| external help file | WindowsCompatibility-help.xml |
|---|---|
| Module Name | WindowsCompatibility |
| online version | |
| schema | 2.0.0 |
Invoke a ScriptBlock that runs in the compatibility runspace.
Invoke-WinCommand [-ScriptBlock] <ScriptBlock> [-ComputerName <String>] [-ConfigurationName <String>]
[-Credential <PSCredential>] [-ArgumentList <Object[]>] [<CommonParameters>]
This command takes a ScriptBlock and invokes it in the compatibility session. Parameters can be passed using the -ArgumentList parameter.
By default, when executing, the current compatibility session is used, or, in the case where there is no existing session, a new default session will be created. This behavior can be overridden using the additional parameters on the command.
Invoke-WinCommand {param ($name) "Hello $name, how are you?"; $PSVersionTable.PSVersion} JeffreyHello Jeffrey, how are you?
Major Minor Build Revision PSComputerName
----- ----- ----- -------- --------------
5 1 17134 1 localhost
In this example, we're invoking a ScriptBlock with 1 parameter in the compatibility session. This ScriptBlock will simply print a message and then return the version number of the compatibility session.
Invoke-WinCommand {Get-EventLog-Log Application -New 10 }This examples invokes Get-EventLog in the compatibility session, returning the 10 newest events in the application log.
Arguments to pass to the ScriptBlock.
Type: Object[]Parameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseIf you don't want to use the default compatibility session, use this parameter to specify the name of the computer on which to create the compatibility session. (Defaults to 'localhost')
Type: StringParameter Sets: (All)Aliases: cnRequired: FalsePosition: NamedDefault value: localhostAccept pipeline input: FalseAccept wildcard characters: FalseSpecifies the configuration to connect to when creating the compatibility session (Defaults to 'Microsoft.PowerShell')
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: Microsoft.PowerShellAccept pipeline input: FalseAccept wildcard characters: FalseThe credential to use when connecting to the compatibility session.
Type: PSCredentialParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThe ScriptBlock to invoke in the compatibility session.
Type: ScriptBlockParameter Sets: (All)Aliases:
Required: TruePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).