Several improvements to Get-WMIObject cmdlet in Windows PowerShell
Several improvements to Get-WMIObject cmdlet:
- WMI methods are exposed as part of the WMI Windows PowerShell adapter.
- A new parameter set was added to Get-WmiObject that includes a Query parameter that takes WQL queries.
- Added [WMI] as an intrinsic type that takes a string (such as a WMI PATH).
– You can now instantiate a WMI instance as follows:
PS >[WMI]'\\JPSLAP04\root\cimv2:Win32_Process.Handle="0"'
This would be the same as:
PS >new-object system.management.managementobject '\\JPSLAP04\root\cimv2:Win32_Process.Handle="0"'
- Designed a new way to deal with CIMDATETIMES that are STRINGS. This was implemented by having a SCRIPT method for System.Management.ManagementObject that does a ConvertToDateTime() and a ConvertFromDateTime().
Example:
PS >$wmiclass = [wmiclass]"win32_processstartup"
PS >$dmtfDate = "20020408141835.999999-420"
PS >$dateTime = $wmiclass.ConvertToDateTime($dmtfDate)
PS >$result = $wmiclass.ConvertFromDateTime($dateTime)
No security warnings when you first start the shell:
Users are no longer prompted to trust the Microsoft signing certificate the first time that they start Windows PowerShell. The PS1XML files that are included in Windows PowerShell are signed and trusted even when the Windows PowerShell execution policy is set to "Restricted."
Miscellaneous changes:
- $host.version now reports the actual host version 1.0.0.0, not the assembly version.
- A Force parameter was added to the ConvertTo-SecureString cmdlet.
- Tab completion now works on property references:
PS >$a = get-process outlook
PS >$a.Mai<tab> => $a.MainModule then $a.MainModule.fi<tab> => $a.MainModule.FileName
- Default attributes can now be used to resolve ambiguous parameter sets. For example, if a cmdlet has two parameter sets, and the command that is entered could be resolved by using either of the parameter sets, the default parameter set is used. Before this change, the command would generate a "cannot resolve parameterset" error.
Posted in: Windows| Tags: Windows PowerShell PowerShell Windows processstartup CIMDATETIMES ConvertToDateTime Win32_Process.Handle Get-WMIObject Miscellaneous