Keith Hill

Explore articles and content from this author

Keith Hill

12 articles published

2 min read

PowerShell Script that Relaunches as Admin

If were following good security practices we run our Windows system with UAC enabled. This means that if you forget to launch your PowerShell prompt as Administrator when you run a script that requires administrative privilege then that script will fail. It would be nice to build a mechanism into our script to “auto-elevate” if UAC is enabled. The trick to doing this is to run Start-Process ““verb runas. After that you only need to figure out if the current user is an administrator and if UAC is enabled.

3 min read

PSCX 2.1 and 3.0 Release Candidates Posted

Oisin and I have been busy prepping the PowerShell Community Extensions to support Windows PowerShell 3.0. With this release, we are providing two packages. There is a Pscx-2.1.0-RC.zip that is xcopy deployable just like PSCX 2.0. Just remember to unblock the ZIP before extracting it otherwise you"™ll get errors when you try to import the module. Pscx 2.1 can be used to target both Windows PowerShell 2.0 and 3.0. In order to do this, Pscx 2.

1 min read

PSCX 3.0 Beta Released

We"™ve just released a beta of the PowerShell Community Extensions 3.0 which targets PowerShell 3.0 specifically. This new version uses a WiX based installer. We may look at providing an xcopy deployable ZIP file but we had so many users get burned by not unblocking the ZIP file that the move back to MSI seemed warranted. The MSI really doesn"™t do much other than copy files into the Program Files dir and add a path to the PSModulePath environment variable.

2 min read

PowerShell V3 "“ ObsoleteAttribute

PowerShell V3 now supports the ObsoleteAttribute for compiled cmdlets but unfortunately not advanced functions. This is handy to let your users know that a binary cmdlet will be going away in a future release of your binary module. As we work on PSCX 3.0 there are a few binary cmdlets that we will mark with this attribute to let you know to switch over to PowerShell"™s built-in equivalent before we eliminate the cmdlet completely in the next release.

4 min read

PowerShell V3 Beta"“Better NTFS Alternate Data Stream Handling

One of the many new features in Windows PowerShell V3 is better support for alternate data streams (ADS) in NTFS files. ADS allows an NTFS file to contain additional data that is not part of the “main” stream i.e. the file"™s primary content. Tools like Windows Explorer or even PowerShell"™s Get-ChildItem cmdlet don"™t show these extra data streams. In fact the file size reported by both of these tools does not take into account the data stored in the alternate streams.

4 min read

PowerShell V3 CTP2 Provides Better Argument Passing to EXEs

Within PowerShell it has always been easy to pass “simple” arguments to an EXE e.g.: C:\PS> ipconfig -all However passing arguments to certain exes can become surprising difficult when their command line parameter syntax is complex i.e. they require quotes and use special PowerShell characters such as @ $ ;. A lot of these problems can be solved by placing single or double quotes in the right places or by escaping PowerShell"™s special characters e.

1 min read

Microsoft Windows PowerShell V3 CTP2 Available for Download

You can grab the bits from here. If you have V3 CTP1 installed, please uninstall it first or you can get your machine into a bad state. So far my favorite two features new to this drop are both in the Integrated Scripting Editor (ISE). The first is the “most recently opened files list” on the File menu and second is the switch to a two pane ISE (combines the output and command panes into one).

6 min read

Windows PowerShell Version 3 Simplified Syntax

Windows PowerShell version 3 introduces a simplified syntax for the Where-Object and Foreach-Object cmdlets. The simplified syntax shown below, eliminates the curly braces as well as the need for the special variable $_. C:\PS> Get-Process | Where PM -gt 100MB ... C:\PS> Get-Process | Foreach Name ... The intent of this “syntax” is to make it easier for folks get started with PowerShell. Compared to the commands below, I can see the value of the simplified syntax:

1 min read

PSCX 2.1 Beta 1 Available for Download

I just uploaded beta 1 for the PowerShell Community Extensions version 2.1. This beta drop adds better support for Windows PowerShell V3 that is in the Windows 8 Developer Preview. There are a number of bug fixes in this drop: 28023 Read-Archive : Cannot bind parameter ‘Path’. Cannot convert the … value of type “System.String” to type “Pscx.IO.PscxPathInfo”. 28198 Test-XML not validating xml against schema correctly 28964 Get-FileTail access conflict 29255 Get-HttpResource Timeout Bug 29598 String – PscxPathInfo ParameterBindingException 30169 Invoke-Ternary example doesn’t work