Monday, May 7, 2012

Powershell: Get service tag or serial number

In case a machine name gets changed accidentally or perhaps your users have admin rights and decide to rename their computer the below powershell script will return you the true serial number or service tag. This is also useful in case the physical sticker or tag on the laptop or desktop has been rubbed off or is illegible.



If you are running the script locally open PowerShell from your start menu and type:


Get-WmiObject win32_SystemEnclosure | select serialnumber 


and to shorten it:


gwmi win32_SystemEnclosure | select serialnumber


If you are running the script remotely:


gwmi win32_systemenclosure –computername remotesystemname | select serialnumber

I'm sure some world class Enterprise System Admins will scoff at such a silly script but sometimes simple is best when you need to get one piece of information quickly.
As with most remote scripts be sure you are an administrator on the remote or local system before attempting or you may not get any results.

No comments:

Post a Comment