powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Invoke-WmiMethod



NAME
Invoke-WmiMethod

SYNOPSIS
Calls Windows Management Instrumentation (WMI) methods.

SYNTAX
Invoke-WmiMethod [-Class] [[-ArgumentList] ] [-Authentication {Default | None | Connect | Call |
Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority ] [-ComputerName ] [-Credenti
al ] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}
] [-Locale ] [-Namespace ] [-Name] [-AsJob] [-ThrottleLimit ] [-Confirm] [-WhatIf] [<
CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unc
hanged}] [-Authority ] [-ComputerName ] [-Credential ] [-EnableAllPrivileges] [-Imp
ersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale ] [-Namespace ] [-Na
me] [-AsJob] [-ThrottleLimit ] [-Confirm] [-WhatIf] []

Invoke-WmiMethod -InputObject [-ArgumentList ] [-Name] [-AsJob] [-ThrottleLim
it ] [-Confirm] [-WhatIf] []

Invoke-WmiMethod -Path [-ArgumentList ] [-Authentication {Default | None | Connect | Call | Pack
et | PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority ] [-ComputerName ] [-Credential SCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-L
ocale ] [-Namespace ] [-Name] [-AsJob] [-ThrottleLimit ] [-Confirm] [-WhatIf] [ nParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unc
hanged}] [-Authority ] [-ComputerName ] [-Credential ] [-EnableAllPrivileges] [-Imp
ersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale ] [-Namespace ] [-Na
me] [-AsJob] [-ThrottleLimit ] [-Confirm] [-WhatIf] []

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unc
hanged}] [-Authority ] [-ComputerName ] [-Credential ] [-EnableAllPrivileges] [-Imp
ersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Locale ] [-Namespace ] [-Na
me] [-AsJob] [-ThrottleLimit ] [-Confirm] [-WhatIf] []


DESCRIPTION
The Invoke-WmiMethod cmdlet calls WMI methods.


PARAMETERS
-ArgumentList
Specifies the parameters to pass to the called method. The value of this parameter must be an array of objects
and they must appear in the order required by the called method.

Important: A second value of $null is required, otherwise the command will generate an error, such as "Unable t
o cast object of type 'System.Byte' to type 'System.Array'.".

An example using an array of objects ($binSD) followed by a null value ($null) follows:

PS C:\> $acl = get-acl test.txt
PS C:\> $binSD = $acl.GetSecurityDescriptorBinaryForm()
PS C:\> invoke-wmimethod -class Win32_SecurityDescriptorHelper -Name BinarySDToSDDL -argumentlist $binSD, $null

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-AsJob []
Runs the command as a background job. Use this parameter to run commands that take a long time to finish.

When you use the AsJob parameter, the command returns an object that represents the background job and then dis
plays the command prompt. You can continue to work in the session while the job finishes. If Invoke-WmiMethod i
s used against a remote computer, the job is created on the local computer, and the results from remote compute
rs are automatically returned to the local computer. To manage the job, use the cmdlets that contain the Job no
un (the Job cmdlets). To get the job results, use the Receive-Job cmdlet.

Note: To use this parameter with remote computers, the local and remote computers must be configured for remoti
ng. Additionally, you must start Windows PowerShell by using the "Run as administrator" option in Windows Vista
and later versions of Windows. For more information, see about_Remote_Requirements.

For more information about Windows PowerShell background jobs, see about_Jobs and about_Remote_Jobs.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Authentication
Specifies the authentication level to be used with the WMI connection. Valid values are:

-1: Unchanged
0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishes a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call when the application receives the reque
st.)
4: Packet (Authentication is performed on all the data that is received from the client.)
5: PacketIntegrity (All the data that is transferred between the client and the application is authenticated a
nd verified.)
6: PacketPrivacy (The properties of the other authentication levels are used, and all the data is encrypted.)

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Authority
Specifies the authority to use to authenticate the WMI connection. You can specify standard NTLM or Kerberos au
thentication. To use NTLM, set the authority setting to ntlmdomain:, where identifies
a valid NTLM domain name. To use Kerberos, specify kerberos:. You cannot include the aut
hority setting when you connect to the local computer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Class
Specifies the WMI class that contains a static method to call.

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ComputerName
Specifies the computer against which you want to run the management operation. The value can be a fully qualifi
ed domain name, a NetBIOS name, or an Internet Protocol (IP) address. Use the local computer name, use localhos
t, or use a dot (.) to specify the local computer. The local computer is the default. When the remote computer
is in a different domain from the user, a fully qualified domain name is required. You can also set the value
of this parameter by piping the value to the parameter.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Credential
Specifies a user account that has permission to perform this action. The default is the current user. Type a us
er name, such as "User01", "Domain01\User01", or User@Contoso.com. Or, enter a PSCredential object, such as an
object that is returned by the Get-Credential cmdlet. When you type a user name, you will be prompted for a pas
sword.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-EnableAllPrivileges []
Enables all the privileges of the current user before the command makes the WMI call.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Impersonation
Specifies the impersonation level to use. Valid values are:

0: Default (Reads the local registry for the default impersonation level, which is usually set to "3: Impersona
te".)
1: Anonymous (Hides the credentials of the caller.)
2: Identify (Allows objects to query the credentials of the caller.)
3: Impersonate (Allows objects to use the credentials of the caller.)
4: Delegate (Allows objects to permit other objects to use the credentials of the caller.)

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-InputObject
Specifies a ManagementObject object to use as input. When this parameter is used, all other parameters except t
he Flag and Argument parameters are ignored.

Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-Locale
Specifies the preferred locale for WMI objects. Specify the value of the Locale parameter as an array in the MS
_ format in the preferred order.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Name
Specifies the name of the method to be invoked. This parameter is mandatory and cannot be null or empty.

Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Namespace
When used with the Class parameter, this parameter specifies the WMI repository namespace where the referenced
WMI class or object is located.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Path
Specifies the WMI object path of a WMI class, or specifies the WMI object path of an instance of a WMI class. T
he class or the instance that you specify must contain the method that is specified in the Name parameter.

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ThrottleLimit
Allows the user to specify a throttling value for the number of WMI operations that can be executed simultaneou
sly. This parameter is used together with the AsJob parameter. The throttle limit applies only to the current c
ommand, not to the session or to the computer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Confirm []
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf []
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS
None
This cmdlet does not accept any input.


OUTPUTS
None
This cmdlet does not generate any output.


NOTES





-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-wmimethod -path win32_process -name create -argumentlist notepad.exe

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 4844
ReturnValue : 0


Description
-----------
This command starts an instance of Notepad by calling the Create method of the Win32_Process class.

Note: The ReturnValue property is populated with a 0, and the ProcessId property is populated with an integer (the
next process ID number) if the command is completed.





-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-wmimethod -path "CIM_DataFile.Name='C:\scripts\test.txt'" -Name Rename -ArgumentList "C:\scripts\test_
bu.txt"

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0


Description
-----------
This command renames a file. It uses the Path parameter to reference an instance of the CIM_DataFile class. Then, i
t applies the Rename method to that particular instance.

Note: The ReturnValue property is populated with a 0 if the command is completed.






RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113346
Get-WmiObject
Remove-WmiObject
Set-WmiInstance
Get-WSManInstance
Invoke-WSManAction
New-WSManInstance
Remove-WSManInstance