标签:powershell serial number service tag 服务编号
使用以下PS script可以查询在线PC的服务编号,因为服务编号是出厂就写入BIOS的.以下命令用Domain admin account打开ISE运行.
Get-ADComputer -filter * -searchbase "ou=CN computers,ou=asia computers,ou=yourou,dc=yourdomain,dc=yourdomain" | ForEach-Object { $hostname = $_.name $serialnumber = (Get-WMIObject Win32_BIOS -computer $hostname -ErrorAction SilentlyContinue).SerialNumber if (-not $serialnumber) { Add-Content c:\scripts\offlinehosts.csv "$hostname" Add-Content c:\scripts\offlinehosts.txt "$hostname" } else { Write-Host "$hostname,$serialnumber" # output to screen Add-Content c:\scripts\serialnumberlist.csv "$hostname,$serialnumber" } }
以上命令可以根据指定OU得到在线电脑的服务编号,不在线电脑列表在保存在offlinehosts.txt文本中,
再用以下命令扫描不在线电脑列表.
Get-Content C:\scripts\offlinehosts.txt | ForEach-Object { $serialnumber = (Get-WMIObject Win32_BIOS -computer $_ -ErrorAction SilentlyContinue).SerialNumber Write-Host "$_,$serialnumber" # output to screen Add-Content c:\scripts\serialnumberlistadd.csv "$hostname,$serialnumber" }
标签:powershell serial number service tag 服务编号
原文地址:http://simondu.blog.51cto.com/754321/1572810