February 2019
Intermediate to advanced
626 pages
15h 51m
English
The following snippet creates a directory and shares that directory:
$path = 'C:\Temp\WmiPermissions' New-Item $path -ItemType Directory$params = @{ ClassName = 'Win32_Share' MethodName = 'Create' Arguments = @{ Name = 'WmiPerms' Path = $path Type = [UInt32]0 }}Invoke-CimMethod @params
The Create method used here will fail if the argument for Type is not correctly defined as a UInt32 value. PowerShell will otherwise use Int32 for a value of 0.
The requirement for UInt32, in this case, may be viewed by exploring the parameters required for the method:
PS> (Get-CimClass Win32_Share).CimClassMethods['Create'].Parameters | Where-Object Name -eq TypeName CimType Qualifiers ReferenceClassName---- ------- ---------- ...
Read now
Unlock full access