I want to use my pc's ServiceTag as output but i need to delete "SerialNumber" text first.
my code:
cls
$tag = wmic bios get serialnumber
$tag
Output:
SerialNumber
JPX9832X31Z
i need JPX9832X31Z as $tag
The easiest solution would be to split the string based on new line and select the 2nd index.
$WMiResult = wmic bios get serialnumber
$tag = ($WMiResult -split "\n")[2]
$tag
Alternatively you can also use Select-Object Cmdlet.
$tag = wmic bios get serialnumber | Select-Object -Index 2
$tag = (get-ciminstance -classname win32_bios).SerialNumberwmic.exe /?on Windows 10, the message appears"WMIC is deprecated."UseGet-CimInstance.(Get-CimInstance -ClassName Win32_BIOS).SerialNumber