Discussion:
Putting Server in Maintenance Mode via Power Shell
(too old to reply)
Scopus69
2008-06-23 02:43:00 UTC
Permalink
I am trying to use the following script to put one of my servers in
Maintenance Mode:

param
($rootMS,$computerPrincipalName,$numberOfHoursInMaintenanceMode,$comment)

Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable
errSnapin;
set-location $rootMS -ErrorVariable errSnapin;

$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass
-criteria:$computerCriteria
$healthServices = $computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" + $computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject
-monitoringclass:$healthServiceWatcherClass -criteria:$healthServiceCriteria
$startTime = [System.DateTime]::Now
$endTime = $startTime.AddHours($numberOfHoursInMaintenanceMode)


"Putting " + $computerPrincipalName + " into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment


"Putting the associated health service into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$comment


"Putting the associated health service watcher into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthServiceWatcher -comment:$comment

I can seem to get it to work. I run the following:

PS C:\> .\AgentMaintenanceMode.ps1 -rootMS: `scomsrv01.acme.com'
-computerPrincipalName: 'websrv02.acme.com' -numberOfHo
ursInMaintenanceMode:1 -comment:'Server is now in MaintenanceMode'

ERROR:

Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1.
At C:\AgentMaintenanceMode.ps1:3 char:13
+ Add-PSSnapin <<<<
"Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable
errSnapin;
Set-Location : Cannot find a provider with name 'OperationsManagerMonitoring'.
At C:\AgentMaintenanceMode.ps1:4 char:13
+ Set-Location <<<< "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
The term 'new-managementGroupConnection' is not recognized as a cmdlet,
function, operable program, or script file. Ver
ify the term and try again.
At C:\AgentMaintenanceMode.ps1:5 char:30
+ new-managementGroupConnection <<<< -ConnectionString:$rootMS
-ErrorVariable errSnapin;
Set-Location : Cannot find path 'C:\scomsrv01.acme.com' because it does not
exist.
At C:\AgentMaintenanceMode.ps1:6 char:13
+ set-location <<<< $rootMS -ErrorVariable errSnapin;
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:8 char:37
+ $computerClass = get-monitoringclass <<<< -name:Microsoft.Windows.Computer
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the te
rm and try again.
At C:\AgentMaintenanceMode.ps1:9 char:42
+ $healthServiceClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthService
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:10 char:49
+ $healthServiceWatcherClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthServiceWatcher
The term 'get-monitoringobject' is not recognized as a cmdlet, function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:12 char:33
+ $computer = get-monitoringobject <<<< -monitoringclass:$computerClass
-criteria:$computerCriteria
You cannot call a method on a null-valued expression.
At C:\AgentMaintenanceMode.ps1:13 char:56
+ $healthServices = $computer.GetRelatedMonitoringObjects( <<<<
$healthServiceClass)
Cannot index into a null array.
At C:\AgentMaintenanceMode.ps1:14 char:34
+ $healthService = $healthServices[0 <<<< ]
The term 'get-monitoringobject' is not recognized as a cmdlet, function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:16 char:45
+ $healthServiceWatcher = get-monitoringobject <<<<
-monitoringclass:$healthServiceWatcherClass -criteria:$healthServi
ceCriteria
Putting websrv02.acme.com into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:22 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment
Putting the associated health service into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:26 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$commen
t
Putting the associated health service watcher into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:30 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthServiceWatcher -comment:
$comment
PS C:\>
Anders Bengtsson [MVP]
2008-06-23 07:15:56 UTC
Permalink
Hi Scopus69,

It seems that you are running power shell, not operations manager command
shell, which is a snap-in to the normal power shell. Install both power shell
and ops mgr command shell. Then make sure you start ops mgr command shell
when you want to run the script.
--
Anders Bengtsson
Microsoft MVP - Operations Manager
http://www.contoso.se
Post by Scopus69
I am trying to use the following script to put one of my servers in
param
($rootMS,$computerPrincipalName,$numberOfHoursInMaintenanceMode,$comme
nt)
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable
errSnapin;
set-location $rootMS -ErrorVariable errSnapin;
$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass
-criteria:$computerCriteria
$healthServices =
$computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" +
$computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject
-monitoringclass:$healthServiceWatcherClass
-criteria:$healthServiceCriteria
$startTime = [System.DateTime]::Now
$endTime = $startTime.AddHours($numberOfHoursInMaintenanceMode)
"Putting " + $computerPrincipalName + " into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment
"Putting the associated health service into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$comment
"Putting the associated health service watcher into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthServiceWatcher -comment:$comment
PS C:\> .\AgentMaintenanceMode.ps1 -rootMS: `scomsrv01.acme.com'
-computerPrincipalName: 'websrv02.acme.com' -numberOfHo
ursInMaintenanceMode:1 -comment:'Server is now in MaintenanceMode'
Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1.
At C:\AgentMaintenanceMode.ps1:3 char:13
+ Add-PSSnapin <<<<
"Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable
errSnapin;
Set-Location : Cannot find a provider with name
'OperationsManagerMonitoring'.
At C:\AgentMaintenanceMode.ps1:4 char:13
+ Set-Location <<<< "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
The term 'new-managementGroupConnection' is not recognized as a cmdlet,
function, operable program, or script file. Ver
ify the term and try again.
At C:\AgentMaintenanceMode.ps1:5 char:30
+ new-managementGroupConnection <<<< -ConnectionString:$rootMS
-ErrorVariable errSnapin;
Set-Location : Cannot find path 'C:\scomsrv01.acme.com' because it does not
exist.
At C:\AgentMaintenanceMode.ps1:6 char:13
+ set-location <<<< $rootMS -ErrorVariable errSnapin;
The term 'get-monitoringclass' is not recognized as a cmdlet,
function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:8 char:37
+ $computerClass = get-monitoringclass <<<<
-name:Microsoft.Windows.Computer
The term 'get-monitoringclass' is not recognized as a cmdlet,
function,
operable program, or script file. Verify the te
rm and try again.
At C:\AgentMaintenanceMode.ps1:9 char:42
+ $healthServiceClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthService
The term 'get-monitoringclass' is not recognized as a cmdlet,
function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:10 char:49
+ $healthServiceWatcherClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthServiceWatcher
The term 'get-monitoringobject' is not recognized as a cmdlet,
function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:12 char:33
+ $computer = get-monitoringobject <<<<
-monitoringclass:$computerClass
-criteria:$computerCriteria
You cannot call a method on a null-valued expression.
At C:\AgentMaintenanceMode.ps1:13 char:56
+ $healthServices = $computer.GetRelatedMonitoringObjects( <<<<
$healthServiceClass)
Cannot index into a null array.
At C:\AgentMaintenanceMode.ps1:14 char:34
+ $healthService = $healthServices[0 <<<< ]
The term 'get-monitoringobject' is not recognized as a cmdlet,
function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:16 char:45
+ $healthServiceWatcher = get-monitoringobject <<<<
-monitoringclass:$healthServiceWatcherClass -criteria:$healthServi
ceCriteria
Putting websrv02.acme.com into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:22 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment
Putting the associated health service into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:26 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$commen
t
Putting the associated health service watcher into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:30 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
$comment
PS C:\>
Scopus69
2008-06-23 17:59:02 UTC
Permalink
Anders,

Thanks for the quick response. I have a few follow up questions.
Is Operations Manager Command Shell installed by default on the SCOM 2007 Server?
Should this script be running on the local Server that I am monitoring or on the SCOM 2007 server?
How do you access this Operations Manager Command Shell?
Hi Scopus69,
It seems that you are running power shell, not operations manager command
shell, which is a snap-in to the normal power shell. Install both power shell
and ops mgr command shell. Then make sure you start ops mgr command shell
when you want to run the script.
--
Anders Bengtsson
Microsoft MVP - Operations Manager
http://www.contoso.se
Post by Scopus69
I am trying to use the following script to put one of my servers in
param
($rootMS,$computerPrincipalName,$numberOfHoursInMaintenanceMode,$comme
nt)
Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable
errSnapin;
set-location $rootMS -ErrorVariable errSnapin;
$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass
-criteria:$computerCriteria
$healthServices =
$computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" +
$computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject
-monitoringclass:$healthServiceWatcherClass
-criteria:$healthServiceCriteria
$startTime = [System.DateTime]::Now
$endTime = $startTime.AddHours($numberOfHoursInMaintenanceMode)
"Putting " + $computerPrincipalName + " into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment
"Putting the associated health service into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$comment
"Putting the associated health service watcher into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthServiceWatcher -comment:$comment
PS C:\> .\AgentMaintenanceMode.ps1 -rootMS: `scomsrv01.acme.com'
-computerPrincipalName: 'websrv02.acme.com' -numberOfHo
ursInMaintenanceMode:1 -comment:'Server is now in MaintenanceMode'
Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1.
At C:\AgentMaintenanceMode.ps1:3 char:13
+ Add-PSSnapin <<<<
"Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable
errSnapin;
Set-Location : Cannot find a provider with name
'OperationsManagerMonitoring'.
At C:\AgentMaintenanceMode.ps1:4 char:13
+ Set-Location <<<< "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
The term 'new-managementGroupConnection' is not recognized as a cmdlet,
function, operable program, or script file. Ver
ify the term and try again.
At C:\AgentMaintenanceMode.ps1:5 char:30
+ new-managementGroupConnection <<<< -ConnectionString:$rootMS
-ErrorVariable errSnapin;
Set-Location : Cannot find path 'C:\scomsrv01.acme.com' because it does not
exist.
At C:\AgentMaintenanceMode.ps1:6 char:13
+ set-location <<<< $rootMS -ErrorVariable errSnapin;
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:8 char:37
+ $computerClass = get-monitoringclass <<<<
-name:Microsoft.Windows.Computer
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the te
rm and try again.
At C:\AgentMaintenanceMode.ps1:9 char:42
+ $healthServiceClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthService
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:10 char:49
+ $healthServiceWatcherClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthServiceWatcher
The term 'get-monitoringobject' is not recognized as a cmdlet, function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:12 char:33
+ $computer = get-monitoringobject <<<<
-monitoringclass:$computerClass
-criteria:$computerCriteria
You cannot call a method on a null-valued expression.
At C:\AgentMaintenanceMode.ps1:13 char:56
+ $healthServices = $computer.GetRelatedMonitoringObjects( <<<<
$healthServiceClass)
Cannot index into a null array.
At C:\AgentMaintenanceMode.ps1:14 char:34
+ $healthService = $healthServices[0 <<<< ]
The term 'get-monitoringobject' is not recognized as a cmdlet, function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:16 char:45
+ $healthServiceWatcher = get-monitoringobject <<<<
-monitoringclass:$healthServiceWatcherClass -criteria:$healthServi
ceCriteria
Putting websrv02.acme.com into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:22 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment
Putting the associated health service into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:26 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$commen
t
Putting the associated health service watcher into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:30 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime -endTime:$endTime
$comment
PS C:\>
Anders Bengtsson [MVP]
2008-06-26 20:35:10 UTC
Permalink
Hi Scopus69,

The ops Mgr command shell is not installed by default, you have to select
it during the setup wizard. The script should be run on the managemnet server.
--
Anders Bengtsson
Microsoft MVP - Operations Manager
Microsoft Certified Trainer (MCT)
http://www.contoso.se
Post by Scopus69
Anders,
Thanks for the quick response. I have a few follow up questions.
Is Operations Manager Command Shell installed by default on the SCOM 2007 Server?
Should this script be running on the local Server that I am
monitoring or on the SCOM 2007 server?
How do you access this Operations Manager Command Shell?
Hi Scopus69,
It seems that you are running power shell, not operations manager
command shell, which is a snap-in to the normal power shell. Install
both power shell and ops mgr command shell. Then make sure you start
ops mgr command shell when you want to run the script.
--
Anders Bengtsson
Microsoft MVP - Operations Manager
http://www.contoso.se
Post by Scopus69
I am trying to use the following script to put one of my servers in
param
($rootMS,$computerPrincipalName,$numberOfHoursInMaintenanceMode,$com
me nt)
Add-PSSnapin
"Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable
errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS
-ErrorVariable
errSnapin;
set-location $rootMS -ErrorVariable errSnapin;
$computerClass = get-monitoringclass
-name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass
-name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass
-criteria:$computerCriteria
$healthServices =
$computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" +
$computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject
-monitoringclass:$healthServiceWatcherClass
-criteria:$healthServiceCriteria
$startTime = [System.DateTime]::Now
$endTime = $startTime.AddHours($numberOfHoursInMaintenanceMode)
"Putting " + $computerPrincipalName + " into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$computer -comment:$comment
"Putting the associated health service into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthService -comment:$comment
"Putting the associated health service watcher into maintenance
mode" New-MaintenanceWindow -startTime:$startTime -endTime:$endTime
-monitoringObject:$healthServiceWatcher -comment:$comment
PS C:\> .\AgentMaintenanceMode.ps1 -rootMS: `scomsrv01.acme.com'
-computerPrincipalName: 'websrv02.acme.com' -numberOfHo
ursInMaintenanceMode:1 -comment:'Server is now in MaintenanceMode'
Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1.
At C:\AgentMaintenanceMode.ps1:3 char:13
+ Add-PSSnapin <<<<
"Microsoft.EnterpriseManagement.OperationsManager.Client"
-ErrorVariable
errSnapin;
Set-Location : Cannot find a provider with name
'OperationsManagerMonitoring'.
At C:\AgentMaintenanceMode.ps1:4 char:13
+ Set-Location <<<< "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
The term 'new-managementGroupConnection' is not recognized as a cmdlet,
function, operable program, or script file. Ver
ify the term and try again.
At C:\AgentMaintenanceMode.ps1:5 char:30
+ new-managementGroupConnection <<<< -ConnectionString:$rootMS
-ErrorVariable errSnapin;
Set-Location : Cannot find path 'C:\scomsrv01.acme.com' because it does not
exist.
At C:\AgentMaintenanceMode.ps1:6 char:13
+ set-location <<<< $rootMS -ErrorVariable errSnapin;
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:8 char:37
+ $computerClass = get-monitoringclass <<<<
-name:Microsoft.Windows.Computer
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the te
rm and try again.
At C:\AgentMaintenanceMode.ps1:9 char:42
+ $healthServiceClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthService
The term 'get-monitoringclass' is not recognized as a cmdlet, function,
operable program, or script file. Verify the term and try again.
At C:\AgentMaintenanceMode.ps1:10 char:49
+ $healthServiceWatcherClass = get-monitoringclass <<<<
-name:Microsoft.SystemCenter.HealthServiceWatcher
The term 'get-monitoringobject' is not recognized as a cmdlet, function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:12 char:33
+ $computer = get-monitoringobject <<<<
-monitoringclass:$computerClass
-criteria:$computerCriteria
You cannot call a method on a null-valued expression.
At C:\AgentMaintenanceMode.ps1:13 char:56
+ $healthServices = $computer.GetRelatedMonitoringObjects( <<<<
$healthServiceClass)
Cannot index into a null array.
At C:\AgentMaintenanceMode.ps1:14 char:34
+ $healthService = $healthServices[0 <<<< ]
The term 'get-monitoringobject' is not recognized as a cmdlet, function,
operable program, or script file. Verify the t
erm and try again.
At C:\AgentMaintenanceMode.ps1:16 char:45
+ $healthServiceWatcher = get-monitoringobject <<<<
-monitoringclass:$healthServiceWatcherClass -criteria:$healthServi
ceCriteria
Putting websrv02.acme.com into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:22 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime
-endTime:$endTime
-monitoringObject:$computer -comment:$comment
Putting the associated health service into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:26 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime
-endTime:$endTime
-monitoringObject:$healthService -comment:$commen
t
Putting the associated health service watcher into maintenance mode
The term 'New-MaintenanceWindow' is not recognized as a cmdlet, function,
operable program, or script file. Verify the
term and try again.
At C:\AgentMaintenanceMode.ps1:30 char:22
+ New-MaintenanceWindow <<<< -startTime:$startTime
-endTime:$endTime
$comment
PS C:\>
Loading...