Audit Objects in your Domain(s) Ready to Switch?

I find it important to figure out who and what is in your active directory OUs

get-aduser $TargetedUser

What about groups, and computers?

get-adobject $targetObject

this includes users, groups, and computers.

here is a switch that will report differently based on object class property that gets returned.

get-adobject -filter *| foreach-object{
Switch($_.Objectclass) {

User{ write-host "Found a User" -foregroundcolor red
      $_ | export-csv Users.csv -notypeinformation -append
     } #end User

Group{ write-host "Found a Group" -foregroundcolor blue
       $_ | export-csv Group.csv -notypeinformation -append
     } #end group

Computer{ write-host "Found a Computer" -foregroundcolor cyan
          $_ | export-csv Computers.csv -notypeinformation -append
     }#end Computer
}#end switch

}#end Foreach-object from pipeline

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.