Showing results for FAQ - PowerShell Team

Dec 10, 2010
0
0

Same Command. Different Return Types.

PowerShell Team
PowerShell Team

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 general,...

FAQReturn Values
Mar 8, 2007
0
0

Installing PowerShell on Vista/"Longhorn" Server

PowerShell Team
PowerShell Team

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 and lan...

FAQ
Mar 7, 2007
0
0

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

PowerShell Team
PowerShell Team

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,startmod...

FAQ
Feb 23, 2007
0
0

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

PowerShell Team
PowerShell Team

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 a C#...

FAQ
Jan 24, 2007
0
0

PowerShell Cheat Sheet Redux – the PDF version

PowerShell Team
PowerShell Team

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 Offic...

FAQ
Jan 24, 2007
0
0

PowerShell Cheat Sheet

PowerShell Team
PowerShell Team

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]Windows ...

FAQ
Oct 14, 2006
0
0

Windows PowerShell Exit Codes

PowerShell Team
PowerShell Team

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 process a...

FAQ
Sep 17, 2006
0
0

The Wonders of Date Math using Windows PowerShell

PowerShell Team
PowerShell Team

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 | Where {$Today -le $_.TimeWritten}$Events |Group...

FAQDOTNET
Sep 15, 2006
0
0

ErrorLevel equivalent

PowerShell Team
PowerShell Team

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     ...

FAQ$lastExitCodeErrorLevel
Sep 6, 2006
0
0

DateTime Utility Functions

PowerShell Team
PowerShell Team

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 advant...

FAQDateTimeisToday