PowerShell - Get Computers by Last Logged on User via SCCM

2012, Jan 28    

I needed a versatile script to query SCCM and return the list of computers associated with that user.  This is my solution to that.  It simply queries SCCM for the list of computer’s whose last logged on user matches the supplied SamAccountName.  I’ve populated the PowerShell Comment Doc, so check out the Examples supplied in there for usage.

Hope it helps others out there.  Just add the function to your PowerShell Profile or as a Functions in a script to make it available!

In case you’re wondering what the reference is to the $_ProgressTotal variable … I that’s a Global Variable that I set when piping large sets into this funtion.  I’ve got an example of it being used in my Get-ActiveCompByDept function.

Thanks to Jeffrey B. Murphy (sourced) for the starting point.