Skip to content

Commit d7fb685

Browse files
authored
Fix parameter order examples and formatting (#10861)
1 parent 401909e commit d7fb685

File tree

1 file changed

+42
-54
lines changed

1 file changed

+42
-54
lines changed

reference/5.1/Microsoft.PowerShell.Management/Invoke-WmiMethod.md

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Management
5-
ms.date: 06/28/2023
5+
ms.date: 02/05/2024
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/invoke-wmimethod?view=powershell-5.1&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Invoke-WmiMethod
@@ -27,8 +27,8 @@ Invoke-WmiMethod [-Class] <String> [-Name] <String> [-ArgumentList <Object[]>] [
2727
### object
2828

2929
```
30-
Invoke-WmiMethod -InputObject <ManagementObject> [-Name] <String> [-ArgumentList <Object[]>] [-AsJob]
31-
[-ThrottleLimit <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
30+
Invoke-WmiMethod -InputObject <ManagementObject> [-Name] <String> [-ArgumentList <Object[]>]
31+
[-AsJob] [-ThrottleLimit <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
3232
```
3333

3434
### path
@@ -44,27 +44,27 @@ Invoke-WmiMethod -Path <String> [-Name] <String> [-ArgumentList <Object[]>] [-As
4444

4545
```
4646
Invoke-WmiMethod [-Name] <String> [-AsJob] [-Impersonation <ImpersonationLevel>]
47-
[-Authentication <AuthenticationLevel>] [-Locale <String>] [-EnableAllPrivileges] [-Authority <String>]
48-
[-Credential <PSCredential>] [-ThrottleLimit <Int32>] [-ComputerName <String[]>] [-Namespace <String>]
49-
[-WhatIf] [-Confirm] [<CommonParameters>]
47+
[-Authentication <AuthenticationLevel>] [-Locale <String>] [-EnableAllPrivileges]
48+
[-Authority <String>] [-Credential <PSCredential>] [-ThrottleLimit <Int32>]
49+
[-ComputerName <String[]>] [-Namespace <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
5050
```
5151

5252
### query
5353

5454
```
5555
Invoke-WmiMethod [-Name] <String> [-AsJob] [-Impersonation <ImpersonationLevel>]
56-
[-Authentication <AuthenticationLevel>] [-Locale <String>] [-EnableAllPrivileges] [-Authority <String>]
57-
[-Credential <PSCredential>] [-ThrottleLimit <Int32>] [-ComputerName <String[]>] [-Namespace <String>]
58-
[-WhatIf] [-Confirm] [<CommonParameters>]
56+
[-Authentication <AuthenticationLevel>] [-Locale <String>] [-EnableAllPrivileges]
57+
[-Authority <String>] [-Credential <PSCredential>] [-ThrottleLimit <Int32>]
58+
[-ComputerName <String[]>] [-Namespace <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
5959
```
6060

6161
### list
6262

6363
```
6464
Invoke-WmiMethod [-Name] <String> [-AsJob] [-Impersonation <ImpersonationLevel>]
65-
[-Authentication <AuthenticationLevel>] [-Locale <String>] [-EnableAllPrivileges] [-Authority <String>]
66-
[-Credential <PSCredential>] [-ThrottleLimit <Int32>] [-ComputerName <String[]>] [-Namespace <String>]
67-
[-WhatIf] [-Confirm] [<CommonParameters>]
65+
[-Authentication <AuthenticationLevel>] [-Locale <String>] [-EnableAllPrivileges]
66+
[-Authority <String>] [-Credential <PSCredential>] [-ThrottleLimit <Int32>]
67+
[-ComputerName <String[]>] [-Namespace <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
6868
```
6969

7070
## DESCRIPTION
@@ -80,60 +80,38 @@ those running other operating systems. Instead of using `Invoke-WmiMethod`, cons
8080

8181
## EXAMPLES
8282

83-
### Example 1: List the required order of WMI objects
83+
### Example 1: List the required order of WMI method parameters
84+
85+
This command lists the required order of the objects.
8486

8587
```powershell
86-
([wmiclass]'Win32_Volume').GetMethodParameters('Format')
88+
Get-WmiObject Win32_Volume |
89+
Get-Member -MemberType Method -Name Format |
90+
Select-Object -ExpandProperty Definition
8791
```
8892

8993
```Output
90-
__GENUS : 2
91-
__CLASS : __PARAMETERS
92-
__SUPERCLASS :
93-
__DYNASTY : __PARAMETERS
94-
__RELPATH :
95-
__PROPERTY_COUNT : 6
96-
__DERIVATION : {}
97-
__SERVER :
98-
__NAMESPACE :
99-
__PATH :
100-
ClusterSize : 0
101-
EnableCompression : False
102-
FileSystem : NTFS
103-
Label :
104-
QuickFormat : False
105-
Version : 0
106-
PSComputerName :
107-
```
108-
109-
This command lists the required order of the objects. To invoke WMI in PowerShell 3.0 differs from
110-
alternate methods, and requires that object values are entered in a specific order.
94+
System.Management.ManagementBaseObject Format(System.String FileSystem, System.Boolean QuickFormat,
95+
System.UInt32 ClusterSize, System.String Label, System.Boolean EnableCompression,
96+
System.UInt32 Version)
97+
```
98+
99+
To invoke WMI in PowerShell 3.0 differs from alternate methods, and requires that object values are
100+
entered in a specific order.
111101

112102
### Example 2: Start an instance of an application
113103

114104
```powershell
115-
([Wmiclass]'Win32_Process').GetMethodParameters('Create')
105+
([Wmiclass]'Win32_Process').Create.OverloadDefinitions
116106
```
117107

118108
```Output
119-
__GENUS : 2
120-
__CLASS : __PARAMETERS
121-
__SUPERCLASS :
122-
__DYNASTY : __PARAMETERS
123-
__RELPATH :
124-
__PROPERTY_COUNT : 3
125-
__DERIVATION : {}
126-
__SERVER :
127-
__NAMESPACE :
128-
__PATH :
129-
CommandLine :
130-
CurrentDirectory :
131-
ProcessStartupInformation :
132-
PSComputerName :
109+
System.Management.ManagementBaseObject Create(System.String CommandLine, System.String CurrentDirectory,
110+
System.Management.ManagementObject#Win32_ProcessStartup ProcessStartupInformation)
133111
```
134112

135113
```powershell
136-
Invoke-WmiMethod -Path win32_process -Name create -ArgumentList notepad.exe
114+
Invoke-WmiMethod -Path Win32_Process -Name Create -ArgumentList C:\Windows\system32\notepad.exe
137115
```
138116

139117
```Output
@@ -161,7 +139,12 @@ with an integer (the next process ID number) if the command is completed.
161139
### Example 3: Rename a file
162140

163141
```powershell
164-
Invoke-WmiMethod -Path "CIM_DataFile.Name='C:\scripts\test.txt'" -Name Rename -ArgumentList "C:\scripts\test_bu.txt"
142+
$invokeWmiMethodSplat = @{
143+
Path = "CIM_DataFile.Name='C:\scripts\test.txt'"
144+
Name = 'Rename'
145+
ArgumentList = 'C:\scripts\test_bu.txt'
146+
}
147+
Invoke-WmiMethod @invokeWmiMethodSplat
165148
```
166149

167150
```Output
@@ -188,9 +171,14 @@ The **ReturnValue** property is populated with a `0` if the command is completed
188171
An example using an array of objects `$binSD` followed by a `$null` value.
189172

190173
```powershell
191-
$acl = get-acl test.txt
174+
$acl = Get-Acl test.txt
192175
$binSD = $acl.GetSecurityDescriptorBinaryForm()
193-
Invoke-WmiMethod -class Win32_SecurityDescriptorHelper -Name BinarySDToSDDL -ArgumentList $binSD, $null
176+
$invokeWmiMethodSplat = @{
177+
Class = 'Win32_SecurityDescriptorHelper'
178+
Name = 'BinarySDToSDDL'
179+
ArgumentList = $binSD, $null
180+
}
181+
Invoke-WmiMethod @invokeWmiMethodSplat
194182
```
195183

196184
## PARAMETERS

0 commit comments

Comments
 (0)