Can you restart SQL Server Reporting Services using Powershell?

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

  • This topic has 4 replies, 4 voices, and was last updated 1 month ago by
    Participant
    .
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
      Moderator
      Topics: 0
      Replies: 42
      Points: 388
      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
      Participant
      Topics: 3
      Replies: 137
      Points: 721
      Helping Hand
      Rank: Major Contributor

      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: 10
      Replies: 1284
      Points: 1,084
      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
      Participant
      Topics: 3
      Replies: 137
      Points: 721
      Helping Hand
      Rank: Major Contributor

      @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:

      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
  • You must be logged in to reply to this topic.