Weekly Tip 57

PowerShell Script to Get Whether Deployments are Device or User-Based

Here’s a PowerShell script that will pull whether deployments are device based or user based. Insert your a location to save a CSV file, your primary site server name, and site code at the top.

$csv = <path to CSV file>

$siteServer = <site server name>

$siteCode = <site code>

$deployments = get-wmiobject -computername $siteServer -namespace root\sms\site_$siteCode -class SMS_DeploymentInfo

$collections = get-wmiobject -computername $siteServer -namespace root\sms\site_$siteCode -class SMS_Collection

add-content $csv “DeploymentName,CollectionID,CollectionType,CollectionName”

ForEach ($deployment in $deployments) {

$deploymentName = $deployment.DeploymentName

$collID = $deployment.CollectionID

$collName = $deployment.CollectionName

$collectionType = ($collections | where-object -filterscript {$_.CollectionID -eq $collID}).CollectionType

If ($collectionType -eq “0”) {$f_collectiontype = “Other”}

If ($collectionType -eq “1”) {$f_collectiontype = “User”}

If ($collectionType -eq “2”) {$f_collectiontype = “Device”}

add-content $csv “$deploymentname,$collID,$f_collectionType,$collName”

}

Share:

Facebook
Twitter
LinkedIn
Picture of Matt Tinney

Matt Tinney

Professional IT executive & business leader having decades of experience with Microsoft technologies delivering modern-day cloud & security solutions.

Contact Us

=
On Key

More Posts

Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=