Friday, December 19, 2008

Tick Tock DOC!

I recently found myself in a situation where I had deal with Ticks in Powershell.

What's a tick? you ask.

A tick is the core time measurement in Powershell and .NET, I think...

[System.Datetime] - Core time measurement is a tick.
a tick is 100 nanoseconds.
There are 10000000 ticks in a second.

I was going to try to explain how to convert ticks into seconds but I found a post doing just that. So for sake of not reinventing the wheel, here is the [Link] to the Blog [] Explaining how to do it.

May The PoSH Be With You
Powershell Jedi

Tuesday, December 16, 2008

Finding Powershell information on the Internet

Over the Past few months is have evolved into a Powershell junkie.

This is how I find information about Powershell on the Internet.

1.) Google News Alerts - I create several news alerts for phrases like "Powershell", "Powershell WMI", Powershell Snover, Powershell 2.0 2 CTP3 -CTP2 -Beta -2008 (the minus subtracts the following phrase from the search results). Next, I create a folder called "News Alerts - Powershell" in my email client of choice "Yahoo" and a filter that auto sorts all emails containing the word "Powershell" in the subject line into it. Any Time anything is posted any where on the web and is searched by google will be sent directly to me :)

2.) Delicious: I keep a list of interesting Powershell links on Delicious. I'm sure your familiar with Delicious it's very easy to see what other people interested in Powershell have book marked. I often peek at halr9000 from ('s Bookmarks.

3.) Powshell Toolbar This Toolbar has links to all of the Major Powershell Blogs, Sites and Online Resources.

Ok, Now that I found all this Information on Powershell my only problem is sifting through it all.

May The PoSH Be With You
Powershell Jedi

Monday, December 15, 2008

PSSession = Runspace

In Powershell v2 CTP3 which is due any day now all CMDlets ending in the word -Runspace have been renamed to -PSSession.

I think this is good to remember because the powershell development team has stated repeatedly that you will be able to provide users customised or scaled down Runspaces. In a scaled down Runspace users only have access to the CMDlet provided by the administrator.

Wednesday, December 10, 2008

Missing CMD function in Powershell

As a network admin I type c:\>start \\RemoteMachine\c$
at the command prompt about 100 times a day.

I like using it because it keeps the run line on my servers and management box clean, call me nitpicky.

But Powershell doesn't have this basic command, and It annoys me to no end.
For me to be able to go 100% PoSH. I would need that command.

lets say...

Start-Location -path \\RemoteMachine\c$
or written with an alias
Start \\RemoteMachine\c$

Ok so I know you do this...

(new-object -comObject Shell.Application).open("\\RemoteMachine\c$")


I thought Powershell was supposed to reduce typing

Don't get me wrong I love Powershell as much as the next tech.


I wonder it I can use Script CMDlets to turn that into a CMDlet

Just Rambling I guess,

May The PoSH Be With You,
Powershell Jedi

Tuesday, December 9, 2008


Great, another overlapping acronym, “M.O.M.”... No not "Microsoft Operations Manager". As you can see I've been Powershell 2.0 Remoting crazy today. And in Powershell 2.0 you will undoubtedly come across the M.O.M. acronym in a vague theory sort of way akin to how the O.S.I. model relates to the day to day tasks of an Network Admin.

Ok so what is M.O.M. you ask?

Mobile Object Model: Jeffry Snover describes the Mobile Object Model in this way "Islands of optimization in a sea of interoperability."

Let’s say your managing a Exchange 12 box remotely. Exchange isn't installed on your remote machine. So there’s no way for your machine to understand the exchange code.

When you are remoting using in Powershell 2.0 objects are serialized then returned to you as XML over the wire. Because the methods of the remote objects are code which didn’t come across the wire you cannot use the methods of the objects while remoting.

Coded based applications like Exchange = Islands of optimization
The serialized XML data = The Sea of interoperability

Ok, that it for a while.

May the PoSH Be with you,
Powershell Jedi

Who needs SMS!!

Install an .MSI package via WMI

(Get-WMIObject -ComputerName $TargetSys -list | Where-Object -FilterScript {$_.Name -eq "Win32_Product"}).PSBase.InvokeMethod("Install","\\AppSrv\dsp\NewPackage.msi")

May the PoSH Be with you,
Powershell Jedi

Finding Remotable CMDlets

Find all remotable Powershell CMDlets in any Session

Get-Help * -Parameter ComputerName

May the PoSH Be with you,
Powershell Jedi

Powershell 2.0 Remoting

Lately I've been spending more time with Powershell Version 2. Mainly because The next release of Powershell 2.0 Will be released within the December 08/January09 Time Frame. It will be called CTP3 (Community Technology Preview 3) or Beta. The main thrust of version 2 of Powershell is Remoting. During my Studies I found it very confusing when because a bunch of terms where thrown around.

Terms like WinRM, WSMan, WMI. Here’s the annoying part, their all related to remoting yet no one explained the relationship between them. Not until I found a video by the Creator of Powershell Jeffery Snover who mentioned in response to a question reguarding the relation between WinRM and WSMan (WSManagement). So here it is, Short and Sweet.

WinRM is Microsoft’s Implementation of WSMan

So their basicaly the same thing!!

Moving Forward, Microsoft Remoting Technology will be all based around the WSMan protocol

WMI (Windows Management Instrumentation) is an older technology that has been built into windows for a while. The Get-WmiObject CMDlet is how you do remoting in Powershell Version 1.0. The Problem with WMI is it uses DCOM (Distributited COM) which is blocked by most firewalls You can get at the WMI info of a system over a firewall using WinRM because it uses port 80, http or https based and uses the SOAP protocol hence the WS in WSMan. The WS stands for Web Services. As I said before "Web Services Management" (WSMan) is an industry wide standard regulated by the DTMF. It is intended to manage computers, switch, raw hardware basicly everything "in the near future".

Until Next Time...

May the PoSH Be with you,
Powershell Jedi

Monday, December 8, 2008

Hello world...

This is my first blog ever; it's dedicated to hard to find facts and explanation regarding Powershell.

I began learning Powershell basically as a complete scripting newbie, I have cut and pasted and manipulated a few VB scripts before beginning Powershell but nothing big otherwise. I am beginning this blog because over the course of my studies I have come across a few sticking points. This Blog will serves as a place holder for interesting and non-apparent facts about Powershell that I come across during my journey to becoming a Powershell Jedi Master :). As it stands for now most posts will be short micro-blog style. The intent of this Blog is to help others along they’re learning path with some of the more unapparent facts and sometime irrelevant yet fun facts regarding Powershell. As such, the skill level of my posts will probably be all over the board.

A little about me: I am a Network Engineer in the Atlanta Georgia Area with 10 Years of Windows Networking Experience. I Passed the MCSE at the ripe old age of 23 in 1999 placing myself in the category of youngest MCSE’s (5% of all MCSE where under 25 at the time, I think, Anyway…).

This will probably be my longest post as I prefer to spend my free time With Friends, Family, or Playing GoW2 on XBL. So without further a due here are a few facts you might not have known about Powershell.

Before I begin with my Obscure tips I must mention the Basics. Powershell is an Object oriented Scripting Language… actually this CAN be my first obscure tidbit. More Precisely Powershell is an automation technology that gets “surfaced” a scripting Language & Shell.

Let’s Say we have an Object of CAR,
A car has parts like Door, in Powershell "Door" would be a property of CAR. The way you use the car like speed, crash or PimpOut would be its methods. Detailed info regarding objects is beyond the scope of this blog (I’m just being lazy, plus Hero’s comes on in 15 min.. yes, I have a DVR, ok I’m just lazy!!)

Anyway, let’s say there is a CMDlet (Pronounced “Command let”) called Get-Car
Putting CMDLets in parenthesis () is the same as assigning them to a Variable

$Car = Get-Car

is the same as


One small benefit of assigning Get-Car to a variable would be that you get "Tab Expansion" on the Properties of Get -Car
Which brings me to my next tidbit

Tab Expansion TidBits
4 Places to use Tab Expansion
(Hitting tab to auto complete a line is called Tab Expansion)

1.) After a variable with a dot
$Date = Get-Date
$Date.[tab expansion]

2.) After a dash in a CMDlet
Get-[tab expansion]

3.) After the Parameter dash
Get-Help -[tab expansion]

4.) If you hit tab when there nothing in front of the prompt Tab Expansion will cycle thru the Child Items or the contents of the current folder and will look like this .\whatever

Bonus Tip: Shift+Tab Cycles thru Tab Expansion Backwards

The Snapin PowerTab ( expands the tab expansion function of Powershell to make it act more like Visual Studio IntelliSence

That’s all for now. I hope I made sense please let me know if my examples we’re to simple to complex or Just right.

Until Next Time...

May the PoSH Be with you,
Powershell Jedi