Month: February 2010

Remote file explorer using PowerShell remoting and Windows forms

Last week, I released the remote file explorer powerpack for PowerGUI. The concept of this powerpack is quite simple. We use PowerShell remoting to access the PS drives of a remote machine and then use the same remoting channel to transfer files between computers. I’ve published a free book on PowerShell 2.0 remoting. You can download it at: So, here is the first release of this forms based script. I have put this on CodePlex for better visibility and availability. This will also let me use the version control features of CodePlex. I am no expert in developing GUI applications and there will be some inefficient code. Do let me know when you find some thing like. I will fix it as soon as possible. The project is available at http://psremoteexplorer.codeplex.com/ and the latest release is http://psremoteexplorer.codeplex.com/releases/view/40933. Here is how the initial release looks As shown in the above screenshot, I have used TreeView control for the computer listing and then a DataGrid for listing the files. Requirements 1. PowerShell 2.0 2. pModem 0.5 or …

Remote file explorer PowerPack using PowerShell 2.0 remoting

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: I just realesed my second powerpack for PowerGUI — A remote file explorer. This one uses PowerShell 2.0 remoting to enable remote drive browsing and file transfers. For performing file transfers, I am using pModem module developed by @oising. At present, this module supports file transfers from a remote session only. So as this PowerPack. Requirements 1. PowerGUI 2.0 or later 2. PowerShell 2.0 3. pModem 0.5 or later pModem download: http://www.nivot.org/2009/11/02/PowerShell20IntroducingThePModemFileTransferProtocol.aspx Make sure you copy this module to all remote computer to the $ENV:PSModulePath 4. You need to run PowerGUI with elevated privileges Getting Started Enable PS remoting on computers by using Enable-PSRemoting. For guidance on how to do this in a workgroup environment check http://www.ravichaganti.com/blog/?p=1060 Check PS remoting on each computer by using Enter-PSSession -ComputerName Localhost Install this powerpack Add remote computers using “Add remoting Computers” Option in actions Make sure you check PowerShell libraries in the admin console’s file menu to see if pmodem is enabled or not. Adding a remoting …

Archiving PowerShell command history on a daily basis

I try quite a few things everyday within in a PowerShell prompt or ISE or some other script editor. Sometimes, there will be some useful one-liners I receive on Twitter or found somewhere on Internet. However, once I close the session, the whole command history is gone and I lose all that I tried if I don’t save that in a seperate file. Remembering to save everything I type at command console can be quite painful. In fact, yesterday, I was searching for a tweet I received just a few days ago. To my horror, it was not there on Twitter time line also. So, I decided to write something to save all the command history when I exit the console or my favorite PowerShell editor.   I quickly searched on the net and found @oising‘s persisting command history post which uses eventing to save the command history to a file before exiting. This is what I needed. But as I started using it, I realized the limitations.   The command history is always saved to the …

PowerShell 2.0 remoting guide: Part 12 – Using CredSSP for multi-hop authentication

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: In this part of the remoting series, we look at how CredSSP can be used for multi-hop authentication in PowerShell remoting. CredSSP and multi-hop support are not features of PowerShell 2.0 or PowerShell remoting, per se. Credential Security Service Provider (CredSSP) is a new security service provider that enables an application to delegate the user’s credentials from the client to the target server. Multi-hop support in Windows Remote Management uses CredSSP for authentication. Since PowerShell 2.0 remoting is built on top of WinRM, we can use CredSSP to perform multi-hop authentication. So, what is multi-hop authentication? Well, let us look at an example to understand what is multi-hop authentication. Imagine a group of computers as shown here and you establish a remoting session from computer A (client) to computer B (server) and then from computer B, you try to create a file in a file share on computer C. CredSSP example Now, within the remoting session to computer B, we want to execute a command — as …

PowerShell 2.0 remoting guide: Part 11 – Interpreting, formatting and displaying remote output

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: In this part of the remoting series, we look at remoting output. This includes how the output is transferred from remote computer to local, how it is displayed and how we can format this output based on a need. We already discussed various methods to execute commands (part4, part 5 and part 6) on a remote computer. In this post, for the sake of our discussion of remoting output, I will use only Invoke-Command method to execute remote commands. However, I will point out the differences as required. Note: Most of this does not apply within an interactive remoting session The concepts of remoting output are explained in a TechNet article at http://technet.microsoft.com/en-us/library/dd347582.aspx. I am going to put some story around this to help you understand the concepts well. First, let us start with an obvious difference in the output received from a remote session. If you use Invoke-Command to run Get-PSDrive, you see something like this. You can see an additional …

PowerShell 2.0 remoting guide: Part 10 – Restricting available commands using custom session configuration

Update: This post has been updated to provide accurate details around the subject. Old content has been removed. I’ve published a free book on PowerShell 2.0 remoting. You can download it at: “With great power comes great responsibility”, said uncle Ben. But some people don’t just understand that. That is when you have to rip-off their powers. Similarly, the default PS Session configuration allows full access to PowerShell language, cmdlets, scripts and everything available to PowerShell. Of course, you need to authenticate as a local administrator or should have execute permission to invoke the session. Running a few cmdlets such as Stop-Service or Restart-Computer can be quite dangerous on a production server. This is where a custom session configuration can help provide role based access to remote host using PowerShell remoting. We touched upon creating custom session configuration in part 9 of this PowerShell remoting series. In this part, I will discuss how we can extend the concept of custom session configuration to restrict available commands and PowerShell language in a remote session. I will go striaght …

PowerShell 2.0 remoting guide: Part 9 – Session configurations and creating custom configurations

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: In part2 of this series on PowerShell remoting we quickly looked at various cmdlets that form part of overall remoting infrastructure. The list there included cmdlets related to PS Session configuration. Now that we have gone through the basics of remoting, it is time for us to dig in to these additional cmdlets and explore what they really do. So, in this part, we will look at all the PS session configurtion cmdlets, discuss how to create custom PS Session configurations and the need for it. Let us dive in to this now. What is PS session configuration? A session configuration can be used to define who can create a Windows PowerShell sesion on the local computer, what level of access — to cmdlets, scripts and PowerShell language — they have on the local computer, etc. When you enable PowerShell remoting using Enable-PSRemoting, you will see a final step performing Microsoft.PowerShell and Microsoft.PowerShell32 (on x64 systems) session configuration registrations. These default session configurations are used …

Download PowerScripting podcast episodes using PowerShell and BITS

Update (3/5): Fixed an issue with empty podcast enclosure links  PowerScripting podcast series is a great source of PowerShell related information. I have been following the same since episode 80, if I remember that well. At present the site has no way to download all the episodes in one single click. So, this morning I wrote a quick script to download all of these episodes to my local archive using BITS file transfer service. It is a simple one and did not require lot of effort.  

 This snippet will download all podcast episodes (MP3) files using BITS file transfer service. You can monitor the progress using Get-BitsTransfer cmdlet. After testing this, I thought I will just put the whole thing in to a simple script so that I can re-use the same for other podcast feeds too. The result is the following PowerShell v2 script.      Note: I have not tested this script with any feed URL other than PowerScripting podcast. At the same time, I don’t see a reason why this should fail if the feed …