Summary:  Run a Windows PowerShell cmdlet on multiple servers at the same time.

Hey, Scripting Guy! Question How can I run a Windows PowerShell cmdlet on multiple servers at the same time?

              Hey, Scripting Guy! Answer To run a Windows PowerShell cmdlet on multiple servers at the same time use the New-PSSession cmdlet and save the returned session object in a variable. Now use the Invoke-Command cmdlet with the session object to run the command. Use the ScriptBlock parameter to specify the cmdlet to run.

$session = New-PSSession -cn dc2,dc3 -cred iammred\administrator

Invoke-Command -Session $session -ScriptBlock {get-date}