Lately I have been exploring some of the Powershell 2 CTP3 features. The features that I am studying right now are, Advanced Functions (Very Useful!), WPF & .NET programming via Powershell (The Add-Type CMDlet), and dabbling with the ISE (Integrated Scripting Environment) that comes with Powershell 2.0. Today I have been playing with adding custom menus to the ISE. I wanted to add a custom menu to my powershell profile so when I start up the ISE it will be there by default. The problem is if you add the custom menu entry for the ISE to your powershell profile, it will create an error for the CLI or default version of powershell.
$psISE.CustomMenu.Submenus.Add("Dir", {Dir}, "f7")
I know there's probably hundreds of ways the do this but... I used an if statement to get rid of the error.
[string]$ISE = $psISE
if($ISE -match 'System.Management.Automation') {$psISE.CustomMenu.Submenus.Add("Dir", {Dir}, "f7")}
After adding this to my powershell all I have to do is hit F7 to run a DIR command. User your Imagination, You can probably come up with a better use for this than just a DIR
May The PoSH Be With You
Powershell Jedi
Friday, March 6, 2009
Thursday, February 12, 2009
--
halr9000 over at powershellcommunity.org mentioned that "--" is actually a special keyword that halts parameter processing for a cmdlet. e.g.
get-childitem -recurse -- -foo
This would look for files named "-foo" without throwing an error about there not being a foo parameter.
Source..
May The PoSH Be With You
Powershell Jedi
get-childitem -recurse -- -foo
This would look for files named "-foo" without throwing an error about there not being a foo parameter.
Source..
May The PoSH Be With You
Powershell Jedi
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 [Get-Admin.com] Explaining how to do it.
May The PoSH Be With You
Powershell Jedi
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 [Get-Admin.com] Explaining how to do it.
May The PoSH Be With You
Powershell Jedi
Labels:
convert,
Powershell,
Time,
TimeDate. Ticks
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 (PowershellCommunity.org)'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
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 (PowershellCommunity.org)'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.
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.
Labels:
2.0,
CTP 3,
Powershell,
v2
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$")
Seriously?...
I thought Powershell was supposed to reduce typing
Don't get me wrong I love Powershell as much as the next tech.
Hmm...
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
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$")
Seriously?...
I thought Powershell was supposed to reduce typing
Don't get me wrong I love Powershell as much as the next tech.
Hmm...
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
M.O.M.
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
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
Labels:
2,
Powershell,
Remoting,
Web Services
Subscribe to:
Posts (Atom)