PowerShell Team

Automating the world one-liner at a time…

Same Command. Different Return Types.

My command seems to behave differently depending on how many items were returned. This is something that the PowerShell Team hears from the community or our internal partners every couple of weeks. This blog post will explain when a Windows PowerShell command returns different types and offer some reasons for why it is done this way. In ...

Installing PowerShell on Vista/"Longhorn" Server

1.       I am new to PowerShell and would like to install it on my Vista machine. The following page  http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx gives you links to various PowerShell downloads. Choose the one that best matches your operating system, platform ...
Comments are closed.0 0
FAQ

Why Can’t I Pipe Format-Table to Export-Csv (and get something useful)?

Ken's PowerShell blog has an entry Remote Services and PowerShell where he wrote a function to get services from a remote machine using WMI. He formatted the data using FT (format-table) and then went on to export the data to CSV. He pointed out that the following would NOT work rget-service remotemachinename netlogon | ft -autosize name,...
Comments are closed.0 0
FAQ

Why isn’t “New-Object” aliased to “New”

Alistair Young made a Note to Self : In a standard PowerShell installation, "new" is not an alias for "new-object". You added that. You should therefore know better that to make this kind of dumbass mistake. We talked about making "New" an alias to "New-Object" but decided against it in the end because it leaves open the door for us to provide...
Comments are closed.0 0
FAQ

PowerShell Cheat Sheet Redux – the PDF version

Attached is a PDF version of Ben Pearce's PowerShell Cheat Sheet.  In the past I've encouraged everyone to speak up and complain if we were messing up or not giving you what you needed.  I'm pleased to see that you have taken this to heart (seriously).   Ben and every other Microsoft employee has been using ...
Comments are closed.0 0
FAQ

PowerShell Cheat Sheet

Ben Pearce was gracious enough to put together a good looking PowerShell Cheat Sheet which I've included as an attachment to this blog post.  By definition, a cheat sheet is incomplete so this contains the things that Ben has found to be the most import.   I think you'll find it useful. Cheers! Jeffrey Snover [MSFT]...
Comments are closed.0 0
FAQ

Windows PowerShell Exit Codes

Windows PowerShell Exit Codes   PSMDTAG:FAQ: How can my script control the PowerShell exit code? Answers: 1.      A normal termination will set the exitcode to 0 2.      An uncaught THROW will set the exitcode to 1 3.      The EXIT statement will stop the ...
Comments are closed.0 0
FAQ

The Wonders of Date Math using Windows PowerShell

Larry Hayden posted a query about dates at:http://techtasks.com/bookmarks/powershell/2006/09/interview-with-a-scripter-jeffrey-snover/ He has a script which gets all the Application Events that happened TODAY: ————————————————————$today = [DateTime]::Today$Events = Get-Eventlog -New 1024 Application | ...

ErrorLevel equivalent

PSMDTAG:FAQ: ErrorLevel - what is the PowerShell equivalent? In Cmd.exe, %ErrorLevel% is a builtin variable which indicates the success or failure of the last executable run. In PowerShell, we support:     $?       Contains True if last operation succeeded and False otherwise.And   &...

DateTime Utility Functions

I often want to find things that happened Today.  For instance, which files got changed today.  Windows PowerShell makes this easy to do but it can be a bit verbose and I do it a lot so I've added a function to my profile:  IsToday. function isToday ([datetime]$date) {[datetime]::Now.Date  -eq  $date.Date} This takes ...

Feedback usabilla icon