Hi All !
Recently i had the situation, where there was no SCCM Agent in an environement for specific
reasons, but the customer wanted to use this data to fill up his SCSM Database (Provance Assets in that case). So we had more ore less empty CI´s in the SCSM Database and wanted to fill this up with directly scanned WMI Data.
The result should have a format to be directly used by an SCSM Import Tool.
The Powershell Script queries all Virtual machines in the SCSM Database and gets information from online machines via WMI. This data is then written to a CSV File. Use and have fun.
# Script to query Online Virtual Machines based on SCSM Data to get Serial Numbersimport-module smlets
$Computers = Get-SCSMCLass Microsoft.windows.Computer$
$VMList = @(Get-SCSMObject $Computers -Filter „IsVirtualMachine -eq ‚true'“)
$Arr = @()
foreach ($VM in $VMList)
{
$data = new-object psobject # New Object
$data | add-member -membertype NoteProperty -Name ComputerName -Value $VM.NetBiosComputerName
$data | add-Member -membertype NoteProperty -Name SerialNumber -Value (Get-WMIObject -Class „Win32_BIOS“ -Computername $VM.NetBiosComputerName).SerialNumber
$data | add-Member -membertype NoteProperty -Name OSName -Value (Get-WMIObject -Class „Win32_OperatingSystem“ -Computername $VM.NetBiosComputerName).Caption
$data | add-Member -membertype NoteProperty -Name Manufacturer -Value (Get-WMIObject -Class „Win32_ComputerSystem“ -Computername $VM.NetBiosComputerName).Manufacturer
$data | add-Member -membertype NoteProperty -Name Model -Value (Get-WMIObject -Class „Win32_ComputerSystem“ -Computername $VM.NetBiosComputerName).Model
$Arr += $data
}
$arr | select -property ComputerName,SerialNumber,OSName,Manufacturer,Model | export-csv -notypeinformation .\Documents\VMSerials.csv
Remove-Module Smlets
The result is a CSV file like this.
„ComputerName“,“SerialNumber“,“OSName“,“Manufacturer“,“Model“„Server1″,“1111-1111-1111-5431-2407-9700-21″,“Microsoft Windows Server 2012 R2 Standard“,“Microsoft Corporation“,“Virtual Machine“
„Server2″,“2222-2222-2222-7060-4845-5504-27″,“Microsoft Windows Server 2012 R2 Standard“,“Microsoft Corporation“,“Virtual Machine“
„Serern“,“3333-3333-3333-9977-7669-1954-03″,“Microsoft Windows Server 2012 R2 Standard“,“Microsoft Corporation“,“Virtual Machine“
Regards / Roman