PowerShell for Windows Admins

Feb 11 2010   4:07PM GMT

VolumeLabels

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Need to read just the volume labels on a system.  Try this

001
002
003
004
005
006
007
008
009
010
011
012
013
014
function Get-VolumeLabel {
param ([string]$computer=".",
       [string]$drive = $null
)
    if ($drive){
        if ($drive -notlike "?:")
        { Throw "Drive should be submitted as letter and colon e.g. C:"}
        $wmiq = Get-WmiObject -Class Win32_LogicalDisk `
         -Filter "DeviceId=’$($drive)’"  -Computer $computer
    }
    else {$wmiq = Get-WmiObject -Class Win32_LogicalDisk -Computer $computer}
   
    $wmiq | select DeviceId, VolumeName
}

 

Technorati Tags: ,

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: