PowerShell Team
Automating the world one-liner at a time…
Latest posts

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 | Where {$Today -le $_.TimeWritten}$Events |Group EntryType,Source |Format-Table Count,Name -Auto———————————————————— What Larry really wants is the Application Events that happend in the last 24 hours. We'll Larry - you're in luck because PowerShell leverages the awesome .NET frameworks which support Date Math....

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 $LASTEXITCODE Contains the exit code of the last Win32 executable execution. PS> 2+24PS> $?TruePS> 3/$nullAttempted to divide by zero.At line:1 char:3+ 3/$ <<<< nullPS> $?FalsePS>PS> ping localhost Pingin...

Draft – Creating Cmdlet Help

NOTE: This content is also included as an RTF attachment as well. Creating Cmdlet Help When creating your own cmdlet, you can also create Help content that Windows PowerShell can display using the Get-Help cmdlet. The Help content that describes your cmdlet can include a description of the cmdlet, the syntax used by your cmdlet, parameter descriptions, examples, and other related notes. Creating the Help XML file The name of the Help file must be in the following format: MySnapinAssemblyName.dll-Help.xml Example The following XML shows the major sections that are in t...

Windows PowerShell on TechNet Radio

Tune in & Geek out at Technet Radio: http://www.microsoft.com/technet/community/tnradio/default.mspx There are a couple of PowerShell podcasts there: Drill down into Windows PowerShell: An interview with Jeffrey Snover Scripting with Windows PowerShell: An interview with Vivek Sharma and Mihai Jalobeanu Enjoy! Jeffrey Snover [MSFT]Windows PowerShell/Aspen ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Controlling Internet Explorer object from PowerShell

NOTE: The site must be in the Trusted Sites Zone for this script to work - James Brundage [MSFT] January 5th, 2009 The following example shows how to display all the processes in an IE window and highlight the ones with memory usage of greater than or equal to the specified value. $oIE=new-object -com internetexplorer.application$oIE.navigate2("About:blank")while ($oIE.busy) { sleep -milliseconds 50}$oIE.visible=$true$procList=ps |select-object ProcessName,Handles,NPM,PM,WS,VM,CPU,Id |convertto-html $oDocBody=$oIE.document.documentelement.lastchild ; #populate the document.body$oDocBody.inn...

Thomas Lee on Monad (Windows PowerShell)

The site that has the Best of TECHED Boston also has the BEST of other shows as well. I'm not sure when/where Thomas gave this talk but I just watched it and it is highly entertaining. It's clear that Thomas has been in front of crowds a couple of (thousand) times. For those of you that don't already know Thomas - he is a maniac (in a good way). Find out for yourself at: http://www.microsoft.com/emea/itsshowtime/sessionh.aspx?videoid=277 Enjoy! Jeffrey Snover [MSFT]Windows PowerShell/Aspen ArchitectMicrosoft CorporationVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/Power...

FREE Windows PowerShell Help Tool from Sapien

Command line help is great because it is always there when you need it. That said, sometimes you want to have the help in one window while you experiement in the other. You can always do that with 2 console windows but why would you do that when you can download Sapien's FREE Windows PowerShell help tool. They have a download like in the text of their page describing Don Jones and Jeffrey Hicks PowerShell TFM book. That's TFM as in RTFM. clever. http://www.sapienpress.com/powershell.asp Enjoy! Jeffrey Snover [MSFT]Windows PowerShell/Aspen ArchitectMicrosoft CorporationVisit the...

Best of Tech.Ed 2006 (BOSTON)

TechNet has made the provided videos of the top rated sessions of the TechEd 2006 Boston conference available at: http://www.microsoft.com/emea/itshowtime/ My talk: Windows PowerShell: Next Generation Command Line Scripting is available at: http://www.microsoft.com/emea/itsshowtime/sessionh.aspx?videoid=209 Enjoy! Jeffrey Snover [MSFT]Windows PowerShell/Aspen ArchitectMicrosoft CorporationVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

All crosshairs on the same prairie dog

When I lived in Colorado, I picked up the great concept/phrase, "All crosshairs on the same prairie dog". Damon Cortesi recent blog highlights this principle. http://dcortesi.com/2006/09/07/windows-powershell/ He posted a blog about the verbosity of PowerShell and within an hour - we had 3 PowerShell people post comments. We compared notes and there were no comments when any of us responded so he must have had moderation turned on. Enjoy Jeffrey Snover [MSFT]Windows PowerShell/Aspen ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/Power...