PowerShell Remoting Insanity with AppAssure and the Invoke-Command Cmdlet

Although simple, I thought I would share the following PowerShell script since it’s neat due to the fact that it uses the PowerShell remoting Invoke-Command cmdlet to retrieve a list of server names that are protected by an AppAssure Core server where the status is not protected, then it uses the output of that portion of the script (Nesting in parenthesis) as the input for the ComputerName parameter of the outer portion of the script which uses another Invoke-Command to attempt to start the AppAssureAgent service on those servers that were returned by the nested portion of the script:

$cred = Get-Credential
Invoke-Command -ComputerName (
Invoke-Command -ComputerName AppAssureCoreServerName {
Get-ProtectedServers |
where status -ne protected |
select -expand displayname
} -Credential $cred) {
Start-Service AppAssureAgent -PassThru} -Credential $cred


AppAssure version 5.3.1 or higher is required on the AppAssure Core server for PowerShell support. I’ve used the simplified PowerShell version 3 Where-Object syntax in this script since the AppAssure Core server is running PowerShell version 3 .