none
Getting Deployments for the device with powershell RRS feed

  • Question

  • Is there a cmdlet to find deployments assigned to a device?

    I can check the members of the collection with get-cmcollectionmember.

    But not able to find anything with get-command get-*deployment*

    or get-command get-*device*

    Thank you.

    Wednesday, July 10, 2019 2:08 PM

All replies

  • Hi,

    You can get this information just with right click on the device and click Properties, then go the Deployments Tab.

    You can use also a build-in report to have all packages and application deployed by device collection, see this: https://sccm-zone.com/package-and-application-deployments-reporting-by-collection-with-sccm-64199bbcdc6c

    Regards,

    SAAD Youssef

    ______

    Please remember to mark the replies as answer if they help, thank you!

    Wednesday, July 10, 2019 2:17 PM
  • I know how to get it from the console.

    I am asking if its possible with powershell.

    Thank you.

    Wednesday, July 10, 2019 2:31 PM
  • I am sorry if I am not clear.

    I am looking for a way to see what deployments are assign to a device/client.

    For example hostname has 'windows 10 1903' deployed.

    Is there a way to see it with powershell?

    thank you

    Wednesday, July 10, 2019 3:00 PM
  • I don't think there is anything native. you might need to lookup all the collection memberships then pass that info to get-cmdeployment

    Richard Knight | Collection Refresh Manager | Automate detection rules for patch \ msp files | Twitter

    Wednesday, July 10, 2019 3:32 PM
  • Hello,
     
    Try the following Powershell script. Do not forget to use your own device name and site code.
     
    $DeviceName = "Name"
    $SiteCode ="Code"
    $Collections = (Get-WmiObject -Namespace root/SMS/site_"$SiteCode" -Query "SELECT SMS_Collection.* FROM SMS_FullCollectionMembership, SMS_Collection where name = '$DeviceName' and SMS_FullCollectionMembership.CollectionID = SMS_Collection.CollectionID").Name
    foreach ($Collection in $Collections){
    Get-CMDeployment -CollectionName $Collection | select ApplicationName, @{n="Type"; e={switch ($($_.featuretype)) { 1 {"Application"}; 2 {"Program"}; 3 {"MobileProgram"}; 4 {"Script"}; 5 {"SoftwareUpdate"} 6 {"Baseline"}; 7 {"TaskSequence"}; 8 {"ContentDistribution"}; 9 {"DistributionPointGroup"}; 10 {"DistributionPointHealth"}; 11 {"ConfigurationPolicy"}; 28 {"AbstractConfigurationItem"}}}}}
     
    Hope my answer could help you and look forward to your feedback.
     
    Best Regards,
    Ray

    Please remembers to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Richard.Knight Thursday, July 11, 2019 3:21 PM
    Thursday, July 11, 2019 9:23 AM
  • Hello,
     
    I notice that you have not updated for several days. Has your issue been solved? Or is there any update? Feel free to feedback.
     
    Best Regards,
    Ray

    Please remembers to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, July 15, 2019 12:01 PM
  • The above script doesn't work. Below is the error message

    Get-WmiObject : Invalid parameter 
    At C:\Windows\System32\WindowsPowerShell\v1.0\Test.ps1:3 char:17
    + $Collections = (Get-WmiObject -Namespace root/SMS/site_"$SiteCode" -Query "SELEC ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
        + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    Wednesday, December 4, 2019 12:43 AM
  • Ray's script is good as long as you run the get-wmi-object command on the site server and then the Get-CMDeployment when connected to the CM site / CM module is loaded.
    Wednesday, December 11, 2019 1:50 AM