Home All Groups Group Topic Archive Search About

powershell storage management

Author
31 Dec 2008 3:02 PM
IT
I need to filter out the shared drives in this script located below.  The
drive letters are Z,M,N,D,G.  This is the code I'm currently using to display
information about my servers.




$strComputer = "servername"

$colItems = get-wmiobject -class "Win32_LogicalDisk" -namespace "root\CIMV2" `
-computername $strComputer

foreach ($objItem in $colItems) {
      write-host "Caption: " $objItem.Caption
      write-host "Compressed: " $objItem.Compressed
      write-host "Description: " $objItem.Description
      write-host "Device ID: " $objItem.DeviceID
      write-host "File System: " $objItem.FileSystem
      write-host "Free Space: " $objItem.FreeSpace
      write-host "Name: " $objItem.Name
      write-host "Provider Name: " $objItem.ProviderName
      write-host "Size: " $objItem.Size
      write-host "System Name: " $objItem.SystemName
      write-host "Volume Name: " $objItem.VolumeName
      write-host


}

Author
3 Jan 2009 4:32 PM
OldDog
On Dec 31 2008, 9:02 am, IT <IT @discussions.microsoft.com> wrote:
Show quoteHide quote
> I need to filter out the shared drives in this script located below.  The
> drive letters are Z,M,N,D,G.  This is the code I'm currently using to display
> information about my servers.
>
> $strComputer = "servername"
>
> $colItems = get-wmiobject -class "Win32_LogicalDisk" -namespace "root\CIMV2" `
> -computername $strComputer
>
> foreach ($objItem in $colItems) {
>       write-host "Caption: " $objItem.Caption
>       write-host "Compressed: " $objItem.Compressed
>       write-host "Description: " $objItem.Description
>       write-host "Device ID: " $objItem.DeviceID
>       write-host "File System: " $objItem.FileSystem
>       write-host "Free Space: " $objItem.FreeSpace
>       write-host "Name: " $objItem.Name
>       write-host "Provider Name: " $objItem.ProviderName
>       write-host "Size: " $objItem.Size
>       write-host "System Name: " $objItem.SystemName
>       write-host "Volume Name: " $objItem.VolumeName
>       write-host
>
> }

If you only want the physical drives on your server, then -filter
DriveType=3
Author
6 Jan 2009 8:39 PM
BJ
On 31 Dez. 2008, 16:02, IT <IT @discussions.microsoft.com> wrote:
Show quoteHide quote
> I need to filter out the shared drives in this script located below.  The
> drive letters are Z,M,N,D,G.  This is the code I'm currently using to display
> information about my servers.
>
> $strComputer = "servername"
>
> $colItems = get-wmiobject -class "Win32_LogicalDisk" -namespace "root\CIMV2" `
> -computername $strComputer
>
> foreach ($objItem in $colItems) {
>       write-host "Caption: " $objItem.Caption
>       write-host "Compressed: " $objItem.Compressed
>       write-host "Description: " $objItem.Description
>       write-host "Device ID: " $objItem.DeviceID
>       write-host "File System: " $objItem.FileSystem
>       write-host "Free Space: " $objItem.FreeSpace
>       write-host "Name: " $objItem.Name
>       write-host "Provider Name: " $objItem.ProviderName
>       write-host "Size: " $objItem.Size
>       write-host "System Name: " $objItem.SystemName
>       write-host "Volume Name: " $objItem.VolumeName
>       write-host
>
>
>
> }- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Hi IT,
pipe the WMI to the folowing Filter:

? {$_.DeviceID -notmatch "[Z|M|N|D|G]"}

Complete line of Code:

$colItems = get-wmiobject -class "Win32_LogicalDisk" -namespace "root
\CIMV2" -computername $strComputer |  ? {$_.DeviceID -notmatch "[Z|M|N|
D|G]"}

So all Drives wich NOT match are assigned to $colItems