List Agents Pending Management using PowerShell

I don’t know about you but I hate it when I have agents stuck in pending management…because, well they aren’t being managed and there’s no monitoring going on. So here’s a short PowerShell script to list all of your Pending Management Agents.

$pushInstall = $repairAgent = $ManualApproval = $RepairFailed = $PushInstallFailed =0

“Pending Management Stats”
“==========================================”
$agentpending = Get-AgentPendingAction
switch ($agentpending | Select-Object AgentPendingActionType ) {
 {$_.AgentPendingActionType -like “PushInstall”} {$pushInstall++}
 {$_.AgentPendingActionType -like “PushInstallFailed”} {$PushInstallFailed++}
 {$_.AgentPendingActionType -like “ManualApproval”}  {$ManualApproval++}
 {$_.AgentPendingActionType -like “RepairAgent”} {$repairAgent++}
 {$_.AgentPendingActionType -like “RepairFailed”} {$RepairFailed++}


“Push Install ……………….. = $pushInstall”
“Push Install Failed …………. = $PushInstallFailed”
“Manual Approval……………… = $ManualApproval”
“Repair Agent ……………….. = $repairAgent”
“Repair Failed ………………. = $RepairFailed”

This script will produce output like this:

Pending Management Stats
==========================================
Push Install ……………….. = 0
Push Install Failed …………. = 0
Manual Approval……………… = 5
Repair Agent ……………….. = 0
Repair Failed ………………. = 2

Advertisements
This entry was posted in Powershell for SCOM, SCOM Agents and tagged , , . Bookmark the permalink.

One Response to List Agents Pending Management using PowerShell

  1. Rich says:

    Get-AgentPendingAction doesn’t exist. Should be:

    Get-SCOMPendingManagement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s