Showing archive results for April 2006

Apr 25, 2006
Post comments count0
Post likes count0

Verb-Noun vs Noun-Verb

PowerShell Team

Kurt asked the question "why not Noun-Verb vs Verb-Noun" in his post: http://blogs.msdn.com/monad/archive/2006/02/16/533522.aspx#574708 There are lots of answers to this some better than others.  Let me rattle off a couple of them: Jeffrey P. SnoverMonad Architect [Edit: Monad has now been renamed to Windows PowerShell. This script or discus...

FAQ
Apr 25, 2006
Post comments count0
Post likes count0

Is it safe to use ALIASES in scripts?

PowerShell Team

In our newsgroup (Microsoft.Public.Windows.Server.Scripting) , Mark Ayers asked the question:> Shouldn't best practice for scripts be full command name? The answer is YES, NO, and MAYBE. YES - Full names provide the most readable experience for scripts.  This is very important.  People often throw the rock at Perl saying that...

FAQ
Apr 25, 2006
Post comments count0
Post likes count0

Working with Sort-Object Cmdlet

PowerShell Team

In this blog I will try to explain different features of sort-object(Sort) cmdlet. For the purpose of this blog, I assume the following objects exist:   MSH C:\temp\monad> $a,$b,$c,$d                            &...

FAQCMDLET:UTILITY
Apr 25, 2006
Post comments count1
Post likes count0

How does Select-String work with Pipelines of objects?

PowerShell Team

<Edited to convert Match-String to Select-String 7/9/2006> In our newsgroup (Microsoft.Public.Windows.Server.Scripting) , Vasu asked about how Select-string works in pipelines: Here is what I observe:1. MSH C:\> get-alias ..truncated..Alias           ri    &nb...

FAQPHILOSOPHYSelect-String
Apr 25, 2006
Post comments count0
Post likes count0

Check Spelling Script

PowerShell Team

After reading Marcel's introductory piece on ScriptBlock, I decided to rewrite an old script of mine that checks the spelling of all text files in a directory. Here is what I came out with. #region Parse a line to a list of words $StringFind ={param ($str, $start, $cond)  if ($start -ge 0 -and $start -lt $str.Length...

Apr 25, 2006
Post comments count0
Post likes count0

Base64 Encode/Decode a string

PowerShell Team

Today I came across http://scripts.readify.net/  . This sight is focused on Monad and MSH and is starting a collection of scripts at: http://scripts.readify.net/Scripts.aspx .  You should visit their site and let them know what type of scripts would be useful to you.  I particularly liked their entry on how to Base64 encode a f...

FAQPHILOSOPHYDOTNET
Apr 25, 2006
Post comments count0
Post likes count0

GetObject()

PowerShell Team

Monad provides a way to create new com objects with new-object $ie = New-Object -ComObject InternetExplorer.Application$ie.Navigate2(http://blogs.msdn.com/monad)$ie.Visible=1 Great but what about if you want to bind to an existing object?  Where is the equivalent of GetObject()? This is one of those good new/bad news stories.  First the b...

FAQCOM
Apr 25, 2006
Post comments count0
Post likes count0

Monitor the Event Log

PowerShell Team

Administrators often want to monitor the event logs and look for specific error conditions.  The most capable way to do this, of course, is to use a dedicated monitoring application such as Microsoft Operations Manager, or get down-and-dirty with the Win32 API NotifyChangeEventLog.  However, Monad can be used for simple applications. Supp...

CMDLET
Apr 25, 2006
Post comments count0
Post likes count0

Why did you do that? $VAR/ {} / Weak Intellisense

PowerShell Team

I strongly encourage people to let us know where we could be doing better and to let us know if we are getting into the weeds.  I believe that being open to such bad news is core to the the virtuous cycle of self improvement so such feedback provides opportunities to reflect and make changes when appropriate.  Other times&...

FAQPHILOSOPHY
Apr 25, 2006
Post comments count0
Post likes count0

A bit about Scriptblocks

PowerShell Team

When scripting with MSH one of the most useful things to know about are scriptblocks (lambda functions).  Scriptblocks are compiled bits of MSH script which you can pass around and invoke whenever you feel like it.  They turn out to be so useful that if you look at the cmdlets you’ll find a few that take scriptblocks (foreach-object, w...