Using Object properties

A lot of people see PowerShell as conversion tool, but it can do so much more.

It can uninstall apps, inventory your applications. Rename files to a standard. Create shares, modify files and sessions and give an Administrator access to a computer without interrupting a session.

It is built on .net/c# so it can do everything a program can. You just have to know your property and methods on your objects.

I am mainly speaking about windows platform. I may do a write up on Linux impact.

I can write excel, word files with out office being installed, send emails and query websites for remote data. Consolidated information and write to databases. The list is ridiculous.

I wanted to interact more so I would like to take on a challenge from the comments. What is something you think you cannot do in PowerShell?!

Scripting Technique, Uncategorized

Audit Objects in your Domain(s) using switch statements in PowerShell

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
Scripting Technique, Uncategorized

Add-Member if you want to effectively “object” all things and possess their property.

I thought I would clarify this as most articles don’t simplify this to easily wrap you head around.

Add-member is what I would use to add a new member to a group of properties on an object

  1. I create the object
  2.  Add a noteproperty that translate to text
  3. create a scriptmethod that can do things based on a scriptblock when called.
  4. create a scriptproperty that runs each time you call the $x object to display the results of it’s script block.
Here is the code:
$x=new-object psobject
$x| add-member -name ID – value “smithx” -membertype Noteproperty
$x| add-member -name ADlookup -value { get-aduser $x.name } -membertype scriptmethod
$x|add–member -name ADinfo -value {$x.adlookup()} -membertype Scriptproperty

if you want you can overwrite a member with the -force command.