title: Powershell Trying To Restart Print Spooler
body: <p>I have a PowerShell script that obtains the actual name of the Windows Print Spooler</p>
  <pre><code>$serviceDisplayName = &quot;Print Spooler&quot;
  $actualServiceName = (Get-Service -DisplayName &quot;$serviceDisplayName&quot;).Name
  </code></pre>
  <p>I can find out accurately whether or not the <em>Print Spooler</em> is running:</p>
  <pre><code>Try
  {
      $serviceInqResults = get-service -Name $actualServiceName -ErrorVariable err
  }
  
  Catch 
  {
      write-output &quot;An exception occurred while trying to see if $serviceDisplayName were running or not.&quot;
      write-output $err
  }
  </code></pre>
  <p>But, when I try to restart the Print Spooler by either it's real name or its display name, I get the same error:</p>
  <pre><code>if($serviceInqResults.Status -ne &quot;Running&quot;)
  {
      write-output &quot;The service is not running. Starting the $serviceDisplayName &quot;
  
     try
     {
          Start-Service -Name $actualServiceName -ErrorVariable err
     }
      
      Catch
      {
          write-output $err
      }
  
  
  Service 'Print Spooler (Spooler)' cannot be started due 
  to the following error: Cannot open Spooler service on computer '.'.
  </code></pre>
  <p>I have tried starting the service with the name &quot;Print Spooler&quot;, &quot;Spooler&quot;, &quot;Print Spooler (Spooler)&quot; all with the same error, and yet I can start it in the service control manager (Services).</p>
  <p>I am wondering what I am missing.</p>