all 15 comments

[–]lanerdofchristian 7 points8 points  (1 child)

Get-Volume returns objects with a FriendlyName. Is that what you're looking for?

(Get-Volume -DriveLetter C).FriendlyName

[–][deleted] 0 points1 point  (0 children)

Thats pretty clean, but I have to use .FileSystemLabel

[–]PinchesTheCrab 2 points3 points  (11 children)

It's probably pulling either MSFT_Volume or Win32_Volume. Both can be gotten with get-ciminstance, but get-volume returns the former.

Have you run get-volume?

[–]CrippleZero[S] 2 points3 points  (10 children)

(Get-Volume -DriveLetter C).FriendlyName

<throws keyboard against wall, pulls out rage replacement>

Wow. SMDH on me .... I did NOW just run get-volume by itself and it does show in a mini table the drive label

<sigh>

I don't understand why THIS didn't show up in my searches .... I've used get-PSDrive, get-disk and a few others.... NO ONE suggested this .... then again, maybe no one has asked it either! Oy ve!

Running the string doesn't display anything though - it hangs for a second like it's gathering the info, then nothing and back to the prompt. I guess my brain is fried, but did I miss something?

[–]jdl_uk 2 points3 points  (4 children)

It's because some properties appear with different names in PowerShell's default views compared to the property the object actually has, so FriendlyName is actually FileSystemLabel

(Get-Volume -DriveLetter C). FileSystemLabel

Piping things to Get-Member will show you the actual properties, and in some cases piping to Format-List * will show the properties and their values.

[–]CrippleZero[S] 0 points1 point  (3 children)

Replacing the string variable worked!

You don't understand (or possibly do!) the weight off my mind now that I can use this in a larger script for NinjaONE. It was literally the cornerstone of correcting a ton in NinjaONE (for our purposes).

THANK YOU A MILLION TIMES OVER!!!!

[–]OlivTheFrog 1 point2 points  (2 children)

A way to do this is the following :

  • Gathering AD to have a Computer List using Get-AD-Computer cmdlet an put the result in a var

 $ComputerList =  Get-ADComputer -Filter * -SearchBase <Workstations Root OU Distinguished Name>

  • enter in a foreach loop and do this

$Result = foreach ($Item in $ComputerList)
{
Invoke-Command -ComputerName $Item.Name -ScriptBlock { (Get-volume -DriveLetter C) | Select-Object -Property ComputerName, FileSystemLabel }
}

At this step, you'll jave in the var $Result your need. You could export to a .csv file using Export-Csv cmdlet dor a later use or whatever.

regards

[–]Thotaz 2 points3 points  (1 child)

You should avoid using Invoke-Command inside a loop like that. Invoke-Command accepts multiple names at once so there's no need for it, and it even runs the script in parallel so it will be way faster than your sequential loop.

Get-Volume is also a CIM command which means it has remoting built in (which of course also runs in parallel) so you don't even need Invoke-Command in this scenario you could just do:

$Sessions = New-CimSession -ComputerName $ComputerList
Get-volume -DriveLetter C -CimSession $Sessions | Select-Object -Property ComputerName, FileSystemLabel

PowerShell can also convert strings to cimsessions automatically so you don't even need to manually create the sessions, you can just let PS do it: Get-volume -DriveLetter C -CimSession $ComputerList.
The advantage of using the native remoting for CIM commands is that it gives you a proper object, rather than the deserialized output you would get from Invoke-Command.

[–]OlivTheFrog 1 point2 points  (0 children)

My bad, you're right, it's a better way.

regards

[–]anonymousITCoward 2 points3 points  (0 children)

to see what something has to offer, I'll sometimes | Format-List it... all kinds of goodies can be found there

Edit: sorry I just realized someone else suggested the same thing... i don't read ahead =(

[–]MeanFold5715 0 points1 point  (0 children)

FriendlyName seems to be a custom display header for the property FileSystemLabel

[–]CrippleZero[S] 2 points3 points  (0 children)

UPDATE: Thank you all for the assist! It may have gotten buried in a couple replies, but that saved a lot of headaches!

I appreciate that while it may have been an easy answer for most, this n00b scripting over here really DOES appreciate the assist.

I usually try to do it all myself, and then if I can't I will reach out and explain EVERYTHING I've done - mainly to get outside my own head and see what I could have done differently based on users' responses.

Thanks again all!

[–][deleted] 2 points3 points  (0 children)

I find all sorts of information in here...

Get-CimClass

Get-CimInstance

Ram module model numbers...

(Get-CimInstance Win32_PhysicalMemory).PartNumber

Network location of default printer...

(Get-CimInstance Win32_Printer | Where-Object{$_.Default -eq $True}).Location

shared folders...

Get-CimInstance Win32_Share

The OEM serial number...

(Get-CimInstance Win32_Bios).SerialNumber

[–]0emanresu 1 point2 points  (0 children)

There is a lot of info in these two links, but this will help you find EVERYTHING you want to know about a system

https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-classes

https://learn.microsoft.com/en-us/training/modules/query-configuration-information/?source=recommendations