| external help file | WindowsCompatibility-help.xml |
|---|---|
| Module Name | WindowsCompatibility |
| online version | |
| schema | 2.0.0 |
This command defines a global function that always runs in the compatibility session.
Add-WinFunction [-Name] <String> [-ScriptBlock] <ScriptBlock> [-ComputerName <String>]
[-ConfigurationName <String>] [-Credential <PSCredential>] [<CommonParameters>]
This command defines a global function that always runs in the compatibility session, returning serialized data to the calling session. Parameters can be specified using the 'param' statement but only positional parameters are supported.
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.
Add-WinFunction myFunction {param ($n) "Hi $n!"; $PSVersionTable.PSEdition }
myFunction BillHi Bill!
Desktop
This example defines a function called 'myFunction' with 1 parameter. When invoked it will print a message then return the PSVersion table from the compatibility session.
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: 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 creating the compatibility session using the target machine/configuration
Type: PSCredentialParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThe name of the function to define.
Type: StringParameter Sets: (All)Aliases: FunctionNameRequired: TruePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseScriptBlock to use as the body of the function.
Type: ScriptBlockParameter Sets: (All)Aliases:
Required: TruePosition: 2Default 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).