Databases Reference
In-Depth Information
USING POWERSHELL TO INVESTIGATE SERVER ISSUES
PowerShell provides full integration with the Windows Management Instrumentation (WMI)
framework, The WMI framework is a very powerful method for querying the Windows system to
i nd detailed information. Traditionally, it has not been easy to gain access to WMI, and this was
mainly done via a programming interface. PowerShell opens up access to WMI making it a useful
resource for your troubleshooting efforts.
Interrogating Disk Space Utilization
In this example, you are going to see how to make use of one of the WMI win32-logicaldisk
classes to retrieve information about disk space utilization on the server. Initially, the raw informa-
tion provided by the class will be returned and then the data will be used to produce a detailed
analysis of disk space available:
Get-wmiobject win32_logicaldisk
Running the Get-WmiObject cmdlet and providing the win32_logicaldisk class returns the fol-
lowing results on my computer:
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 105582891008
Size : 128742060032
VolumeName :
DeviceID : D:
DriveType : 5
ProviderName :
FreeSpace : 0
Size : 45471744
VolumeName : VBOXADDITIONS_4.
The default list view of the results is not very readable for this output, but you can improve it by for-
matting the output as a table:
Get-wmiobject win32-logicaldisk | format-table -autosize
On my computer this statement produces the following output:
DeviceID DriveType ProviderName FreeSpace Size VolumeName
-------- --------- ------------ --------- ---- ----------
C: 3 105582891008 128742060032
D: 5 0 45471744 VBOXADDITIONS_4.
You may want to i lter this information so that you are only displaying i xed disks. This can be
achieved by using a Filter parameter to i lter the disks returned to be i xed disks only:
Get-WmiObject Win32_logicaldisk -Filter "DriveType = 3" | Format-Table -autosize
 
Search WWH ::




Custom Search