Package Management in Windows PowerShell v5: Install and Manage Software from the Command Line
Historically, I’ve been a big fan of Linux in general, and Debian Linux in particular. It’s awesome being able to use the Advanced Packaging Tool (APT) to locate, install, and manage software, all from the command line.
For instance, I can run the following command on my Ubuntu Linux box to install the nmap network scanner:
sudo apt-get install nmap
The good news for Windows systems administrators is that Windows PowerShell v5 Preview includes this same functionality. At the moment the module is called OneGet, but PowerShell co-creator Jeffrey Snover said at this year’s Microsoft Ignite conference that for legal reasons the team will change the module’s name to PackageManagement.
Let’s get started!
Now, Don’t Get Confused…
After you’ve installed WMF 5 on one of your non-production systems, fire up an elevated PowerShell console session. Command-line installation goodness is available for software packages (OneGet), as well as for community PowerShell modules (PowerShellGet). To that point:
Get-Command -Module PowerShellGet | Select-Object -Property CommandType, Name | Format-Table -AutoSize CommandType Name ----------- ---- Function Find-Module Function Get-PSRepository Function Install-Module Function Publish-Module Function Register-PSRepository Function Set-PSRepository Function Unregister-PSRepository Function Update-Module
As cool as PowerShellGet is, it’s not the focus of this article. Instead, let’s investigate the commands contained within the OneGet module:
Get-Command -Module OneGet | Select-Object -Property CommandType, Name | Format-Table -AutoSize CommandType Name ----------- ---- Cmdlet Find-Package Cmdlet Get-Package Cmdlet Get-PackageProvider Cmdlet Get-PackageSource Cmdlet Install-Package Cmdlet Register-PackageSource Cmdlet Save-Package Cmdlet Set-PackageSource Cmdlet Uninstall-Package Cmdlet Unregister-PackageSource
That’s the ticket! If you’ve never used Linux package managers such as apt, yum, or rpm, be prepared to be surprised at how easy the process is. I’m a big fan, because I never like clicking through graphical installation routines.