PowerShell Notes

Been doing some projects in PowerShell lately and have found tons of great info available online to learn from. I was reading some old blogs and came across this link that talks about how to include help info in your PS functions:

This sample is from Media and MicroCode:

#.Synopsis
#      Turns a Hashtable into a PowerShell object
#.Description
#      Creates a new object from a hashtable.
#.Example
#      # Creates a new object with a property foo and the value bar
#      Get-HashtableAsObject @{"Foo"="Bar"}
#.Example
#      # Creates a new object with a property Random and a value
#      # that is generated each time the property is retreived
#      Get-HashtableAsObject @{"Random" = { Get-Random }}
#.Example
#      # Creates a new object from a hashtable with nested hashtables
#      Get-HashtableAsObject @{"Foo" = @{"Random" = {Get-Random}}}  

Another cool short PS script I read was doing a lookup on an IP address to find the location. This was posted on the Get-PowerShell blog and shows a really short script to find out the public IP address of the system being run and then do a lookup to find the georgraphical area it is located in.

Advertisements
Explore posts in the same categories: PowerShell, Tech

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s


%d bloggers like this: