Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 3.0 » Invoke-Command

Invoke-Command - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Invoke-Command

Short description
Runs commands on local and remote computers.

Syntax
Invoke-Command [-ScriptBlock] <ScriptBlock> [-ArgumentList <Object[]>] [-InputObject <PSObject>] [-NoNewScope] [<Common
Parameters>]
Invoke-Command [[-ConnectionUri] <Uri[]>] [-ScriptBlock] <ScriptBlock> [-AllowRedirection] [-ArgumentList <Object[]>] [
-AsJob] [-Authentication <AuthenticationMechanism>] [-CertificateThumbprint <String>] [-ConfigurationName <String>] [-C
redential <PSCredential>] [-EnableNetworkAccess] [-HideComputerName] [-InDisconnectedSession] [-InputObject <PSObject>]
 [-JobName <String>] [-SessionOption <PSSessionOption>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Invoke-Command [[-ConnectionUri] <Uri[]>] [-FilePath] <String> [-AllowRedirection] [-ArgumentList <Object[]>] [-AsJob] 
[-Authentication <AuthenticationMechanism>] [-ConfigurationName <String>] [-Credential <PSCredential>] [-EnableNetworkA
ccess] [-HideComputerName] [-InDisconnectedSession] [-InputObject <PSObject>] [-JobName <String>] [-SessionOption <PSSe
ssionOption>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Invoke-Command [[-ComputerName] <String[]>] [-FilePath] <String> [-ApplicationName <String>] [-ArgumentList <Object[]>]
 [-AsJob] [-Authentication <AuthenticationMechanism>] [-ConfigurationName <String>] [-Credential <PSCredential>] [-Enab
leNetworkAccess] [-HideComputerName] [-InDisconnectedSession] [-InputObject <PSObject>] [-JobName <String>] [-Port <Int
32>] [-SessionName <String[]>] [-SessionOption <PSSessionOption>] [-ThrottleLimit <Int32>] [-UseSSL] [<CommonParameters
>]
Invoke-Command [[-ComputerName] <String[]>] [-ScriptBlock] <ScriptBlock> [-ApplicationName <String>] [-ArgumentList <Ob
ject[]>] [-AsJob] [-Authentication <AuthenticationMechanism>] [-CertificateThumbprint <String>] [-ConfigurationName <St
ring>] [-Credential <PSCredential>] [-EnableNetworkAccess] [-HideComputerName] [-InDisconnectedSession] [-InputObject <
PSObject>] [-JobName <String>] [-Port <Int32>] [-SessionName <String[]>] [-SessionOption <PSSessionOption>] [-ThrottleL
imit <Int32>] [-UseSSL] [<CommonParameters>]
Invoke-Command [[-Session] <PSSession[]>] [-FilePath] <String> [-ArgumentList <Object[]>] [-AsJob] [-HideComputerName] 
[-InputObject <PSObject>] [-JobName <String>] [-ThrottleLimit <Int32>] [<CommonParameters>]
Invoke-Command [[-Session] <PSSession[]>] [-ScriptBlock] <ScriptBlock> [-ArgumentList <Object[]>] [-AsJob] [-HideComput
erName] [-InputObject <PSObject>] [-JobName <String>] [-ThrottleLimit <Int32>] [<CommonParameters>]





Description
The Invoke-Command cmdlet runs commands on a local or remote computer and returns all output from the commands, includi
ng errors. With a single Invoke-Command command, you can run commands on multiple computers.


To run a single command on a remote computer, use the ComputerName parameter. To run a series of related commands that 
share data, use the New-PSSession cmdlet to create a PSSession (a persistent connection) on the remote computer, and th
en use the Session parameter of Invoke-Command to run the command in the PSSession. To run a command in a disconnected 
session, use the InDisconnectedSession parameter. To run a command in a background job, use the AsJob parameter.


You can also use Invoke-Command on a local computer to evaluate or run a string in a script block as a command. Windows
 PowerShell converts the script block to a command and runs the command immediately in the current scope, instead of ju
st echoing the string at the command line.


To start an interactive session with a remote computer, use the Enter-PSSession cmdlet. To establish a persistent conne
ction to a remote computer, use the New-PSSession cmdlet.


Before using Invoke-Command to run commands on a remote computer, read about_Remote (http://go.microsoft.com/fwlink/?Li
nkID=135182).