Can you restart SQL Server Reporting Services using Powershell?

Welcome Forums General PowerShell Q&A Can you restart SQL Server Reporting Services using Powershell?

Viewing 4 reply threads
  • Author
    Posts
    • #186586
      Participant
      Topics: 1
      Replies: 0
      Points: 12
      Rank: Member

      Hi!

      I’m new to powershell but trying to learn. I need to restart a named instance of SSRS on a server. The instance is called POCSSRS

      This is my code:

      Get-Service -Computer $ssrs.machinename -Name “POCSSRS” | Restart-Service;

      But I get the error:

      Get-Service : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

       

      Any idea what Im doing wrong?

      Thanks,

      Zoe

       

    • #186607
      Participant
      Topics: 0
      Replies: 42
      Points: 414
      Team MemberHelping Hand
      Rank: Contributor

      It looks like the property “machinename” on the $SSRS object is null or empty. If you output $SSRS.MachineName, is the value a string?

      If you look at $SSRS, are there any other properties that might be useful?

    • #186790
      Moderator
      Topics: 4
      Replies: 231
      Points: 1,260
      Helping Hand
      Rank: Community Hero

      Hi @Zoe79,

      In your command, the parameter name is not -Computer, its -ComputerName.

      Usually named SSRS instances are created with the service name as ‘ReportServer$InstanceName’.

      so in your case, you can use the command below…

      Get-Service -ComputerName $ssrs.machinename -Name ‘ReportServer$POCSSRS’ | Restart-Service;
      
      

      Thank you.

    • #186799
      Participant
      Topics: 12
      Replies: 1651
      Points: 2,702
      Helping Hand
      Rank: Community Hero

      @Kiran

      Powershell will actually work on portion parameter names as long as it’s non-ambiguous. For instance, you have Get-WMIObject that has -ComputerName and -Class, we can’t use -C because that it is ambiguous, but if you add a letter it will work:

      gwmi -co . -cl Win32_OperatingSystem
      

      Powershell is built for admins so it is not strict and does a lot of automatic look ups. -Co is basically a wildcard search -Co* that resolves to -ComputerName. For instance, Powershell also does things like automatic Module import if you call a command and it’s not available. It’s all about making things simple.

    • #186814
      Moderator
      Topics: 4
      Replies: 231
      Points: 1,260
      Helping Hand
      Rank: Community Hero

      @kiran

      Powershell will actually work on portion parameter names as long as it’s non-ambiguous. For instance, you have Get-WMIObject that has -ComputerName and -Class, we can’t use -C because that it is ambiguous, but if you add a letter it will work:

      <textarea class=”ace_text-input” style=”opacity: 0; height: 17.6471px; width: 7.19608px; left: 45px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

      1
      2
      gwmi co . cl Win32_OperatingSystem
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

      Powershell is built for admins so it is not strict and does a lot of automatic look ups. -Co is basically a wildcard search -Co* that resolves to -ComputerName. For instance, Powershell also does things like automatic Module import if you call a command and it’s not available. It’s all about making things simple.

      Okay, it’s something new to me. Noted.

      Thank you.

Viewing 4 reply threads
  • The topic ‘Can you restart SQL Server Reporting Services using Powershell?’ is closed to new replies.