Skip to main content

Invoke-ObjectMethod

SYNOPSISโ€‹

Invoke method on any object.

SYNTAXโ€‹

Positional (Default)โ€‹

Invoke-ObjectMethod [-InputObject] <Object> [-MethodName] <String> [[-ArgumentList] <Object[]>]
[<CommonParameters>]

Namedโ€‹

Invoke-ObjectMethod [-InputObject] <Object> [-MethodName] <String> [-Parameter] <Hashtable>
[<CommonParameters>]

DESCRIPTIONโ€‹

Invoke method on any object with or without using named parameters.

EXAMPLESโ€‹

EXAMPLE 1โ€‹

$ShellApp = New-Object -ComObject 'Shell.Application'

$null = Invoke-ObjectMethod -InputObject $ShellApp -MethodName 'MinimizeAll'

Minimizes all windows.

EXAMPLE 2โ€‹

$ShellApp = New-Object -ComObject 'Shell.Application'

$null = Invoke-ObjectMethod -InputObject $ShellApp -MethodName 'Explore' -Parameter @{'vDir'='C:\Windows'}

Opens the C:\Windows folder in a Windows Explorer window.

PARAMETERSโ€‹

-InputObjectโ€‹

Specifies an object which has methods that can be invoked.

Type: Object
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MethodNameโ€‹

Specifies the name of a method to invoke.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ArgumentListโ€‹

Argument to pass to the method being executed. Allows execution of method without specifying named parameters.

Type: Object[]
Parameter Sets: Positional
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Parameterโ€‹

Argument to pass to the method being executed. Allows execution of method by using named parameters.

Type: Hashtable
Parameter Sets: Named
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept 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.

INPUTSโ€‹

Noneโ€‹

You cannot pipe objects to this function.โ€‹

OUTPUTSโ€‹

System.Object.โ€‹

The object returned by the method being invoked.โ€‹

NOTESโ€‹

This is an internal script function and should typically not be called directly.

https://psappdeploytoolkit.com