![Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)](https://wfqqreader-1252317822.image.myqcloud.com/cover/733/36700733/b_36700733.jpg)
How it works...
In step 1, you review the cmdlets available in the PackageManagement module:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/03d8d068-772f-4023-bca3-604f835f2910.png?sign=1739288708-Sw19ihx1DGkOE0C6PBcCg1ISfPczUHHa-0-a4e5a1a634499f6f336e703ff70138fc)
In step 2, you use the Get-PackageProvider cmdlets to display the currently installed package providers:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/9f35f51d-6aa9-4e7c-9379-73a7aea29a84.png?sign=1739288708-HsoB2uztGq7jXAMWTbGWjpOzRDGffgvx-0-7f098c372e40bfe9da888f2083e476aa)
In step 3, you use Get-Package with the -ProviderName parameter to review packages installed via the msi, msu, and Programs package providers:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/84050261-3e34-4f1f-8648-8f15b5620b24.png?sign=1739288708-5gndhcpgEp67XLy62R6n9XlwG5vaAExq-0-e20b9ba9d44cd02f5782305a87dee6ae)
In step 4, review the NuGet provider:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/1bef9cf9-bc4a-45b8-8bf1-9521a900da54.png?sign=1739288708-gVyVPOmVf2wdFARe8gW5CW1S3iWjHpkD-0-5abddccbcfdfd3edae5cb978cb03ced4)
In step 5, search for other package providers:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/2687924a-c1f6-495e-9c3c-6ccccb707863.png?sign=1739288708-W8F3lZWtFcSkVF0SAqtsEbs2cME0y6d4-0-a27c9ae73ff616cb050b306dd8ddc56c)
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):
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/406c7f4f-a0db-466a-8fe4-dbc925cc1483.png?sign=1739288708-2wv59tCMbDHhgpm83DkER6T6H3lVtTnX-0-e42e1bc91c7f9907d103c24d2c542632)
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:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/23b62105-6df4-4454-921c-0bfdce5c3c51.png?sign=1739288708-lVGuzALjL37dfO1iDxeNWo9UMCLBIDJq-0-fa3ac781d0a4f0f89882ab6658493941)
In step 8, retrieve a list of available software packages from the ChocolateyPackageProvider, store as a variable, and count the available packages:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/5d06c885-f9bc-42ed-ac0a-5c444d0f7585.png?sign=1739288708-5fLHuWgrKjDE35D1o7BJ9A1gUWoHIm2o-0-a69837da035d16a7971197d608d4d78a)
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:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/4680f2cd-a69c-445e-bb65-f9b09c55dc07.png?sign=1739288708-d8aCVOqPhYvt4c1OcaHMFQwm9YXbesS5-0-99247542297c364690d8fa1678ba6235)
In step 10, you install this package (or any package you choose):
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/d2defcf3-1f61-46ac-a32a-ee35f0ce3eae.png?sign=1739288708-R8mh9bOYcankCSlMtXsE1C53SonKGN80-0-dca0779dc84f34bb0004941010e89b0c)
In step 11, you review the installed Chocolatey packages, and the files contained within the sysinternals package folder:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/71f86785-5d46-483a-a184-30b1da82923c.png?sign=1739288708-N1Uudb3YstIwOL8OxcOpNFOpvqwdr6Ys-0-ca8e7574a41901ae4b100bf4a79f1617)
In step 12, run any Sysinternals command, for example, PsInfo.Exe :
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/3839e225-1424-405a-a8f8-665ca4f72965.png?sign=1739288708-BolsRKk0BvopcKjtGa6Mexq4iqSTT9Tq-0-6e737e37d2f9a66dbfbe7a57d32f9ae3)
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:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/92eef698-30ea-436a-b2e1-2d94dc04b2cb.png?sign=1739288708-5PtsxfoabmBYVXMKOo66O7nVczSSN2h5-0-dd7a5ec5eacfc95e742046c657154069)