PowerShell – Get Computers by Last Logged on User via SCCM

VertigoRay/ January 28, 2012/ Uncategorized/ 0 comments

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.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*