Runs commands on local and remote computers.
-AllowRedirection
Allows redirection of this connection to an alternate URI.
When you use the ConnectionURI parameter, the remote destination can return an instruction to redirect to a different URI. By default, Windows PowerShell does not redirect connections, but you can use the AllowRedirection parameter to allow it to redirect the connection.
You can also limit the number of times that the connection is redirected by setting the MaximumConnectionRedirectionCount property of the $PSSessionOption preference variable, or the MaximumConnectionRedirectionCount property of the value of the SessionOption parameter. The default value is 5. For more information, see the description of the SessionOption parameter and the help topic for the New-PSSessionOption cmdlet.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-ApplicationName <string>
Specifies the application name segment of the connection URI. Use this parameter to specify the application name when you are not using the ConnectionURI parameter in the command.
The default value is the value of the $PSSessionApplicationName preference variable on the local computer. If this preference variable is not defined, the default value is WSMAN. This value is appropriate for most uses. For more information, see about_Preference_Variables.
The WinRM service uses the application name to select a listener to service the connection request. The value of this parameter should match the value of the URLPrefix property of a listener on the remote computer.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
WSMAN
|
|
Accept Pipeline Input?
|
true (ByPropertyName)
|
|
Accept Wildcard Characters?
|
false
|
-ArgumentList <Object[]>
Supplies the values of local variables in the command. The variables in the command are replaced by these values before the command is run on the remote computer. Enter the values in a comma-separated list. Values are associated with variables in the order that they are listed. The alias for ArgumentList is "Args".
The values in ArgumentList can be actual values, such as "1024", or they can be references to local variables, such as "$max".
To use local variables in a command, use the following command format:
{param($<name1>[, $<name2>]...) <command-with-local-variables>} -ArgumentList <value> -or- <local-variable>
The "param" keyword lists the local variables that are used in the command. The ArgumentList parameter supplies the values of the variables, in the order that they are listed.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-AsJob
Runs the command as a background job on a remote computer. Use this parameter to run commands that take an extensive time to complete.
When you use AsJob, the command returns an object that represents the job, and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the Job cmdlets. To get the job results, use Receive-Job.
The AsJob parameter is similar to using Invoke-Command to run a Start-Job command remotely. However, with AsJob, the job is created on the local computer, even though the job runs on a remote computer, and the results of the remote job are automatically returned to the local computer.
For more information about Windows PowerShell background jobs, see about_Jobs and about_Remote_Jobs.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
None
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-Authentication <AuthenticationMechanism>
Specifies the mechanism that is used to authenticate the user's credentials. Valid values are Default, Basic, Credssp, Digest, Kerberos, Negotiate, and NegotiateWithImplicitCredential. The default value is Default.
CredSSP authentication is available only in Windows Vista, Windows Server 2008, and later versions of Windows.
For information about the values of this parameter, see the description of the System.Management.Automation.Runspaces.AuthenticationMechanism enumeration in MSDN.
CAUTION: Credential Security Service Provider (CredSSP) authentication, in which the user's credentials are passed to a remote computer to be authenticated, is designed for commands that require authentication on more than one resource, such as accessing a remote network share. This mechanism increases the security risk of the remote operation. If the remote computer is compromised, the credentials that are passed to it can be used to control the network session.The following values are permitted for this object type.
-
Default
-
Basic
-
Negotiate
-
NegotiateWithImplicitCredential
-
Credssp
-
Digest
-
Kerberos
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
Default
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-CertificateThumbprint <string>
Specifies the digital public key certificate (X509) of a user account that has permission to perform this action. Enter the certificate thumbprint of the certificate.
Certificates are used in client certificate-based authentication. They can only be mapped to local user accounts; they do not work with domain accounts.
To get a certificate thumbprint, use the Get-Item or Get-ChildItem commands in the Windows PowerShell Cert: drive.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-ComputerName <string[]>
Specifies the computers on which the command runs. The default is the local computer.
When you use the ComputerName parameter, Windows PowerShell creates a temporary connection that is used only to run the specified command and is then closed. If you need a persistent connection, use the Session parameter.
Type the NETBIOS name, IP address, or fully-qualified domain name of one or more computers in a comma-separated list. To specify the local computer, type the computer name, "localhost", or a dot (.).
To use an IP address in the value of the ComputerName parameter, the command must include the Credential parameter. Also, the computer must be configured for HTTPS transport or the IP address of the remote computer must be included in the WinRM TrustedHosts list on the local computer. For instructions for adding a computer name to the TrustedHosts list, see "How to Add a Computer to the Trusted Host List" in about_Remote_Troubleshooting.
Note: On Windows Vista, and later versions of Windows, to include the local computer in the value of the ComputerName parameter, you must open Windows PowerShell with the "Run as administrator" option.
|
Required?
|
false
|
|
Position?
|
1
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
true (ByPropertyName)
|
|
Accept Wildcard Characters?
|
false
|
-ConfigurationName <string>
Specifies the session configuration that is used for the new PSSession.
Enter a configuration name or the fully qualified resource URI for a session configuration. If you specify only the configuration name, the following schema URI is prepended: http://schemas.microsoft.com/powershell.
The session configuration for a session is located on the remote computer. If the specified session configuration does not exist on the remote computer, the command fails.
The default value is the value of the $PSSessionConfigurationName preference variable on the local computer. If this preference variable is not set, the default is Microsoft.PowerShell. For more information, see about_Preference_Variables.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
http://Schemas.Microsoft.com/PowerShell/Microsoft.PowerShell
|
|
Accept Pipeline Input?
|
true (ByPropertyName)
|
|
Accept Wildcard Characters?
|
false
|
-ConnectionURI <Uri[]>
Specifies a Uniform Resource Identifier (URI) that defines the connection endpoint for the interactive session. The URI must be fully qualified. The format of this string is as follows:
<Transport>://<ComputerName>:<Port>/<ApplicationName>
The default value is as follows:
http://localhost:5985/WSMAN
If you do not specify a ConnectionURI, you can use the UseSSL, ComputerName, Port, and ApplicationName parameters to specify the ConnectionURI values.
Valid values for the Transport segment of the URI are HTTP and HTTPS. If you specify a connection URI with a Transport segment, but do not specify a port, the session is created with standards ports: 80 for HTTP and 443 for HTTPS. To use the default ports for Windows PowerShell remoting, specify port 5985 for HTTP or 5986 for HTTPS.
If the destination computer redirects the connection to a different URI, Windows PowerShell prevents the redirection unless you use the AllowRedirection parameter in the command.
|
Required?
|
false
|
|
Position?
|
1
|
|
Default Value
|
http://localhost:80/wsman
|
|
Accept Pipeline Input?
|
true (ByPropertyName)
|
|
Accept Wildcard Characters?
|
false
|
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. The default is the current user.
Type a user name, such as "User01" or "Domain01\User01", or enter a variable that contains a PSCredential object, such as one generated by the Get-Credential cmdlet. When you type a user name, you will be prompted for a password.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
true (ByPropertyName)
|
|
Accept Wildcard Characters?
|
false
|
-FilePath <string>
Runs the specified local script on one or more remote computers. Enter the path and file name of the script, or pipe a script path to Invoke-Command. The script must reside on the local computer or in a directory that the local computer can access. Use the ArgumentList parameter to specify the values of parameters in the script.
When you use this parameter, Windows PowerShell converts the contents of the specified script file to a script block, transmits the script block to the remote computer, and runs it on the remote computer.
|
Required?
|
true
|
|
Position?
|
2
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-HideComputerName
Omits the computer name of each object from the output display. By default, the name of the computer that generated the object appears in the display.
This parameter affects only the output display. It does not change the object.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-InputObject <psobject>
Specifies input to the command. Enter a variable that contains the objects or type a command or expression that gets the objects.
When using InputObject, use the $input automatic variable in the value of the ScriptBlock parameter to represent the input objects.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
true (ByValue)
|
|
Accept Wildcard Characters?
|
false
|
-JobName <string>
Specifies a friendly name for the background job. By default, jobs are named "Job<n>", where <n> is an ordinal number. This parameter is valid only with the AsJob parameter.
If you use the JobName parameter in a command, the command is run as a job, and Invoke-Command returns a job object, even if you do not include the AsJob parameter in the command.
For more information about Windows PowerShell background jobs, see about_Jobs.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
Job<n>
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-Port <int>
Specifies the network port on the remote computer that is used for this connection. To connect to a remote computer, the remote computer must be listening on the port that the connection uses. The default ports are 5985 (the WinRM port for HTTP) and 5986 (the WinRM port for HTTPS).
Before using an alternate port, you must configure the WinRM listener on the remote computer to listen at that port. To configure the listener, type the following two commands at the Windows PowerShell prompt:
remove-item -path wsman:\Localhost\listener\listener* -recurse
new-item -path wsman:\Localhost\listener -Transport http -Address * -port <port-number>
Do not use the Port parameter unless you must. The Port set in the command applies to all computers or sessions on which the command runs. An alternate port setting might prevent the command from running on all computers.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-ScriptBlock <scriptblock>
Specifies the commands to run. Enclose the commands in braces ( { } ) to create a script block. This parameter is required.
By default, any variables in the command are evaluated on the remote computer. To include local variables in the command, use the ArgumentList parameter.
|
Required?
|
true
|
|
Position?
|
1
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-Session <PSSession[]>
Runs the command in the specified Windows PowerShell sessions (PSSessions). Enter a variable that contains the PSSessions or a command that creates or gets the PSSessions, such as a New-PSSession or Get-PSSession command.
When you create a PSSession, Windows PowerShell establishes a persistent connection to the remote computer. Use a PSSession to run a series of related commands that share data. To run a single command or a series of unrelated commands, use the ComputerName parameter.
To create a PSSession, use the New-PSSession cmdlet. For more information, see about_PSSessions.
|
Required?
|
false
|
|
Position?
|
1
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
true (ByPropertyName)
|
|
Accept Wildcard Characters?
|
false
|
-SessionOption <PSSessionOption>
Sets advanced options for the session. Enter a SessionOption object that you create by using the New-PSSessionOption cmdlet.
The default values for the options are determined by the value of the $PSSessionOption preference variable, if it is set. Otherwise, the session uses the system defaults.
For a description of the session options, including the default values, see the help topic for the New-PSSessionOption cmdlet. For information about the $PSSessionOption preference variable, see about_Preference_Variables.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-ThrottleLimit <int>
Specifies the maximum number of concurrent connections that can be established to run this command. If you omit this parameter or enter a value of 0, the default value, 32, is used.
The throttle limit applies only to the current command, not to the session or to the computer.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
32
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
-UseSSL
Uses the Secure Sockets Layer (SSL) protocol to establish a connection to the remote computer. By default, SSL is not used.
WS-Management encrypts all Windows PowerShell content transmitted over the network. UseSSL is an additional protection that sends the data across an HTTPS, instead of HTTP.
If you use this parameter, but SSL is not available on the port used for the command, the command fails.
|
Required?
|
false
|
|
Position?
|
named
|
|
Default Value
|
|
|
Accept Pipeline Input?
|
false
|
|
Accept Wildcard Characters?
|
false
|
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.