Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

How it works...

In step 1, you review the cmdlets available in the PackageManagement module:

In step 2, you use the Get-PackageProvider cmdlets to display the currently installed package providers:

In step 3, you use Get-Package with the -ProviderName parameter to review packages installed via the msi, msu, and Programs package providers:

In step 4, review the NuGet provider:

In step 5, search for other package providers:

In step 6, you use Install-PackageProvider to install the Chocolatey provider. Since it is untrusted as a public source, you must approve the installation (at your own risk and responsibility):

In this example, you run Install-PackageProvider from within the ISE. By default, this pops up a confirmation dialog. If you run this cmdlet from the PowerShell console, you see a prompt there. You can suppress these confirmation requests by including the parameter -Confirm:$False.

In step 7, you verify Chocolatey is now installed as a package provider:

In step 8, retrieve a list of available software packages from the ChocolateyPackageProvider, store as a variable, and count the available packages:

In step 9, pipe the variable to Out-GridView and use the filter feature to explore what is available. This example is filtering for the Sysinternals package:

In step 10, you install this package (or any package you choose):

In step 11, you review the installed Chocolatey packages, and the files contained within the sysinternals package folder:

In step 12, run any Sysinternals command, for example, PsInfo.Exe :

In step 13, you enumerate the installed packages with Get-Package. As time goes by, packages can be updated with bug fixes, new features, and so on. You can update all the installed packages if any updates exist, as follows: