Hi all !
Lets focus on a simple problem, many Service Manager / ITAM customers probably have. A set of discovered computers by AD/SCCM is imported into the ServiceManager CMDB with more or less useful information. On the other hand there is unstructured ITAM data. So what those many people want is:
Create an Asset for every Computer CI in the CMDB !
Even if this is not best ITAM practice, it is a common question/demand, this blog addresses
The solution can be easily done with the ScsmPX Module on GitHub and a little piece of code. In the files available in the download section you will find the Powershell Script, and the Provance Import Template to allow the creation of Assets with Provance DMP.
[codesyntax lang=“powershell“ lines=“normal“ container=“pre“]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# This Script reads SCCM discovered computers from the SCSCM database and creates a csv file with the relevant imprt data for Provance ITAM # Load SCSMPX Commandlets import-module scsmpx # Set Path to store export File $CSVPath = "C:\transfer\SCCMDiscoveredComputers.csv" # Define classes to retrieve data $C_WinCmp = Get-SCClass -Name "Microsoft.windows.Computer" $C_DplCmp = Get-scclass -Name "Microsoft.SystemCenter.ConfigurationManager.DeployedComputer" $C_User = Get-SCCLass -Name "System.Domain.User" $R_CompHasPrimUser = Get-SCRelationship -Name "System.ComputerPrimaryUser" # Get Discovered Computer Data $CmpList = @(Get-SCSMClassInstance -Class $C_WinCmp) # Create empty data array $CompArr = @() # Write DiscoveredHardwareData into Array foreach ($Comp in $CmpList) { # Get Hardware Chassis Object $CompId = $Comp.GetRelatedObjectsWhereTarget($C_DplCmp).EnterpriseManagementObject.Id # Get Deployed Computer Object $DplComp = Get-SCClassInstance -Class $C_DplCmp -Filter "Id -eq $CompId" -ErrorAction Ignore # Get Primary User of the Computer $PrimUser = Get-ScsmPxRelatedObject -Source $Comp -RelationshipClassName $R_CompHasPrimUser # Put Properties together and write them into PSObject Array $data = new-object psobject -Property ( [Ordered]@{ ComputerName =$Comp.PrincipalName; IPAddress =$Comp.IPAddress; LastInventoryDate =$Comp.LastInventoryDate.ToShortDateString() HostServerName =$Comp.HostServerName; IsVirtualMachine =$Comp.IsVirtualMachine; VirtualMachineName =$Comp.VirtualMachineName; SerialNumber =$DplComp.SerialNumber; SMBIOSAssetTag =$DplComp.SMBIOSAssetTag; Manufacturer =$DplComp.Manufacturer; Model =$DplComp.Model; PrimaryUserName =$PrimUser.UserName; PrimaryUserDN =$PrimUser.DisplayName; } ) -ErrorAction SilentlyContinue $CompArr += $data Start-Sleep -Milliseconds 50 } #Create Import CSV File $CompArr | select -property * | export-csv $CSVPath -Encoding UTF8 -NoTypeInformation # Unload Modules Remove-Module scsmpx |
[/codesyntax]
The Import Template uses this CSV and loads the Data as Assets, depending on if its physical Computers or virtual machines. Below find a screenshot of the template:
Finally if you load the data with the Provance DMP you get:
- Physical Hardware Assets + Assigned User
- Hardware Catalog Items for Physical Computers + related Vendor
- Virtual Computer Assets + Assigned Users
- All assets are linked to CI´s
Way to go and start importing/editing financial data for your assets
Update: Sept 2015: Script now uses Powershell v3 PSObject way of creating arrays
Cheers / Roman