Running PowerShell Scripts from a Remote File Share


Summary : Microsoft Scripting Guy, Ed Wilson, talks about running Windows PowerShell scripts from a remote file share.
Microsoft Scripting Guy, Ed Wilson, is here. It is sort of official…
There are at least three Windows PowerShell Saturday events coming up. They are listed on the PowerShell Saturday website. Atlanta and Singapore are already planning (I know, because I will be speaking at both events). The Charlotte event is still early in the planning stages (I will be speaking there also). Of course, don’t just take my word for it. Bookmark the PowerShellSaturday website, so you can keep up to date on all the events.
First things first
Note For good background info about running Windows PowerShell scripts from a remote file share, check out the guest blog post written by June Blender and Judith Herman: How to Run PowerShell Scripts from a Shared Directory .
So I have this shared folder on one of my servers. I can open Windows PowerShell and use the Net View command to see all of the shares. I can then use the Get-ChildItem command ( dir is an alias) to view the files in the shared folder. This is shown here.

If I want to look at the files in a GUI, I can type the path into Internet Explorer, and view the files in the File Explorer as shown in the following image.

For a background, I happen to know that the remote server is running 32-bit Windows Server 2008. I also found out that the server is running Windows PowerShell 2.0. I did this by using the Invoke-Command cmdlet ( icm is an alias) as shown here:
PS C:\> icm -ComputerName dc1 {$PSVersionTable}
Name Value
---- -----
PSRemotingProtocolVersion 2.1
BuildVersion 6.0.6002.18111
PSCompatibleVersions {1.0, 2.0}
PSVersion 2.0
CLRVersion 2.0.50727.4241
WSManStackVersion 2.0
SerializationVersion 1.1.0.1
Open script in ISE
The cool thing is that I can open a Windows PowerShell script in the Windows PowerShell ISE on my 64-bit laptop (running Windows 8a and Windows PowerShell 3.0) from the remote file share. So I do the following:

I open the Windows PowerShell ISE.
I click File , then Open .
In the Open dialog box, I type the UNC path to the remote file share and I press ENTER. I am now viewing the files from the share, as shown in the following image.

I view (and edit if required) the script from the remote file share. When I am ready, I click the green triangle (or press F5) to run the script. At the top of the...(read more)

Skip to main content