PowerShell Team
Automating the world one-liner at a time…
Latest posts
CredSSP for second-hop remoting
PS C:\> $r = New-PSSessionPS C:\> icm $r {Get-PfxCertificate c:\monad\TestpfxFile.pfx}Enter password:Invoke-Command : The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation.At line:1 char:4+ icm <<<< $r {Get-PfxCertificate c:\monad\TestpfxFile.pfx} l am trying to run Get-PfxCertificate in a remote runspace, but why does it fail? What is delegation? PowerShell remoting supports a new authentication mechanism called CredSSP. "CredSSP enables an application to delegate the user’s creden...
V2: Custom Enums
Once again MOW proves what a clever guy he is. Check out his blog entry PowerShell V2 CTP2: making Custom Enums using Add-Type. He shows how you can make your own enums using a very simple function he wrote (Add-Enum) which leverages our new Add-Type cmdlet. Wonderful stuff. Add-Type is one of those huge game-changing features that we've added to V2 and it will take all of us a while to understand the full range of scenarios that it enables. The things that we had in focus for this were: We had a couple others but these were the biggies. There is an important aspect to Add-Type that y...
Show-PowerShell / Hide-PowerShell
During the Week of WPF, someone requested an example of how to minimize the PowerShell window. Here's a quick module to make it happen. Copy/paste the code below into Documents\WindowsPowerShell\Packages\PowerShell\PowerShell.psm1 $script:showWindowAsync = Add-Type –memberDefinition @” [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); “@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru function Show-PowerShell() { $null = $showWindowAsync::ShowWin...
New Free Windows PowerShell Quick Reference Card
I've been working with the folks over at Developer Zone on a quick reference card for PowerShell, based on my book. The card is now complete and is available as a free download. (PDF, registration required.) This is an 8-page card that covers the PowerShell language, common commands and examples. The card was written primarily for developers (it is Developer Zone after all) and for people with existing scripting experience. Even so, if you're using PowerShell, it should be a handy reference to the environment. Thanks -bruce =============================== Bruce Payette [MSFT] Principal Developer, Windows P...
WPF & PowerShell – Part 7 (Sharing Hosts)
Well here we are at the end of a week of WPF. We've learned how to create basic, simple user interactive interfaces. We've seen a brief glimmer of the golden UI layer that is WPF, and have seen how we can use PowerShell to add easy interactivity to XAML. You've seen tricks to help you work your way through .NET code, and help you unwrap the mysteries of WPF. We've seen how we can use PowerShell's list processing technology allows for simple binding to WPF's controls, and how WPF applets can help you present a simple front ends to PowerShell functionality. We've gotten a very brief taste of...
WPF & PowerShell – Part 6 (Running Functions in the Background)
For the next part in the series, I've introduced another update to the Show-Control function you first met in Part 4. In this update, I've added the ability to run the control you've created in a background runspace as a switch. In order to do this, Show-Control employs a neat little trick. It actually creates a background runspace, uses Get-Command to find out its own definition, and packs itself into the runspace it just created. Then it removes the switch parameter that told it to run in the background, but adds every other argument. It also makes sure to recreate the event handlers tha...
WPF & PowerShell – Part 5 ( Using WPF & PowerShell Modules)
In the last post we met XAML, and I gave you a core function (Show-Control) that will help you make interactive WPF controls quite nicely in PowerShell. You can see that, by using Show-Control, it is possible to reduce the size and complexity of a script that creates UI. Today, I'll show you how to build small applications by building functions and modules you can use later. But before we get into that, I'll explain some more of the benefits I see of using scripts to produce user interfaces: Let's focus on the 3rd benefit as we build up a few controls that rely on each other. First, let's ma...
PowerShell and WPF: WTF
A number of people are confused by the WPF/PowerShell series and are "asking WTF?". Aaron has a blog entry, WPF and PowerShell Series - I don't get it. Caywen left a comment on the first in posting saying, "Ugh, I could make a peanut butter and squid sandwich, but that doesn't mean you should." (I like the visual on that one!). I thought I would take a couple of minutes to explain a couple of points and provide some context. PowerShell is NOT a CLI I bet that one took you by surprise. Yup - it's true PowerShell is not a CLI. PowerShell is an AUTOMATION technology. Cmdl...
WPF & PowerShell — Part 4 (XAML & Show-Control)
We're not halfway through our week of WPF, and I'm pretty sure at this point that you have an all right grounding in the basics of WPF & PowerShell, but so far, the scripts haven't really been very much like most PowerShell scripts, and the UIs have not been like most WPF UIs. The scripts have been a little odd because they haven't really made use of a common convention of PowerShell... the pipeline. The WPF examples have also been a little verbose because they do not include any XAML. XAML is an XML format you can use to write user interfaces that use WPF. Because WPF is very property...