使用如下PS script能夠查詢在線PC的服務編號,由於服務編號是出廠就寫入BIOS的.如下命令用Domain admin account打開ISE運行.dom
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文本中,ide
再用如下命令掃描不在線電腦列表.ip
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" }