Get users with no primary device in SCCM

After a SCCM client agent implementation, it could be useful to see if there is any user, without any Primary User device.
This information could indicate if there is any computers in your domain, where the installation has been unsuccessful.

The devices that possibly hasn’t got the installation through Client Push, could be caught by using this setup. Another option would be to call the user to investigate further and install the client manually.

This code requires the Configuration Manager module.

Please leave a comment below. Any suggestions are welcome.

<#

    .SYNOPSIS
   
    .DESCRIPTION

    .PARAMETER

    .EXAMPLE

    .NOTES
    Author: Morten Rnborg
    Date: 10-09-2018
    Last Updated: 03-02-2019
    https://mroenborg.com
#>

################################################

#All users in SCCM
 $AllUsers = (Get-CMUser).SMSID

#Remove all chars(domain name) before the \ with .*\\ leaving the username
 $AllUsers = $AllUsers -replace ".*\\"

#Get all devices with there primary user
 $AllDevices = Get-CMDevice | Select-Object Username,Name

#Get all users with no PC object assigned
 $UsersWithNoPC = $AllUsers | Where-Object {$_ -notin $AllDevices.Username}

2 thoughts on “Get users with no primary device in SCCM”

    • Hi Gareth,

      Did you run it on the server or locally?
      Do any of the variables contain any data after execution?
      /Morten

      Reply

Leave a comment