PowerShell Community Extensions (PSCX) V1.1.1

Steve Lee

Keith Hill reports in his blog HERE , that the PowerShell Community Extensions project has release Version 1.1.1. If you aren’t already turned on to PSCX, this is a good time to start. This is a maintenance release which resolves 30 issues but it also adds 5 new features. I’m going to include their Help topic below so you can get a feel for what it does. I think most people will find something there that will tempt them. One thing to note, when you dot-source PSCX’s profile, it customizes your environment to a pretty extensive degree. If you already have some customizations that you like (like your own prompt), they get overridden. As such, you might want to start out by editing the profile file and running each line by itself and checking its effects and then just comment out those sections that you don’t want. Here is another trick you might want to try: PS> SET-PSDebug -step PS> . $env:pscxhome:\profile\profile.ps1 Continue with this operation? 1+ <<<< . $env:pscxhome\profile\profile.ps1 [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): DEBUG: 1+ <<<< . $env:pscxhome\profile\profile.ps1 Continue with this operation? 20+ $MaximumHistoryCount = <<<< 512 [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): At any given point you can SUSPEND which drops you into a nested prompt and you can explore the system up to that point. When you exit, you continue running the script. This is a pretty useful technique to be aware of. Enjoy! Jeffrey Snover [MSFT] Windows Management Partner Architect Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx TOPIC PowerShell Community Extensions (version 1.1.1.0)

SHORT DESCRIPTION Describes the Windows PowerShell Community Extensions (PSCX) snapin and how to use the contained cmdlets and scripts that ship with PSCX.

LONG DESCRIPTION PowerShell Community Extensions is a PowerShell Snapin that provides a number of widely useful cmdlets. PSCX is not affiliated with Microsoft or the Windows PowerShell team at Microsoft. We are a few (at the moment) passionate PowerShell users who wanted more cmdlets than Microsoft was able to deliver in v1.0. So we have taken it upon ourselves to create some of those cmdlets and make them available to the community.

PROFILE PSCX comes with a basic profile script that you can easily install and use. If you didn’t install it during PSCX installation, just copy the follow PowerShell command to the prompt and execute it. However if you already have a Profile.ps1 script, be sure to rename it or back it up first.

Copy-Item $env:PscxHome\Profile\Profile.ps1 (Split-Path $Profile -Parent)

This profile script dot sources a number of function and filter scripts that provide a more sophisticated prompt, CD function as well as number of useful functions like a TabExpansion function that auto-completes on .NET namespaces and type names filters and filters like Get-TypeName (gtn) and Get-PropertyValue (gpv).

To examine and/or customize the PSCX profile just execute “Edit-Profile” or the alias “ep” at the PowerShell prompt.

If you choose to use the PSCX profile then the following “PROFILE” features will be available in your PowerShell environment.

PREFERENCE VARIABLES The following preference variables allow you to customize the behavior of certain PSCX functions and cmdlets. These are defined or present but commented out at the top of the PSCX provide profile.

$PscxDirForcePreference Dir function always specifies -Force. Will cause hidden and system file system items to be returned. $PscxDirHideSystemPreference Dir function filters out files with the system attribute set. The performance may suffer on high latency networks or in folders with many files. $PscxFileSizeInUnitsPreference Display file sizes in KB, MB, GB multiples. $PscxSmtpFromPreference Not defined by default. Set to something like “j_doe@some.domain.com” and you will not need to specify the corresponding parameter on the Send-SmtpMail cmdlet. $PscxSmtpHostPreference Not defined by default. Set to something like “smtp.some.domain.com” and you will not need to specify the corresponding parameter on the Send-SmtpMail cmdlet. $PscxSmtpPortPreference Not defined by default. Set to something like 587 if you SMTP server doesn’t use the default port (25) and you will not need to specify the corresponding parameter on the Send-SmtpMail cmdlet. $PscxTextEditorPreference Defines which editor is started by the EditFile function (alias “e”). Defaulted to “Notepad”. Change to your favorite text editor. $PscxTranscribeSessionPreference Set to true to create a transcript of the entire PowerShell session.

CMDLETS To see what cmdlets are provided by PSCX, execute the alias “gcmpscx” at the PowerShell prompt. The current PSCX cmdlets are listed below:

Get-ADObject Search for objects in the Active Directory/Global Catalog.

Resolve-Assembly Resolve and optionally import Assemblies by partial name with optional Version.

Test-Assembly Tests whether or not the specified file is a .NET assembly.

ConvertFrom-Base64 Converts base64 encoded string to byte array.

ConvertTo-Base64 Converts byte array or specified file contents to base64 string. By default, this cmdlet inserts line breaks every 76 characters and outputs the result in a single string. For very large files, you may run into OutOfMemoryExceptions. In this case, use the -Stream parameter which will generate multiple string outputs that, combined together, result in the equivalent base 64 text.

Export-Bitmap Exports a bitmap object to a specified file format.

Import-Bitmap Loads bitmap files.

Resize-Bitmap Resizes bitmaps.

Format-Byte Turns numbers into nicely formatted byte count, using the highest possible unit.

Write-BZip2 Create BZIP2 format archive files from pipline or parameter input.

Get-Clipboard Gets data from the clipboard.

Out-Clipboard Formats text via Out-String before placing in clipboard.

Set-Clipboard Puts the specified object into the system clipboard.

Write-Clipboard Writes objects to the clipboard using their string representation, bypassing the default PowerShell formatting.

Get-DhcpServer The Get-DhcpServer cmdlet gets all authorized DHCP server from the Active Directory Forest.

Get-DomainController Gets a list of available domain controller in the current forest/domain.

Get-ExportedType Displays public types for a given AssemblyName by loading the associated assembly into a reflection-only context and dumping all publicly accessible Type objects to the pipeline. This cmdlet is typically used in conjunction with AssemblyName objects returned from the GAC provider to display potential candidates for the New-Object cmdlet. Dependent assemblies are not automatically resolved by default as the primary assembly is loaded into a specialized “reflection-only” context; this aids with debugging versioning and/or dependency issues. Providing the ResolveDependencies SwitchParameter will cause the cmdlet to try to load dependent assemblies automatically; if not present, you will be prompted to load them. See notes at footer for more information.

Set-FileTime Sets a file or folder’s created and last accessed/write times.

Get-FileVersionInfo Attempts to get the FileVersionInfo object for the specified path. Usually only executable files include file version information.

Get-ForegroundWindow Returns the hWnd or handle of the window in the foreground on the current desktop. See also Set-ForegroundWindow.

Set-ForegroundWindow Given an hWnd or window handle, brings that window to the foreground. Useful for restoring a window to uppermost after an application which seizes the foreground is invoked. See also Get-ForegroundWindow

Write-GZip Create GNU ZIP (GZIP) format files from pipeline or parameter input.

New-Hardlink Creates filesystem hard links. The hardlink and the target must reside on the same NTFS volume.

Get-Hash Gets the hash value for the specified file or byte array via the pipeline. The default hash algorithm is MD5, although you can specify other algorithms using the -Algorithm parameter (MD5, SHA1, SHA256, SHA384, SHA512 and RIPEMD160). This cmdlet emits a HashInfo object that has properties for Path, Algorithm, HashString and Hash.

Format-Hex The Format-Hex command displays the contents of the specified files in hex format. This cmdlet will also accept pipeline input in the form of a byte stream. The output can be controlled via various parameters to indicate the number of columns that should be displayed or alternatively you can specify the width of the output. The header, address and ASCII portions of the display can also be turned off individually. The offset and count can also be specified via parameters to control where in the input to start displaying and how much to display.

Ping-Host Sends ICMP echo requests to network hosts.

Resolve-Host Resolves host names to IP addresses.

New-Junction Creates NTFS directory junctions.

ConvertTo-MacOs9LineEnding Converts the line endings in the specified file to Mac OS9 and earlier style line endings “\r”. You can convert a single file to a new file name. Or you can convert multiple files and specify a destination directory. By default, this cmdlet will overwrite existing files unless you specify -NoClobber. If you want to force the overwrite of read only files use the -Force option.

Get-MountPoint Returns all mount points defined for a specific root path.

Remove-MountPoint Removes a mount point, dismounting the current media if any. If used against the root of a fixed drive, removes the drive letter assignment.

Get-PEHeader The PE header for Windows executables includes various useful bits of information including the image base address, subsystem, linker version, etc.

Get-Privilege Lists privileges held by the session and their current status.

Set-Privilege Adjusts privileges held by the session.

Start-Process Starts a new process. This cmdlet can be used with documents to invoke their default verb or the verb can be specified using the -Verb parameter. You can also specify the -Credential parameter to run the process as a different user.

Get-PSSnapinHelp Generates a XML file containing all documentation data.

Get-Random Returns a random integer in a specified interval, a double-precision number between 0 and 1, or a buffer of random bytes. It may use the cryptographically strong random number generator, if desired.

Get-ReparsePoint Gets NTFS reparse point data.

Remove-ReparsePoint Removes NTFS reparse junctions and symbolic links.

New-Shortcut Creates shell shortcuts.

Get-ShortPath Gets the short, 8.3 name for the given path. This cmdlet emits a ShortPathInfo object that contains a ShortPath property as well as a Path property which contains the original long path.

Send-SmtpMail Sends email via specified SMTP server to specified recipients. This cmdlet checks for existence of several preference that if set can make this cmdlet much easier to use. Those preference variables are: * $PscxSmtpHostPreference=”smtp.example.net” * $PscxSmtpPortPreference=587 * $PscxSmtpFromPreference=”john_doe@example.net”

Join-String Joins an array of strings into a single string.

Split-String Splits a single string into an array of strings.

New-Symlink Creates filesystem symbolic links. Requires Microsoft Windows Vista or later.

Get-TabExpansion This command provides access to the PSCX tab expansion engine. If you are not using the PSCX profile, call this command from your TabExpansion function.

Start-TabExpansion Initializes the caches used by Get-TabExpansion. These may include the .NET namespace and type cache, the WMI class cache, and more.

Write-Tar Create Tape Archive (TAR) format files from pipeline or parameter input.

Disconnect-TerminalSession Disconnects a specific remote desktop session on a system running Terminal Services/Remote Desktop

Get-TerminalSession Gets information on terminal services sessions.

Stop-TerminalSession Logs off a specific remote desktop session on a system running Terminal Services/Remote Desktop

ConvertTo-UnixLineEnding Converts the line endings in the specified file to Unix line endings “\n”. You can convert a single file to a new file name. Or you can convert multiple files and specify a destination directory. By default, this cmdlet will overwrite existing files unless you specify -NoClobber. If you want to force the overwrite of read only files use the -Force option.

Set-VolumeLabel Modifies the label shown in Windows Explorer for a particular disk volume.

ConvertTo-WindowsLineEnding Converts the line endings in the specified file to Windows line endings “\r\n”. You can convert a single file to a new file name. Or you can convert multiple files and specify a destination directory. By default, this cmdlet will overwrite existing files unless you specify -NoClobber. If you want to force the overwrite of read only files use the -Force option.

Convert-Xml Performs XSLT transforms on the specified XML file or XmlDocument. Use the EnableScript parameter to enable script embedded in the XSLT file.

Format-Xml Pretty print for XML files and XmlDocument objects.

Select-Xml Select-Xml provides an easy way to define namespace prefix to namespace mappings. It handles creating a NamespaceManager and associating that with the XPath queries executed against the supplied XML.

Test-Xml Tests for well formedness and optionally validates against XML Schema. It doesn’t handle specifying the targetNamespace. To see validation error messages, specify the -Verbose flag.

Write-Zip Create ZIP format archive files from pipline or parameter input.

PROVIDERS AssemblyCache Provides access to the .NET Global Assembly Cache and the assemblies it contains. The assemblies are exposed as AssemblyName objects.

DirectoryServices Provides access to LDAP servers like Active Directory or AD Lightweight Directory Services.

FeedStore Provides access to the Internet Explorer 7 RSS feed store.

FILTERS Get-PropertyValue This filter is different from the Select-Object cmdlet in that it doesn’t create a wrapper object (PSCustomObject) around the property. If you just want to get the property’s value to assign it to another variable this filter will come in handy. If you assigned the result of the Select-Object operation you wouldn’t get the property’s value. You would get an object that wraps that property and its value.

Usage: $start = Get-History -Id 143 | Get-PropertyValue StartExecutionTime

Invoke-NullCoalescing Similar to the C# ?? operator e.g. name = value ?? String.Empty; where value would be a Nullable in C#. Even though PowerShell doesn’t support nullables yet we can approximate this behavior. In the example below, $LogDir will be assigned the value of $env:LogDir if it exists and it’s not null, otherwise it get’s assigned the result of the second script block (C:\Windows\System32\LogFiles). This behavior is also analogous to Korn shell assignments of this form: LogDir = ${$LogDir:-$WinDir/System32/LogFiles}

Usage: $LogDir = ?? {$env:LogDir} {“$env:windir\System32\LogFiles”}

Invoke-Ternary Similar to the C# ? : operator e.g. name = (value != null) ? String.Empty : value;

Usage: 1..10 | ?: {$_ -gt 5} {“Greater than 5”;$_} {“Not greater than 5”;$_}

New-HashObject Use when you need to create a PSObject from a dictionary. The keys-value pairs are turned into NoteProperties.

Usage: $ht = @{fname=’John’;lname=’Doe’;age=42} $ht | New-HashObject

Remove-Accessors This filter is intended to be used to filter the Get-Member output to eliminate display of compiler generated accessor methods.

Usage: Get-Process | Get-Member | Remove-Accessors

FUNCTIONS Add-PathVariable This function adds the specified paths to the specified environment variable.

Usage: Add-PathVariable Path C:\Bin,C:\Users\John\Bin

cd CD function that handles location history via a backward and forward stack mechanism that can be navigated using “cd -” to go backwards in the stack and “cd +” to go forwards in the stack. Executing “cd” without any parameters will display the current stack history. For more information execute “cd -?”.

Usage: cd $pscxhome; cd -; cd +; cd -0

cd- Auto-correct function for ‘cd -‘ which changes location backwards in the stack.

cd.. Auto-correct function for ‘cd ..’ which changes location up one level.

cd… Auto-correct function for ‘cd …’ which changes location up two levels.

cd…. Auto-correct function for ‘cd ….’ which changes location up three levels.

cd….. Auto-correct function for ‘cd …..’ which changes location up four levels.

cd? Auto-correct function for ‘cd ?’ which displays usage information.

cd\ Auto-correct function for ‘cd \’ which changes location to the root of the current drive.

cd~ Auto-correct function for ‘cd ~’ which changes location to your Home dir.

cd+ Auto-correct function for ‘cd +’ which changes location forwards in the stack.

Collect Simple alias for the [System.GC]::Collect() static method. This comes in handy when a .NET object hasn’t been disposed and is causing a file system handle to not be released.

Usage: collect

dird Displays just containers (directories).

Usage: dird dird -first 5 dird C:\,$env:windir -combine

dirs Displays folder contents sorted by size descending.

Usage: dirs dirs -first 10 dirs C:\,$Home -combine -f 20

dirt Displays folder contents sorted by time descending.

Usage: dirt dirt -first 10 dirt C:\,$Home -combine -last 20

dirw Displays folder contents in wide format.

Usage: dirw dirw C:\,$env:windir -combine

dirx DIRX is an extended dir function that is used by dird, dirs and dirt. It provides shortcuts for displaying files/dirs with particular attributes. For more information execute “dirx -?”.

Usage: dirx dirx -set Directory,Hidden

Disable-Breakpoints Globally disables breakpoints.

Edit-File Opens up the specified text file in the text editor specified by $PscxTextEditorPreference variable. If not specified or the specified editor isn’t found then notepad is used.

Usage: Edit-File foo.txt gci -r -filter *.make | edit-file

Edit-GlobalHostProfile Opens the machine wide, host specific profile into the editor defined by $PscxTextEditorPreference variable. If not specified or the specified editor isn’t found then notepad is used.

Edit-GlobalProfile Opens the machine wide generic (non-host specific) profile into the editor defined by $PscxTextEditorPreference variable. If not specified or the specified editor isn’t found then notepad is used.

Edit-HostProfile Opens the user’s host specific profile into the editor defined by $PscxTextEditorPreference variable. If not specified or the specified editor isn’t found then notepad is used.

Edit-Profile Opens the user’s generic (non-host specific) profile into the editor defined by $PscxTextEditorPreference variable. If not specified or the specified editor isn’t found then notepad is used.

Elevate Runs the specified command via an elevated PowerShell instance on Vista. To get debug info, set $DebugPreference temporarily to ‘Continue’.

Usage: elevate elevate notepad c:\windows\system32\drivers\etc\hosts elevate gci c:\windows\temp elevate {gci c:\windows\temp | export-clixml tempdir.xml; exit} elevate {gci c:\windows\temp | export-clixml tempdir.xml; exit} | %{$_.WaitForExit(5000)} | %{Import-Clixml tempdir.xml}

Enable-Breakpoints Globally enables breakpoints.

Get-CallStack Displays the function invocation callstack.

Get-ExceptionForHR Returns an exception object for a HRESULT code.

Usage: hrexc -2147023293 Fatal error during installation. (Exception from HRESULT: 0x80070643)

Get-ExceptionForWin32 Returns an exception object for a windows error code.

Usage: winexc 5 Access is denied

Get-PscxAlias Displays all of the aliases created by PSCX.

Get-PscxCmdlet Displays all of the cmdlets provided by PSCX.

Get-PscxDrive Displays all of the drives created by PSCX.

Get-PscxVariable Displays the variables defined by PSCX.

Get-TabExpansion TabExpansion enhances the built-in tab expansion feature of PowerShell. This function does nothing more than call the PSCX cmdlet Get-TabExpansion. NOTE: This function is invoked by PowerShell. You shouldn’t need to invoke it directly.

Usage: Place the following command in your profile if it isn’t present: . “$Env:PscxHome\Profile\TabExpansion.ps1”

Get-VariableSorted Behaves just like Get-Variable except that the output is sorted by name.

glp Gets the current location’s path. This is handy if you just want to see what your location is in a very terse format.

Less Provides easy PowerShell access to the external Less-394 paging application. NOTE: Be careful using less with large amounts of output e.g. gci $env:windir\System32 | less. It appears that PowerShell buffers up all the gci output before converting it to strings to pass to less.

Usage: Get-Content foo.txt | less

Prompt Replacement prompt function. See $PscxHome\Profile\EyeCandy.Jachym.ps1 and $PscxHome\EyeCandy.Keith.ps1 for examples on how to configure the prompt function. Or just comment out the dot sourced EyeCandy scripts in $UserProfile if you have your own prompt function.

Quote-List Use as a wrist friendly way of creating an array of strings without having to type extraneous commas and quotes:

Usage: ql foo bar baz # equivalent of “foo”, “bar”, “baz”

Quote-String Use as a wrist friendly way of create a string from a set of items where each item will be separated by $OFS. Eliminates having to type extraneous quotes:

Usage: qs $a $b $c # equivalent of “$a $b $c”

Set-Breakpoint This function sets a breakpoint in a script that causes a nested prompt to be entered.

Usage: Set-Breakpoint

Skip-Breakpoints Skips over specified number of breakpoints before breaking.

Usage: Skip-Breakpoints 5

Update-Profile Reloads the user’s generic (non-host specific) profile.

SCRIPTS Add-DirectoryLength Calculates the sizes of the specified directory and adds that size as a “Length” NoteProperty to the input DirectoryInfo object. This script is pipeline oriented.

Usage: Get-ChildItem . -recurse | Add-DirectoryLength | sort Length

Add-ShortPath Adds the file or directory’s short path as a “ShortPath” NoteProperty to the input DirectoryInfo object. NOTE: This filter requires the PSCX cmdlet Get-ShortPath

Usage: dir | Add-ShortPath | Format-Table ShortPath,FullName

Clip This function enables quick access to the text data in the clipboard.

Usage: dir | clip clip | ConvertTo-WindowsLineEnding | sc D:\Mary\file.txt

Connect-VirtualServer Invokes URL to Virtual Server’s VSWebApp.exe.

ConvertFrom-WmiDateTime Uses the PowerShell ManagementDateTimeConverter to converter between WMI and .NET DateTime. This is a pipeline oriented script.

Usage: gwmi win32_operatingsystem | gpv LastBootUpTime | ConvertFrom-WmiDateTime

ConvertFrom-WmiTimeSpan Uses the PowerShell ManagementDateTimeConverter to converter between WMI and .NET TimeSpan. This is a pipeline oriented script.

ConvertTo-DmtfDateTime Uses the PowerShell ManagementDateTimeConverter to converter between DMTF and .NET DateTime.

ConvertTo-DmtfTimeInterval Uses the PowerShell ManagementDateTimeConverter to converter between DMTF and .NET TimeSpan.

Export-History Exports your entire command history to a clixml file.

Usage: Export-History Export-History $home\hist.xml

Get-DiskUsage Gets the disk info (free,used,etc) for each drive.

Get-HelpMatch Search the PowerShell help documentation for a given keyword or regular expression.

Usage: Get-HelpMatch hashtable Get-HelpMatch “(datetime|ticks)” -verbose

Get-LoremIpsum Lorem ipsum generator.

Usage: Get-LoremIpsum Get-LoremIpsum 20 -Language Spanish

Get-PagedHelp Pages help using LESS.

Get-ScreenCss Generate CSS header for HTML “screen shot” of the host buffer.

Usage: $css = Get-ScreenCss

Get-ScreenHtml Functions to generate HTML “screen shot” of the host buffer.

Usage: Get-ScreenHtml Get-ScreenHtml 25

Get-TypeName This filter is handy for finding out what types are being passed down the pipeline quickly. Normally you would use Get-Member to determine this but if you are only interested in the type name this filter produces much less output. Also, since Get-Member accumulates multiple instances of the same type into a single output record for that type, you don’t get any sense of how many objects of that type are traversing the pipeline. With this filter, you will see the type name of *every* object passed into it. NOTE: If you specify any arguments then all pipeline input is ignored. This is due to the fact that PowerShell executes the Process function even if there isn’t any input so it is impossible to distinguish between $null pipeline input and no pipeline input.

Usage: gcm get-* | Get-TypeName Get-TypeName “hi” 1 3.14 $false Get-Command get-* | Get-TypeName -FullName

Get-Url This script scrapes the web page of the supplied web URL and outputs a string containing the contents of the web page.

Usage: Get-Url http://www.codeplex.com/PowerShellCX/Project/ProjectRss.aspx

Get-ViewDefinition Gets the possible alternate views for the specified object.

Usage: Get-ViewDefinition Get-ViewDefinition System.Diagnostics.Process Get-ViewDefinition Pscx.Commands.HashInfo $pscxhome\formatdata\*.ps1xml Get-Process | Select -first 1 | Get-ViewDefinition | ft Name,Style -groupby SelectedBy

Import-Assembly Imports the specified assembly via LoadWithPartialName or LoadFrom.

Usage: Import-Assembly System.Windows.Forms Import-Assembly .\Foo.dll

Import-History Imports command history from a clixml file.

Usage: Import-History Import-History $home\hist.xml

Out-Speech Outputs text as spoken words

Usage: Out-Speech “Hello World”

Reduce-Object Applies the supplied reduce function against the pipeline objects. If a reduce function isn’t applied the following default function is used: {param($1,$2) $1 + $2}. The first parameter to this function is the seed value to use send to the reduce function as the first parameter. The reduce function is the second parameter.

Usage: 1..5 | Reduce-Object 0 1..5 | Reduce-Object 1 {param($1,$2)$1*$2}

Resolve-Error Use when reporting an error or ask a question about a exception you are seeing. This function provides all the information we have about the error message making it easier to diagnose what is actually going on.

Search-Transcript Searches your session transcript files for the specified pattern.

Usage: Search-Transcript fxml

Select-History Selects individual history info objects or ranges of them.

Usage: Select-History (1..5+8,9+14..20)

Select-Random Selects a random element from the collection either passed as a parameter or input via the pipeline.

Usage: $arr = 1..5; Select-Random $arr 1..5 | Select-Random

Set-ReadOnly This filter can be used to change a file’s read only status.

Usage: Set-ReadOnly foo.txt Set-ReadOnly [a-h]*.txt -passthru Get-ChildItem bar[0-9].txt | Set-ReadOnly

Set-Writable This filter can be used to change a file’s read only status.

Usage: Set-Writable foo.txt Set-Writable [a-h]*.txt -passthru Get-ChildItem bar[0-9].txt | Set-Writable

PROFILE DEFINED ALIASES To see what aliases get created by PSCX, execute the alias “galpscx” at the PowerShell prompt. The current PSCX defined aliases are listed below:

: alias for

UTILITY APPLICATIONS Less-394 Less-394 is a paging utility that PSCX installs and hooks into the help and man aliases. Using Less to browse help topics is significantly nicer than the default paging in PowerShell. PSCX does not however redefine PowerShell’s “more” function to use Less because the way PowerShell interops with legacy applications causes all output to be rendered to text before it is sent to a legacy application. That makes commands like the following take too much time to generate any output:

PS> gci ‘$env:windir -rec | more’

EchoArgs This is a simple legacy console application that can be very useful when you are troubleshooting the invocation of a legacy application with complex parameters. The typical problem is that you may think the parameters are being passed literally to the legacy application when in fact PowerShell is parsing the parameters via its standard parameter parsing and then passing the result to the legacy application e.g.:

PS> echoargs a /b -c -d:user /e:foo.cs;405 Arg 0 is Arg 1 is Arg 2 is <-c> Arg 3 is <-d:> Arg 4 is Arg 5 is

405

Notice that PowerShell passes ‘-d:user’ as two different parameters. And since ‘;’ is the statement separator in PowerShell the 405 part of the parameter ‘/e:foo.cs;405’ is not even considered a parameter to the legacy application. These sort of problems are typically solved by quoting the arguments to legacy applications e.g.:

5> echoargs a /b -c ‘-d:user’ ‘/e:foo.cs;405’ Arg 0 is Arg 1 is Arg 2 is <-c> Arg 3 is <-d:user> Arg 4 is

MISCELLANOUS FEATURES An “Open PowerShell Prompt” here Windows Explorer context menu item is created for folders and drives. A PowerShell script icon is also registered for the PS1 file extension as well as a user friendly name for the file type – “Windows PowerShell Script”. Note: PSCX does *not* change the default verb association. PS1 files will still open in Notepad when they are double-clicked or invoked with the “Open” or “Edit” verbs.

FEEDBACK Please submit any feedback, including defects and enhancement requests, to either the discussions forums at:

http://www.codeplex.com/PowerShellCX/Thread/List.aspx

or via the Issue Tracker at:

http://www.codeplex.com/PowerShellCX/WorkItem/List.aspx

We are also interested in suggestions you may have for cmdlets. Over time, we hope to be able to add some custom providers but that greatly depends on recruiting some more developers for the PSCX project.

CONTRIBUTING TO PSCX If you are:

A) A software developer with experience programming in C# B) Passionate about Windows PowerShell C) Interested in contributing your coding talents to the project, please drop me an email at:

r_keith_hill@hotmail.com.

SEE ALSO For more information, most of the cmdlets have help associated with them e.g.:

PS> help Get-Clipboard

The definitive information on a cmdlet’s parameters can be obtained by executing:

PS> Get-Command Split-String | Format-List *

or more tersely:

PS> gcm split-string | fl *

0 comments

Comments are closed. Login to edit/delete your existing comments

Feedback usabilla icon