$SCCMserver = SCCMServer01 $namespace = "root\sms\site_xx1" $adminname = "Domain\AdmUser" $password = get-content .\adminpassword.txt|convertto-securestring -key (1..16) $admcred = new-object system.management.automation.pscredential($adminname,$password) $i = 0 $OldComputerSoftware = Get-WmiObject -Namespace $namespace -Class SMS_fullcollectionmembership -ComputerName $SCCMServer -filter "Name = '$SCCMoldcomputer'" -credential $admcred $OldComputerCollectionMemberList = $CollectionList|? {$OldComputerSoftware.collectionID -contains $_.collectionID}
Above I declare my variables, query the SCCM server for all the software on the old computer, and compare it to the $CollectionList collections filtering array. Next I create $NewPCSoftwareList using the old computer software list. Add line numbers and filter unwanted collections via $XList. The $AddedSoftware variable displays the existing software from the old computer and will be updated with software selections in the read-host menu below:
$NewPCSoftwareList = $OldComputerCollectionMemberList|select Name,CollectionID foreach ($C in $NewPCSoftwareList){$i++;$C|add-member -notepropertyname line -notepropertyvalue $i} $NewPCSoftwareList = $NewPCSoftwareList|? {$xlist.name -notcontains $_.name} $addedsoftware = $collectionlist|? {$NewPCSoftwareList.name -contains $_.name}
Available SCCM Software Packages
1 Adobe Acrobat Pro 2 Adobe Acrobat Standard 3 Base Camp 5 Topography Software 6 Google Earth Pro 7 Windows Mobile Device Center OldComputerName SCCM Software will be installed on NewComputerName 4 7-Zip 8 Microsoft Office 2013 Enter line number to add SCCM software to NewComputerName Enter DONE if satisfied with install list (Line number or Done): _
do{ cls write-host "Available SCCM Software Packages" -f white $collectionlist|? {$InstalledSoftwareList.name -notcontains $_.name}|format-table line,name write-host "SCCM Software already installed on $computername" -f white $InstalledSoftwareList|format-table line,name -hidetableheaders if ($newsoftware){ write-host "Software to be added" -f yellow $newsoftware|format-table line,name -hidetableheaders } write-host "Enter " -nonewline;write-host "line number" -f white -nonewline;write-host " to add SCCM software to $computername" write-host "Enter " -nonewline;write-host "DONE" -f white -nonewline;write-host " if satisfied with install list" $addpackages = read-host "(Line number or Done)" if ($addpackages -ne "done"){ $newsoftware += $collectionlist|? line -eq $addpackages } } while ($addpackages -ne "done")
if ($addedsoftware){$addedsoftware|export-csv .\NewComputerName-SCCMsoftware.csv}
No comments:
Post a Comment