PowerShell Functions aka Helpers Reference

Summary

In your Chocolatey packaging, you have the ability to use these functions (and others with Chocolatey's PowerShell Extensions) to work with all aspects of software management. Keep in mind Chocolatey's automation scripts are just PowerShell, so you can do manage anything you want.

NOTE: These scripts are for package scripts, not for use directly in PowerShell. This is in the create packages section, not the using Chocolatey section.

Main Functions

These functions call other functions and many times may be the only thing you need in your chocolateyInstall.ps1 file.

Error / Success Functions

You really don't need a try catch with Chocolatey PowerShell files anymore.

More Functions

Administrative Access Functions

When creating packages that need to run one of the following commands below, one should add the tag admin to the nuspec.

Non-Administrator Safe Functions

When you have a need to run Chocolatey without Administrative access required (non-default install location), you can run the following functions without administrative access.

These are the functions from above as one list.

Complete List (alphabetical order)

Variables

There are also a number of environment variables providing access to some values from the nuspec and other information that may be useful. They are accessed via $env:variableName.

Environment Variables

Chocolatey makes a number of environment variables available (You can access any of these with $env:TheVariableNameBelow):

Advanced Environment Variables

The following are more advanced settings:

Set By Options and Configuration

Some environment variables are set based on options that are passed, configuration and/or features that are turned on:

Business Edition Variables

Experimental Environment Variables

The following are experimental or use not recommended:

Not Useful Or Anti-Pattern If Used