Tuesday, April 22, 2014

Whoami? Waiting for AD Replication?

Added myself to a group using FIM, now I have to wait for the sync to complete, then the replication to complete.  Being the impatient person I am, thought I’d share the one-liner I used to pass the time.

 

& whoami /groups | Where-Object {$_ -like '*group name*'}

 

The above takes advantage of a cmd.exe utility that has some very handy switches.

The output is below, slightly abbreviated.  Each line of the output gets fed into the PowerShell pipeline, so I just do a string comparison using the –like operator.  If the group shows up in the output then I am logged in as a member of that group.

 

REDMIND\Hockey Players                                      Group           

REDMIND\Mountain Bikers                                 Group           

REDMIND\Slackers                                   Group           

 

 

2 comments:

Paul said...

Nice. Feature request. :)

The output is a delimited line. How to break that into an object and expose each delimited section as a property, so that I can not bother messing my screen with the description, e.g.

whoami /groups |? { $_.Name -like 'FIM*' } | ft Name,Sid

blog said...

Nice! QQ (feature request)

How to break each line (which contains multiple pieces of info. delimited by a tab or something similar) into properties of an object that is the line?

This way we can elect not to mess up the screen with the description, e.g. if it's an object I can...

whoami /groups | ? { $_.Name -like 'FIM*' } | ft Name,SID