Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Latest commit

History

History
155 lines (111 loc) · 3.38 KB

File metadata and controls

155 lines (111 loc) · 3.38 KB
external help fileWindowsCompatibility-help.xml
Module NameWindowsCompatibility
online version
schema2.0.0

Invoke-WinCommand

SYNOPSIS

Invoke a ScriptBlock that runs in the compatibility runspace.

SYNTAX

Invoke-WinCommand [-ScriptBlock] <ScriptBlock> [-ComputerName <String>] [-ConfigurationName <String>]
[-Credential <PSCredential>] [-ArgumentList <Object[]>] [<CommonParameters>]

DESCRIPTION

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.

EXAMPLES

EXAMPLE 1

Invoke-WinCommand {param ($name) "Hello $name, how are you?"; $PSVersionTable.PSVersion} Jeffrey
Hello 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.

EXAMPLE 2

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.

PARAMETERS

-ArgumentList

Arguments to pass to the ScriptBlock.

Type: Object[]Parameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ComputerName

If 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: False

-ConfigurationName

Specifies 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: False

-Credential

The credential to use when connecting to the compatibility session.

Type: PSCredentialParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False

-ScriptBlock

The ScriptBlock to invoke in the compatibility session.

Type: ScriptBlockParameter Sets: (All)Aliases:
Required: TruePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False

CommonParameters

This 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).

INPUTS

OUTPUTS

System.Management.Automation.PSObject

NOTES

RELATED LINKS