Installing choco apps is just as easy as the searching. You can install one app at a time or multiple. You can always use the ChocolateyGUI app from the previous section but I want to show you the command line ways. Here are a couple ways to do it:
One at a time:
choco install packagename -y
Notice the -y at the end. If you don’t add that you will need to accept the install. Another switch that can be added is -f. If you add that switch it will force install the app even if its installed. Meaning it will reinstall what is already installed. I have mixed luck with that so keep it in mind that it depends on the app if you can use the -f switch.
Multiple apps at a time in one line:
choco install package1 package2 package3 -y
This method works fine but I have found that if you have more than a few apps the command gets a little long. I have another method for installing multiple apps using an array to hold the package names instead. It just looks better when you have a larger list of apps and is easier the change out apps as needed. Here is the one is use:
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
#List packages you want to install
$packages = (
"chocolateygui",
"googlechrome",
"notepadplusplus",
"vlc",
"winscp",
"nmap",
"autoit",
"7zip",
"putty",
"git",
"vscode",
"openvpn",
"vim",
"mobaxterm",
"adobereader",
"rsat",
"wireshark",
"mousewithoutborders",
"forticlientvpn",
"microsoft-teams",
"Office365Business"
)
#Loop through the packages
foreach ($package in $packages){
#Instal each package and force a reinstall if its already there
choco install $package -y -f
}
As you can see you can pretty much get all of your normal apps installed in one script. That top line is something I add to a lot a scripts that I plan on running from the actual .ps1 file. The line will check to see if the powershell session is running as admin and will reopen it as admin if not.