Link to home
Start Free TrialLog in
Avatar of Domenic DiPasquale
Domenic DiPasqualeFlag for United States of America

asked on

Powershell: Obtain serial number from device, output filtering.

I'm working on a PS script that will allow me to obtain the serial number from our workstations (Dell service tag for example.) and store it in a variable. I can obtain this by running the command: Get-WmiObject win32_SystemEnclosure | select serialnumber

I get the following results (X being the Dell Service Tag):
serialnumber
------------
XXXXXXX


I would like to remove the first two lines (serialnumber and ----------------) from the output and have only the service tag display. From there, when I request the string stored in the variable, it will only show the service tag.
PS>$test

XXXXXXX

PS>

Any ideas? Thank you for your time.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

Alternatively, you can just address the required property directly:
$test = (Get-WmiObject Win32_SystemEnclosure).SerialNumber

Open in new window

Avatar of Domenic DiPasquale

ASKER

Easy A footech! Thank you very much.