2,187
edits
m (→ConvertTo-SecureString: Added WMI command to example) |
m (→WMI: Revised WMI examples etc) |
||
Line 144: | Line 144: | ||
== WMI == | == WMI == | ||
Cmdlet for using WMI via PowerShell is '''Get-WMIObject | Cmdlet for using WMI via PowerShell is '''Get-WMIObject''', for example... | ||
<source lang="powershell"> | <source lang="powershell"> | ||
Line 155: | Line 155: | ||
SerialNumber : 76487-OEM-0011903-00102 | SerialNumber : 76487-OEM-0011903-00102 | ||
Version : 5.1.2600 | Version : 5.1.2600 | ||
</source> | |||
Further useful examples... | |||
<source lang="powershell"> | |||
# Get OS CPU info (address width, speed, FSB etc | |||
$cpu = Get-WMIObject -query "SELECT * FROM Win32_Processor WHERE DeviceID='CPU0'" -credential $cred -computer $svr | |||
# Get local disks | |||
$drives = Get-WMIObject Win32_LogicalDisk -filter "Description = 'Local Fixed Disk'" -credential $cred -computer $svr | |||
</source> | </source> | ||
Line 206: | Line 174: | ||
</source> | </source> | ||
To then see all the properties of a class use (doesn't work on remote machines (access denied) - | To then see all the properties of a class use (if this doesn't work on remote machines (access denied) - it may be due to a known bug in Power Shell v1 whereby <code>Get-WMIObject</code> can't impersonate (or you may just have the wrong credentials)... | ||
<source lang="powershell"> | <source lang="powershell"> | ||
Get-WMIObject Win32_BIOS | Format-List * | Get-WMIObject Win32_BIOS | Format-List * |