PowerShell Team

Automating the world one-liner at a time…

Creating a Secure Environment using PowerShell Desired State Configuration

Introduction: Traditionally, IT environments have secured their business critical information against external threats by adding additional layers of security to the org’s network (e.g. firewalls, DMZs, etc.).  However many of today’s attacks are coming from inside the network so a new “assume breach” approach must be adopted. In ...

How objects are sent to and from remote sessions

Instead of piping unstructured text, Windows PowerShell pipes objects between commands in a pipeline.  As a consequence PowerShell remoting also deals with objects when passing data to and from remote sessions.  This post explains how remote objects are serialized and which types of objects can be sent with full fidelity.  You ...

Saving remote session to your local disk

Read the previous post on implict remoting to learn how the Import-PSSession cmdlet makes it easier to work with remote commands by presenting them as if they were local commands. This user experience saves you the trouble of typing long Invoke-Command incantations to pass arguments to remote commands or to download remote help content. The ...

Bringing remote commands to your local session

How can you manage multiple technologies installed on separate machines that expose their management surface through cmdlets?  One approach would be to open remote desktop connection to each of those machines, another approach would be to send commands using Invoke-Command and PowerShell Remoting.  But remote desktop is not a ...

How to pass arguments for remote commands

When invoking remote commands, one often wants to use local values as arguments to the remote command. This post explains how to do that. Hardcoded values Let's start with a simple example. Below you can see how Get-Process is invoked in a remote session when the Id parameter is set to 0: Passing local values What if we want to calculate ...

Advanced Debugging in PowerShell

Here is a collection of tips and tricks to debug PowerShell Read UpThere is a 7-part series of “Debugging Monad Scripts” that Jon Newman wrote a few years ago that covers a lot of tips, including error handling, traps, tracing, and covers a lot of V1 stuff. Clean codeThe best route, is to make sure code is clean, and common errors are ...

Managing Remote Sessions

  PowerShell V2 introduces a new capability which allows you to remotely manage machines in your organization. You may have already tried this new feature. In this blog, I will show how an administrator can manage different remote sessions (created by different users from different clients) Scenario: Using PowerShell remoting, normal ...

Interactive remoting in CTP3

Today let's talk about one of the cool new features of Windows PowerShell V2 - Interactive Remoting. Let’s start with an example: As you can see Enter-PSSession starts interactive remoting session and Exit-PSSession takes you out of it. The aliases for these commands are etsn and exsn. You can also use exit keyword instead of Exit-...

Manage winrm settings with wsman provider

PowerShell remoting is built on top of Windows Remote Management (WinRM), which is Microsoft’s implementation of WS-Management protocol. You can use winrm.cmd command line tool to query and manage winrm settings. PowerShell V2 CTP3 contains a wsman provider for you to manage winrm settings with the standard *-Item cmdlets . Let’s try it ...

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-...