Approve pending agents from file

First dump pending agents to file:

Get-SCOMPendingManagement | sort AgentName | select -ExpandProperty AgentName | Out-File C:\Temp\agents.txt

Remove any agents you don't want from the file then run this to approve them:

$a=gc C:\Temp\agents.txt
foreach ($i in $a) {Get-SCOMPendingManagement | where {$_.AgentName -eq $i} | Approve-SCOMPendingManagement}

Comments