Scheduling OpsMgr PowerShell scripts

When scheduling an Operations Manager PowerShell script you have to load the powershell snapins.

Insert this in the beginning of your script

$ServerName = “hostname”
add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”;
set-location “OperationsManagerMonitoring::”;
new-managementGroupConnection -ConnectionString:$ServerName;
set-location $ServerName;

One Comment

  1. […] http://www.opsmode.com/2009/09/scheduling-opsmgr-powershell-scripts/ # #Scheduling OpsMgr PowerShell scripts #2009/09/17, 10:37 When scheduling an Operations Manager PowerShell script you have to load the powershell snapins. # #Insert this in the beginning of your script # #$ServerName = “hostname” #add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”; #set-location “OperationsManagerMonitoring::”; #new-managementGroupConnection -ConnectionString:$ServerName; #set-location $ServerName; # […]