Home Powershell Activity

Does anyone know how to create a SR to reboot a server using PowerShell

Bryant_RichardsBryant_Richards Customer IT Monkey ✭
We want to setup a SR to reboot a server if its requested and then approved by management. How do you set the Powershell script to input the server name from the SR that needs to be rebooted? We want to automate the SR to reboot server x after the SR is approved.
So if we are using this script (shutdown -r -f -m \\<ServerName> -t 00 -d up:125:1) so we want the user to be able to pick the server name from the asset list and have that name replace the <ServerName> in the script with the server name. Is that possible and if so how do we accomplish this?

Thanks!

Answers

  • Brett_MoffettBrett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
    The PowerShell activity uses Params to pass information from the SR in to the script.
    For example, Start the script with:

    Param([Parameter(Mandatory=$True)][string]$Servername)
    Then at the bottom of the script window, you will see the Servername Powershell Param show up and you can assign a property from the SR.



    The install guide has an example it in. You can get to the install guide here: https://support.cireson.com/KnowledgeBase/View/1369#/

    Hope this answers your question
  • Peter_NordqvistPeter_Nordqvist Customer Adept IT Monkey ✭✭
    It seems that the propertys available is only the default SR propertys? Can you choose to map a parameter to a extended property?
    Otherwise this is not so useful :(
  • Brett_MoffettBrett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
    Hmmmm. I've not checked but I would have thought it would map to any property associated with that WI.
    Let me confirm and get back to you....
  • Brett_MoffettBrett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
    This is true.
    The properties that are available are just for the base class and no derived classes (Including extended classes)

    I am not sure if this is going to be added to in v2+ of the product or not, but you might want to add it to a feature request so it gets on the radar of the product team.
  • Brett_MoffettBrett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
    having said that, there is no reason in the PowerShell code you could not use code like Get-SMObject to get the parent object's data and pull the relationships including any extended properties or related server CI's and then use that.

    For Example:
    Get-SCSMObject -class (Get-SCSMClass -Name system.WorkItem.Incident$) -filter "Status -eq $ParentID" | Select ExtendentPropertyName

Sign In or Register to comment.