{"id":793,"date":"2014-08-23T00:01:00","date_gmt":"2014-08-23T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/08\/23\/weekend-scripter-powershell-and-chocolatey\/"},"modified":"2014-08-23T00:01:00","modified_gmt":"2014-08-23T00:01:00","slug":"weekend-scripter-powershell-and-chocolatey","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-powershell-and-chocolatey\/","title":{"rendered":"Weekend Scripter: PowerShell and Chocolatey"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Guest blogger and Honorary Scripting Guy, June Blender, talks about using Windows PowerShell and Chocolatey.<\/span><\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today, I welcome back guest blogger, <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/tag\/june-blender\/\" target=\"_blank\">June Blender<\/a>.<\/p>\n<p>I&rsquo;m probably one of five people on earth who really do not like chocolate, so I wasn&rsquo;t too keen to learn about something called &ldquo;Chocolatey.&rdquo; But I kept hearing about Chocolatey and other &ldquo;package installers,&rdquo; such as NuGet, and I wanted to know what all of the fuss was about. Then along comes Windows PowerShell&nbsp;5.0 Preview with a module called OneGet that works with Chocolatey. It was clearly past time to figure it out.<\/p>\n<h2>What&rsquo;s a package installer?<\/h2>\n<p><i>Package installers<\/i> install programs and groups of related programs called <i>packages<\/i>. In this guise, they&rsquo;re not much different than an EXE or MSI file. But unlike simple installers, package installers also know about <i>dependencies<\/i>, which are other programs that the to-be-installed program requires, and they&rsquo;ll install any missing dependencies for you automatically. Beyond that, they solve easy problems, such as expanding zip files and installing tools in a consistent place. They can also solve very difficult installation problems for you, including installing programs on your computer that are designed for a different platform or operating system.<\/p>\n<p>This last feature is truly the most appealing. I took a great Android app programming class from Coursera called <a href=\"https:\/\/www.coursera.org\/course\/androidapps101\" target=\"_blank\">Creative, Serious, and Playful Science of Android Apps<\/a>. It&rsquo;s a terrific class, and I really recommend it. For me, the most difficult part of the class was installing the programming tools on my PC, which is running Windows, because they&rsquo;re designed for an iOS or UNIX platform. I had to install five tools to install the tools that I needed. These include a tool to unzip (or whatever) TGZ files, appropriately called &ldquo;tarballs.&rdquo; Well-designed package installers handle this mess for you.<\/p>\n<p>Package installers are also great for open-source collaborative projects, like those on GitHub. Contributors can collect their files into packages and submit the package in a pull request. When other contributors clone the project, they can use the package installer to install all of the contributed pieces.<\/p>\n<h2>What&rsquo;s Chocolatey?<\/h2>\n<p>Chocolatey is a package installer that&rsquo;s designed especially for working with Windows PowerShell. You can learn all about Chocolatey at the <a href=\"https:\/\/chocolatey.org\/\" target=\"_blank\">Chocolatey Gallery<\/a> site. Chocolatey is also an open-source project. You can view and contribute to the Chocolatey source at <a href=\"https:\/\/github.com\/chocolatey\" target=\"_blank\">Chocolatey GitHub<\/a>.<\/p>\n<p>You can use Windows PowerShell to script Chocolatey installations, but you can also use the search feature on the pretty <a href=\"https:\/\/chocolatey.org\/packages\" target=\"_blank\">Chocolatey Packages<\/a> website:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-8-23-14-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-8-23-14-1.png\" alt=\"Image of website\" title=\"Image of website\" \/><\/a><\/p>\n<h2>What&rsquo;s OneGet?<\/h2>\n<p>OneGet is a Windows PowerShell module that is included in Windows Management Framework&nbsp;5.0 Preview. The cmdlets in the module manage packages, including those on the Chocolatey site. They find packages, get installed packages, get the source of a package, and uninstall packages, among other things.&nbsp;<\/p>\n<p>OneGet includes Windows PowerShell cmdlets with names like <b>Find-Package<\/b>, <b>Get-Package<\/b>, and <b>Install-Package<\/b>. The preview version gets only Chocolatey packages, but I bet that will change. Also, the preview version doesn&rsquo;t yet have Help files, although it&rsquo;s set up for updatable Help. Again, we&rsquo;ll probably see those when the full product is released.<\/p>\n<h2>Installing OneGet and\/or Chocolatey<\/h2>\n<p>You can install OneGet or Chocolatey or both. They&rsquo;re completely independent, and they don&rsquo;t require each other.<\/p>\n<p>You can install Windows Management Framework&nbsp;5.0 Preview (with OneGet) from the Microsoft Download Center: <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42936\" target=\"_blank\">Windows Management Framework 5.0 Preview May 2014<\/a>.<\/p>\n<p>To install Chocolatey, run the <a href=\"https:\/\/chocolatey.org\/install.ps1\" target=\"_blank\">Install.ps1 script<\/a> from the Chocolatey website (inspect it first):<\/p>\n<ol start=\"1\">\n<li>Start Windows PowerShell with the &ldquo;Run as administrator&rdquo; option.<\/li>\n<li>At the Windows PowerShell prompt, run the following command. It starts a web-based script (Install.ps1), which installs Chocolatey. You don&rsquo;t need to replace any values.<\/li>\n<\/ol>\n<p style=\"margin-left:30px\">Invoke-Expression ((New-Object System.Net.WebClient).DownloadString(&#039;https:\/\/chocolatey.org\/install.ps1&#039;))<\/p>\n<h2>Try OneGet!<\/h2>\n<p>Let&rsquo;s play with the OneGet module so we have a sense of how it works.<\/p>\n<h4><b>Find-Package cmdlet<\/b><\/h4>\n<p>The <b>Find-Package<\/b> cmdlet gets information about all available packages. It returns a <b>SoftwareIdentity<\/b> object (Microsoft.OneGet.Core.Packaging.SoftwareIdentity) for each package.<\/p>\n<p>Be patient. The cmdlet can take a full minute to run because it&rsquo;s getting data from a website.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/ws-8-23-14-2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/ws-8-23-14-2.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>In the preview, the source is always &ldquo;Chocolatey&rdquo; and the status is always &ldquo;Available,&rdquo; but it&rsquo;s only a preview.<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package | Group-Object &ndash;Property Source<\/p>\n<p style=\"margin-left:30px\">Count Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Group<\/p>\n<p style=\"margin-left:30px\">&#8212;&#8211; &#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211;<\/p>\n<p style=\"margin-left:30px\">&nbsp;2050 chocolatey&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Microsoft.OneGet.Core.Packaging.SoftwareIdentity, Mi<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package | Group-Object &ndash;Property Status<\/p>\n<p style=\"margin-left:30px\">Count Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Group<\/p>\n<p style=\"margin-left:30px\">&#8212;&#8211; &#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211;<\/p>\n<p style=\"margin-left:30px\">&nbsp;2050 Available&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {Microsoft.OneGet.Core.Packaging.SoftwareIdentity, Mi<\/p>\n<p>You can use the <b>Name<\/b> parameter of <b>Find-Package<\/b> to filter by package name. You can enter part of the package name, but this cmdlet does not support wildcard characters. Cmdlets that launch REST APIs (web page queries) rarely do.<\/p>\n<p>This command gets packages with names that include <b>Autorun<\/b>:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package -Name Autorun<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">Name&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Version&nbsp;&nbsp; Status&nbsp;&nbsp;&nbsp; Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">AutoRuns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Available chocolatey&nbsp;&nbsp;&nbsp;&nbsp; Shows what programs are<\/p>\n<p style=\"margin-left:30px\">AutorunscPortable&nbsp; 12.0.0.0&nbsp; Available chocolatey<\/p>\n<p style=\"margin-left:30px\">AutorunsPortable&nbsp;&nbsp; 12.0.0.0&nbsp; Available chocolatey<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package -Name Autorun*<\/p>\n<p style=\"margin-left:30px\">WARNING: No Package Found:Autorun*<\/p>\n<p>The <b>SoftwareIdentity<\/b> object includes useful information about the package. This command gets the Autoruns package and formats all (<b>*<\/b>) of its properties in a list:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package -Name Autoruns | Format-List -Property *<\/p>\n<p style=\"margin-left:30px\">ProviderName&nbsp; : Chocolatey<\/p>\n<p style=\"margin-left:30px\">Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : chocolatey<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : AutoRuns<\/p>\n<p style=\"margin-left:30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 12.0<\/p>\n<p style=\"margin-left:30px\">VersionScheme : semver<\/p>\n<p style=\"margin-left:30px\">Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Available<\/p>\n<p style=\"margin-left:30px\">Summary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Shows what programs are configured to run during system bootup or login<\/p>\n<h4><b>Install-Package cmdlet<\/b><\/h4>\n<p>To install a package, use the <b>Install-Package<\/b> cmdlet. You can also pipe a <b>Find-Package<\/b> command to the <b>Install-Package<\/b> cmdlet.<\/p>\n<p>I use the parameters of the <b>Find-Package<\/b> cmdlet to create a command that gets only the package that I want to install. Then, I pipe it to <b>Install-Package<\/b>. I use the <b>Verbose<\/b> parameter to see where the package is installed.<\/p>\n<p><b>&nbsp; &nbsp;Note<\/b>&nbsp;&nbsp;To see all parameters of <b>Find-Package<\/b>, type: Get-Command Find-Package &ndash;Syntax.<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package -Name Autoruns -RequiredVersion 12.0<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp; Status&nbsp;&nbsp;&nbsp; Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">AutoRuns 12.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Available chocolatey&nbsp;&nbsp;&nbsp;&nbsp; Shows what programs are configured&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package -Name Autoruns -RequiredVersion 12.0 | Install-Package -Verbose<\/p>\n<p>The <b>Install-Package<\/b> cmdlet prompts me to verify that I trust the package and then installs it. It begins by installing a ZIP file in a temporary directory in my user profile. Then it unzips the file and installs it in a C:\\chocolatey directory.<\/p>\n<p style=\"margin-left:30px\">PS C:\\ps-test&gt; Find-Package -Name Autoruns -RequiredVersion 12.0 | Install-Package &ndash;Verbose<\/p>\n<p style=\"margin-left:30px\">Installing Package &#039;AutoRuns&#039; from untrusted source<\/p>\n<p style=\"margin-left:30px\">WARNING: This package source is not marked as safe. Are you sure you want to install software from &#039;chocolatey&#039;<\/p>\n<p style=\"margin-left:30px\">[Y] Yes&nbsp; [N] No&nbsp; [S] Suspend&nbsp; [?] Help (default is &quot;Y&quot;): y<\/p>\n<p style=\"margin-left:30px\">VERBOSE: Performing the operation &quot;Install Package&quot; on target &quot;AutoRuns&quot;.<\/p>\n<p style=\"margin-left:30px\">VERBOSE: NuGet:Installing &#039;AutoRuns 12.0&#039;.<\/p>\n<p style=\"margin-left:30px\">VERBOSE: NuGet:Successfully installed &#039;AutoRuns 12.0&#039;.<\/p>\n<p style=\"margin-left:30px\">VERBOSE: InstallChocolateyZipPackage:AutoRuns<\/p>\n<p style=\"margin-left:30px\">VERBOSE: CreateFolder<\/p>\n<p style=\"margin-left:30px\">Success:C:\\Users\\juneb\\AppData\\Local\\Temp\\Microsoft.OneGet.Utility\\11\\chocolatey\\AutoRuns<\/p>\n<p style=\"margin-left:30px\">VERBOSE: GetChocolateyWebFile:AutoRuns =&gt; http:\/\/download.sysinternals.com\/files\/Autoruns.zip<\/p>\n<p style=\"margin-left:30px\">VERBOSE: Downloading:&#039;http:\/\/download.sysinternals.com\/files\/Autoruns.zip&#039; to<\/p>\n<p style=\"margin-left:30px\">&#039;C:\\Users\\juneb\\AppData\\Local\\Temp\\Microsoft.OneGet.Utility\\11\\chocolatey\\AutoRuns\\AutoRunsinstall.zip&#039;<\/p>\n<p style=\"margin-left:30px\">VERBOSE:<\/p>\n<p style=\"margin-left:30px\">GetChocolateyUnzip:C:\\Users\\juneb\\AppData\\Local\\Temp\\Microsoft.OneGet.Utility\\11\\chocolatey\\AutoRuns\\AutoRunsinstall.zi<span style=\"font-size:12px\">p<\/span><\/p>\n<p style=\"margin-left:30px\">VERBOSE: CreateFolder &#8212; C:\\Chocolatey\\lib\\AutoRuns.12.0<\/p>\n<p style=\"margin-left:30px\">VERBOSE: Taking Snapshot:C:\\Chocolatey\\lib\\AutoRuns.12.0\\Tools<\/p>\n<p style=\"margin-left:30px\">VERBOSE: CreateFolder &#8212; C:\\Chocolatey\\lib\\AutoRuns.12.0\\Tools<\/p>\n<p style=\"margin-left:30px\">VERBOSE: Diffing Snapshot:C:\\Chocolatey\\lib\\AutoRuns.12.0\\Tools<\/p>\n<p style=\"margin-left:30px\">VERBOSE: Package Successfully Installed:AutoRuns<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp; Status&nbsp;&nbsp;&nbsp; Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">AutoRuns 12.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Available chocolatey&nbsp;&nbsp;&nbsp;&nbsp; Shows what programs are configured&#8230;<\/p>\n<p>To indicate that the installation was successful, <b>Install-Package<\/b> returns a <b>SoftwareIdentity<\/b> object that represents the package that it installed. You can use this feature in a script that includes a package installation, for example:<\/p>\n<p style=\"margin-left:30px\">if (Get-Package Autoruns | Install-Package) { &lt;do the next thing&gt; }<\/p>\n<p>-or-<\/p>\n<p style=\"margin-left:30px\">Foreach ($pkg in $packages)<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">$result = Install-Package -Name $pkg<\/p>\n<p style=\"margin-left:30px\">if ($result.Name &ndash;eq $pkg) {&lt;do the next thing&gt;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<h4><b>Get-Package cmdlet<\/b><\/h4>\n<p>To get all packages that the OneGet cmdlets installed, use the <b>Get-Package<\/b> cmdlet. (<b>Get-Package<\/b> gets only packages that <b>Install-Package<\/b> installed. It does not get packages that you install by other means, including Chocolatey.<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt;Get-Package<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp; Status&nbsp;&nbsp;&nbsp; Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">AutoRuns 12.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Available chocolatey&nbsp;&nbsp;&nbsp;&nbsp; Shows what programs are configured&#8230;<\/p>\n<p>To run the package, at the Windows PowerShell prompt, type <b>Autoruns<\/b>. (You can also use the Start page, Start menu, or Run box.) The starting method might differ for other tools.&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>To uninstall the package, use the <b>Uninstall-Package<\/b> cmdlet. I&rsquo;ve installed and uninstalled packages repeatedly without any errors, so test away!<\/p>\n<h2>Try Chocolatey!<\/h2>\n<p>Now let&rsquo;s try Chocolatey.<\/p>\n<p>To install Chocolatey when you have the OneGet module, use the <b>Install-Package<\/b> cmdlet:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package &ndash;Name Chocolatey<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">chocolatey&nbsp; 0.9.8.28-alpha2&nbsp; Available&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chocolatey&nbsp;&nbsp;&nbsp;&nbsp; Chocolatey is your machine level N&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Find-Package &ndash;Name Chocolatey | Install-Package -Verbose<\/p>\n<p>I&rsquo;ll use Windows PowerShell to run the Chocolatey commands, but you do not need to have Windows PowerShell or OneGet to run the commands. You can use the website or the native or GUI Chocolatey clients.<\/p>\n<p>When you review the Chocolatey commands, you&rsquo;ll notice immediately that the command names don&rsquo;t have the familiar verb-noun format of cmdlets. And <b>Get-Help<\/b> won&rsquo;t help you with these commands. The following Chocolatey wiki is useful: <a href=\"https:\/\/github.com\/chocolatey\/chocolatey\/wiki\/CommandsReference\" target=\"_blank\">Command Reference<\/a>.<\/p>\n<p>To run Chocolatey commands without warnings, you must start Windows PowerShell with the &ldquo;Run as administrator&rdquo; option (also known as &ldquo;elevated&rdquo;).<\/p>\n<p>To search for a package (the equivalent of <b>Find-Package<\/b>), use the <b>List<\/b> or <b>Search <\/b>commands. These commands are aliases of each other, and they can be used interchangeably.<\/p>\n<p>For example, to search for the Autoruns tool, type:<\/p>\n<p style=\"margin-left:30px\">[ADMIN] PS C:\\&gt; choco list Autoruns<\/p>\n<p style=\"margin-left:30px\">AutoRuns 12.0<\/p>\n<p>Again, you can type part of the name of the tool you&rsquo;re searching for, such as <b>choco list Auto<\/b>, but you cannot use wildcard characters.<\/p>\n<p style=\"margin-left:30px\">[ADMIN] PS C:&gt; choco search Autorun<\/p>\n<p style=\"margin-left:30px\">AutoRuns 12.0<\/p>\n<p style=\"margin-left:30px\">AutorunsPortable 12.0.0.0<\/p>\n<p style=\"margin-left:30px\">AutorunscPortable 12.0.0.0<\/p>\n<p style=\"margin-left:30px\">bitdefender-usb-immunizer 2.0.1.90<\/p>\n<p style=\"margin-left:30px\">cmdaliases 1.0.0.1<\/p>\n<p>The <b>List<\/b> and <b>Search<\/b> commands search all fields for the <b>Autorun<\/b> phrase, not only the name field. In this case, the description of the cmdaliases tool includes &ldquo;autorun.&rdquo; Also, the Chocolatey commands return strings of the package names. They don&rsquo;t return <b>SoftwareIdentity<\/b> objects.&nbsp;<\/p>\n<p>To install a package, use the <b>choco install<\/b> or <b>cinst<\/b> command. The following command installs the Autoruns tool.<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; choco install Autoruns<\/p>\n<p>Chocolatey doesn&rsquo;t have a command like <b>Get-Package<\/b>, but it does have commands to uninstall packages and get the source code for the package.<\/p>\n<h2>Using OneGet and Chocolatey together<\/h2>\n<p>You can use both OneGet and Chocolatey. However, in OneGet preview and the current incarnation of Chocolatey, they&rsquo;re not aware of each other. For example, <b>Get-Package<\/b> gets only the packages that <b>Install-Package<\/b> installs. It doesn&rsquo;t get the packages that Chocolatey installs.<\/p>\n<p>The installation location might vary with the package that you install, but Chocolatey installs the Autoruns tool in a different place than <b>Install-Package<\/b> installs it. If you use both, the installations are independent. This isn&rsquo;t a problem for a simple tool like Autoruns, but it might create problems for more complex packages.<\/p>\n<p style=\"margin-left:30px\">OneGet: C:\\Chocolatey\\lib\\AutoRuns.12.0\\Tools\\Autoruns.exe<\/p>\n<p style=\"margin-left:30px\">Chocolatey: C:\\ProgramData\\chocolatey\\lib\\AutoRuns.12.0\\Tools<\/p>\n<h2>Is Find-Package temporary?<\/h2>\n<p>One more hint before you start scripting.&nbsp;<\/p>\n<p>The <b>Find-Package<\/b> command gets data from a website (or websites) where the data changes frequently. The results of <b>Find-Package<\/b> time out, even if you save them in a variable. If you save the output for more than a few minutes, it disappears.<\/p>\n<p>For example, if you save the results of the <b>Find-Package<\/b> cmdlet in an <b>$a<\/b> variable, you can display the value of <b>$a<\/b> as usual. But if you wait a few minutes and repeat the command that displays the value of <b>$a<\/b>, the value is gone!<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; $a = Find-Package<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; $a | Format-Table &ndash;Property Name, Summary -Autosize<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">1password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1Password &#8211; Have you ever forgotten a password?<\/p>\n<p style=\"margin-left:30px\">7zip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7-Zip is a file archiver with a high compression<\/p>\n<p style=\"margin-left:30px\">7zip.commandline&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7-Zip is a file archiver with a high compression<\/p>\n<p style=\"margin-left:30px\">7zip.install&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7-Zip is a file archiver with a high compression<\/p>\n<p style=\"margin-left:30px\">ack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ack is a tool like grep, designed<\/p>\n<p style=\"margin-left:30px\">acr<\/p>\n<p style=\"margin-left:30px\">ActiveMQ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Apache ActiveMQ is a messaging and integration server<\/p>\n<p style=\"margin-left:30px\">ActivePerl&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;ActivePerl is the leading commercial-grade ActivePerl-EqEmu-x86&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ActivePerl-EqEmu-x86<\/p>\n<p style=\"margin-left:30px\">ActiveTcl<\/p>\n<p>Wait 3 minutes&#8230;<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; $a | Format-Table -Property Name, Summary -Autosize<\/p>\n<p style=\"margin-left:30px\">Name Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;- &#8212;&#8212;-<\/p>\n<p>The objects are still there, but their content is missing.<\/p>\n<p style=\"margin-left:30px\">PS C:\\ps-test&gt; $a | Get-Member<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; TypeName: Microsoft.OneGet.Core.Packaging.SoftwareIdentity<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType Definition<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">CreateObjRef&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)<\/p>\n<p style=\"margin-left:30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object obj)<\/p>\n<p style=\"margin-left:30px\">GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()<\/p>\n<p style=\"margin-left:30px\">GetLifetimeService&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object GetLifetimeService()<\/p>\n<p style=\"margin-left:30px\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; type GetType()<\/p>\n<p style=\"margin-left:30px\">InitializeLifetimeService Method&nbsp;&nbsp;&nbsp;&nbsp; System.Object InitializeLifetimeService()<\/p>\n<p style=\"margin-left:30px\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; string ToString()<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property &nbsp;&nbsp;string Name {get;set;}<\/p>\n<p style=\"margin-left:30px\">ProviderName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; string ProviderName {get;set;}<\/p>\n<p style=\"margin-left:30px\">Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; string Source {get;set;}<\/p>\n<p style=\"margin-left:30px\">Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; string Status {get;set;}<\/p>\n<p style=\"margin-left:30px\">Summary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; string Summary {get;set;}<\/p>\n<p style=\"margin-left:30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; string Version {get;set;}<\/p>\n<p style=\"margin-left:30px\">VersionScheme&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; string VersionScheme {get;set;}<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; $a[0]<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Summary<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;-<\/p>\n<p>You might never encounter this in a script, but if you&rsquo;re playing around in the console, it might surprise you.<\/p>\n<p>Now, go off and have fun. There are some amazing Chocolatey packages. I installed a trial version of my favorite tool, <a href=\"http:\/\/www.red-gate.com\/dynamic\/products\/dotnet-development\/reflector\/download\" target=\"_blank\">.NET Reflector<\/a> from Red Gate Software. And ironically, I installed 7Zip, which unzips any file type, even though I might never need to use it again.<\/p>\n<p>~June<\/p>\n<p>Thanks, June. This is useful and fun. Great job.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><span style=\"font-size:12px\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Guest blogger and Honorary Scripting Guy, June Blender, talks about using Windows PowerShell and Chocolatey. Microsoft Scripting Guy, Ed Wilson, is here. Today, I welcome back guest blogger, June Blender. I&rsquo;m probably one of five people on earth who really do not like chocolate, so I wasn&rsquo;t too keen to learn about something called [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,370,3,61,45],"class_list":["post-793","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-june-blender","tag-scripting-guy","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Guest blogger and Honorary Scripting Guy, June Blender, talks about using Windows PowerShell and Chocolatey. Microsoft Scripting Guy, Ed Wilson, is here. Today, I welcome back guest blogger, June Blender. I&rsquo;m probably one of five people on earth who really do not like chocolate, so I wasn&rsquo;t too keen to learn about something called [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=793"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/793\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}