Using the PowerShell version 5 Preview OneGet Module with PowerShell Remoting

I’m picking up where I left off in my last blog article. Adobe Reader, ImgBurn, and WinRAR have been installed on a Windows 8.1 Enterprise edition computer named PC03. All of the examples shown in this blog article are being run from the PC03 computer.

I’ll use a little trick I showed you a few blog articles ago and store the names of the installed packages in a variable and return them at the same time, all in a one-liner:

2014-04-07_20-58-22

I’ll create a PSSession to the computers named PC04, PC05, and PC06, store them in a variable named $Session (technically, it’s named Session) and return a list of the sessions all in a one-liner with the same trick I used in the previous command:

2014-04-07_20-43-41

PC04, PC05, and PC06 all run Windows 8.1 Enterprise edition, have the preview version of PowerShell version 5 installed, their script execution policy is set to RemoteSigned, and PowerShell remoting has been enabled on them. One of the cmdlets from the OneGet module has also been previous run on them to trigger installing the NuGet Package Manager, although no packages have previously been installed on them.

Note: The one package source (Chocolatey) that’s included by default with the preview version of PowerShell verison 5 isn’t trusted:

2014-04-07_22-01-21

This means that by default you’ll be prompted as shown in the following example when installing software from that package source:

2014-04-07_20-37-25

Since I’ll be installing the software on the three remote computers using PowerShell remoting, I’ll be unable to answer those interactive questions. There are two options to prevent being prompted, remove the Chocolatey package source and re-add it as a trusted package source, or simply use the -Force parameter with the Install-Package cmdlet.

I’ll use the -Force parameter since it’s the easier solution to this problem and it doesn’t permanently make changes to the package source settings:

2014-04-07_21-01-43

In the previous command, I’ve taken advantage of the Using scope modifier that was introduced in PowerShell version 3. For more information about the Using scope modifier see the about_Scopes and about_Remote_Variables help topics in PowerShell.

Success! All three of the computers (PC04, PC05, and PC06) now have the same packages installed that are installed on PC03 (Adobe Reader, ImgBurn, and WinRAR):

2014-04-07_21-04-02

I’ll be speaking for the Mississippi PowerShell User Group tonight so sign up and join our virtual meeting (Microsoft Lync) which will be held at 8:30pm Central Time (on April 8th). I’m planning to talk about and demo what I’ve discovered in the PowerShell version 5 preview so far (primarily the cmdlets in the new OneGet module).

µ

4 Comments

  1. Daryl Harrington

    Mike have you tried to deploy packages using a Localfeed or remote repository like ProGet using the Nov. preview? I created a local feed (ie. c:\localnugetfeed) on Server A and copied a few packages to it and then tried to follow your procedure but it would never deploy the packages to Server B/C. I did still have the chocolatey feed as a source. Once I unregistered the localnugetfeed as a source, the above procedure worked fine. Seems like the local feed was causing an issue. I would like to have a local feed to be able to deploy packages to remote servers. Not sure how that will work if I want to install packages to a server across domains though. Would love to hear your thoughts.

    Reply
  2. Kevin

    Mike, just curious how you got it to display PS [MikeFRobbins.com]\> ?

    Reply

Leave a Reply

%d bloggers like this: