SCOM-Task should start a script on a server

StatelyElf 21 Reputation points
2020-11-09T14:20:54.273+00:00

Hi Thogether

I try to create a task, that starts a powershellscript, which is located on a central scriptserver. The task is for the Objects Windows Server. I wanna start the powershellscript with the DNSName of the target-server as parameter.

So I created a task with the following settings:
Application: powershell.exe
Parameters: -file "\server\f$\test\pscript.ps1" $Target/Property[Type="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/DNSName$

But now the script works with the parameter "$Target/Property[Type="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/DNSName$" instead of the DNSName.

I also tried to set the working directory to my local client and start the script on the server, but had the same issue.

It works, when I copy the Script to my local client, and use the following settings:
Application: powershell.exe
Parameters: -file "C:\test\pscript.ps1" $Target/Property[Type="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/DNSName$

Anybody know how I can start the script on the Server, with the DNSName as parameter?

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,413 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CyrAz 5,181 Reputation points
    2020-11-09T15:52:43.833+00:00

    Could you show us the exact xml code for your task?

    Also there is a more efficient way of running powershell tasks on an agent, have a look at Task.Agent.PowerShell.WithParams.mpx fragment in KEvin Holman's fragment library.

    0 comments No comments