Saved for later reference

online repository of stuff I had to google for hours to figure out – and random snippets of code

Active Directory user GUID

Tags: , , , , , ,

I found this page which contains an old oneliner to get a user GUID in PowerShell – but sadly it doesn’t work anymore.

After some tricking around, I found the following to work:

(new-object Guid(,(([directoryservices.directorysearcher] "(samaccountname=theuser)").findall())[0].properties["objectguid"][0])).ToString()

© 2009 Saved for later reference. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.