Showing results 1 - 10 of 14 for the tag: PowerShell.

PowerShell version of dir /s and the -Recurse parameter

My colleagues and I ran into a bit of a problem trying to find all the files that matched a pattern at or below the current folder.  The problem is that the PowerShell Get-ChildItem cmdlet has a bizarre notion of file and path matching.  Consider this cmd.exe command: dir /s Microsoft* This will return all […]

Invoking files with spaces in PowerShell

I needed to run an executable multiple times with different parameters and felt that it would be easier to write the script in PowerShell than in a command script.  The biggest challenge I ran into was running the executable because the path to it has spaces in it (C:\Program Files\etc).  Add to that I wanted […]

PowerShell Prompt Using PSCX

Since I’m using the PowerShell Community Extensions, it makes sense for me to also use the prompt mechanism defined there.  In this article I will describe what PSCX provides over and above what PowerShell provides and how I have chosen to integrate it into my environment. PSCX implements its prompt mechanism as a layer over […]

Prompts in PowerShell

PowerShell provides a very flexible mechanism for specifying what to display for the prompt, particularly since you have the entirety of the .NET Framework at your disposal.  PowerShell displays the prompt using the Prompt function.  By default it is defined like this: ‘PS ‘ + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { ‘>>’ }) + […]


Since my boss decided to switch from cmd.exe to PowerShell (yay!), I’ve been working on setting up a set of standardized profile scripts for everyone.  One of his first questions was how to change the prompt.  Since we’re using the PowerShell Community Extensions, we’ve been not only learning PowerShell but also the community extensions.  One […]

Fixes to PowerShell Community Extension 1.1.1

I’ve been using the Community Extensions for PowerShell for some time now but for various reasons haven’t had the time to really dive in and learn it (or PowerShell) the way I’d like.  My company (well, the IT department at my company) is now standardizing on using PowerShell in place of cmd.exe and using the community […]

PowerShell Community Extensions

I’m working little-by-little towards using PowerShell as my primary command shell instead of cmd.exe.  I’m still a ways away, but PowerShell Community Extensions takes me a bit closer to my goal.  Here’s a description from their web site: PowerShell Community Extensions (PSCX) is aimed at providing a widely useful set of additional cmdlets, providers, aliases, […]

Calling static methods

PowerShell is extremely flexible in what it allows you to do, even allowing you to call static methods on just about any class in just about any assembly.  The problem I had was that I couldn’t remember what the syntax was.  I seemed to recall that it included a double colon (::) but beyond that […]

Error handling in PowerShell scripts

When writing a PowerShell script, often you want to control what happens when an error occurs.  There are several mechanisms available, two of which I’ll describe here. $ErrorActionPreference variable The value of the $ErrorActionPreference variable tells PowerShell what it should do when an error is encountered.  Four values are recognized. Value Meaning SilentlyContinue Ignore the […]

Using PowerShell types with commands and variables

When executing a command in PowerShell that expects a non-string argument, sometimes you need to specify more than just the string representation of the parameter.  Here is an example using dates. PS> 2007-03 2004 PS> [DateTime]"2007-03" Monday, March 01, 2007 12:00:00 AM PS> [DateTime]::Parse("2007-03") Monday, March 01, 2007 12:00:00 AM You can also set the […]

Page 1 of 212