Available variables

PowerShell App Deployment Toolkit and Packaging PowerBench variables

The variables in the following table are defined by the PowerShell App Deployment Toolkit and the Package Deployment module of Packaging PowerBench.

Variable name

Description

.\

The so-called "automatic reference", which points to the package directory

appDeployToolkitName

The name of the deployment toolkit, in the context of the PPB always "PSAppDeployToolkit".

appName

The name of the currently executed package.

DeploymentType

Gibt den Deployment-Type an. Mögliche Werte sind "Install", "Uninstall" und "Repair" 

DisableLogging

Gibt an, ob das Logging aktuell deaktiviert ist

installName

Eine Kombination aus Paketname, Plattform, Sprache und Revision (z.B. "MeinPaket_AMD64_de_1")

installPhase

Der Name des Scriptfiles und des DeploymentType (z.B. "Script.ps1/Install")

logName

Name des aktuellen Logfiles, in das die Ausführung des Pakets protokolliert wird


Active Directory variables

The Active Directory variables are declared by the script ADS.Variables.ps1 and have the prefix ADS in the Packaging PowerBench.

Variable name

Description

ADS.DC.Address

Address of the first domain controller found in the domain.

ADS.DC.AddressFamiliy

Families of the address found, e.g. "InterNetwork" for IP addresses.

ADS.DC.AddressType

Type of address found, e.g. "INET" for IP address.

ADS.DC.ClientSite

AD site of the computer on which the command is executed.

ADS.DC.DNSForest

DNS name of the current domain forest.

ADS.DC.Domain

Domain name of the current domain.

ADS.DC.Name

Name of the first domain controller found in the domain.

ADS.DC.Site

AD site of the first domain controller found in the domain.

ADS.DSE.CN.DefaultContext

Canonical Name of the default context in AD.

ADS.DSE.CN.DirectoryServer

Canonical Name of the contacted domain controller.

ADS.DSE.CN.RootDomainController

Canonical Name of the root domain.

ADS.DSE.DN.DefaultContext

Distinguished Name of the default context in AD.

ADS.DSE.DN.DirectoryServer

Distinguished Name of the contacted domain controller.

ADS.DSE.DN.RootDomainController

Distinguished Name of the root domain of the contacted domain controller.

ADS.DSE.LdapServiceName

Kerberos Principal name.

ADS.NODE.DN

Distinguished Name of the local computer in AD.

ADS.NODE.Fullname

The full name of the local computer in AD.

ADS.NODE.Name

The computer name of the local computer in AD.

ADS.NODE.RDN

The Relative Distinguished Name of the local computer in AD.

ADS.SiteName

The name of the current AD site.

ADS.USR.DN

Der Distinguished Name of the current AD user.

ADS.USR.Fullname

The full name of the current AD user.

ADS.USR.RDN

The Relative Distinguished Name of the current AD user.

ADS.USR.Username

The username of the current AD user.


Package variables

The package variables are declared by the script CurrentPackage.Variables.ps1 and have the prefix CurrentPackage in the Packaging PowerBench.

Variable name

Description

CurrentPackage.AppMoniker

The software product that is packaged.

CurrentPackage.Architecture

Determines if this is a package for 32-bit or 64-bit (or both) platforms. Possible values are "X86", "AMD64" and "X86AMD64"

CurrentPackage.CodeFilesToSign

List of code files to sign.

CurrentPackage.Description

Description of the package.

CurrentPackage.DisplayName

Localized name of the package to display during installation.

CurrentPackage.HasUserPart

Setting that indicates whether the package has a user part.

CurrentPackage.Homepage

Link to the the product's homepage.

CurrentPackage.ID

Unique package identifier used for tracking installations and other purposes.

CurrentPackage.Language

Language of the package. Possible values are "de", "en" and "ml" (multilanguage)

CurrentPackage.License

License of the installed product.

CurrentPackage.LicenseUrl

Link to the product's license conditions.

CurrentPackage.Name

Internal name of the package.

CurrentPackage.Revision

Revision of the package used to track installation.

CurrentPackage.RevisionComment

Description and comments of the current package revision.

CurrentPackage.ScriptAuthor

Packaging engineer in charge of the script.

CurrentPackage.ScriptDate

Date of initial package creation.

CurrentPackage.SkipImmediateUserPartExecution

Setting that specifies whether user parts are installed only after logging off and logging on.

CurrentPackage.TemplateIncludePath

Specifies the base directory of the runtime files copied to the package directory.

CurrentPackage.Vendor

The vendor of the software that is packaged.

CurrentPackage.Version

The version of the packaged software product.


Miscellaneous variables

The variables of the following table are declared by the script Misc.Variables.ps1.

Variable name

Description

IP_ADDR

The first found IPv4 address of the current computer.

IP_ADDR_#

All IPv4 addresses of the current computer.

IPV6_ADDR

The first found IPv6 address of the current computer.

IPV6_ADDR_#

All IPv6 addresses of the current computer.

IP_GATEWAY

The first found IPv4 gateway of the current computer.

IP_GATEWAY_#

All IPv4 gateways of the current computer.

IP_MASK

The first found IPv4 subnet mask of the current computer.

IP_MASK_#

All IPv4 subnet masks of the current computer.

MAC_ADDR

The first found MAC address of the current computer.

MAC_ADDR_#

All MAC addresses of the current computer.

IP_DHCP

Flag whether the first IP address found was obtained via DHCP.

IP_DHCP_#

Flag whether the respective IP address was obtained via DHCP.

IP_NAME

IP name of the computer as it is bound to the first network address.

IP_NAME_#

IP name of the computer as it is bound to the respective network address.

MS.ADSITE

Name of the current Active Directory site of the current user.

MS.DOMAIN

Name of the current Active Directory domain of the current user.

MS.FULLNAME

The full name of the current user.

MS.LOGONSERVER

The domain controller that authenticated the current user.

MS.RESDOMAIN

The resource domain of the current user.

MS.SID

The SID of the current user.

MS.USERNAME

The username of the current user.

XFULLNAME

The NT4-compatible full name of the current user.

XNODE

The NT4-compatible name of the current computer.

XUSER

The NT4-compatible user name of the current user.

WINSYSDIR

The full path to the System32 directory.


Shell Folder variables

The following shell folder variables declared in the ShellFOlders.Variables.ps1 script are provided by Windows and contain directory paths for special system folders (see https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder). 

Variable name

Description

ShellFolders.AdminTools

The file system directory that is used to store administrative tools for an individual user.

ShellFolders.ApplicationData

The directory that serves as a common repository for application-specific data for the current roaming user.

ShellFolders.CDBurning

The file system directory that acts as a staging area for files waiting to be written to a CD.

ShellFolders.CommonAdminTools

The file system directory that contains administrative tools for all users of the computer.

ShellFolders.CommonApplicationData

The directory that serves as a common repository for application-specific data that is used by all users.

ShellFolders.CommonDesktopDirectory

The file system directory that contains files and folders that appear on the desktop for all users.

ShellFolders.CommonDocuments

The file system directory that contains documents that are common to all users.

ShellFolders.CommonMusic

The file system directory that serves as a repository for music files common to all users.

ShellFolders.CommonOemLinks

This value is recognized in Windows Vista and later for backward compatibility, but the special folder itself is no longer used.

ShellFolders.CommonPictures

The file system directory that serves as a repository for image files common to all users.

ShellFolders.CommonProgramFiles

The directory for components that are shared across applications.

ShellFolders.CommonProgramFilesX86

The Program Files folder.

ShellFolders.CommonPrograms

A folder for components that are shared across applications.

ShellFolders.CommonStartMenu

The file system directory that contains the programs and folders that appear on the Start menu for all users.

ShellFolders.CommonStartup

The file system directory that contains the programs that appear in the Startup folder for all users.

ShellFolders.CommonTemplates

The file system directory that contains the templates that are available to all users.

ShellFolders.CommonVideos

The file system directory that serves as a repository for video files common to all users.

ShellFolders.Cookies

The directory that serves as a common repository for Internet cookies.

ShellFolders.Desktop

The logical Desktop rather than the physical file system location.

ShellFolders.DesktopDirectory

The directory used to physically store file objects on the desktop.

ShellFolders.Favorites

The directory that serves as a common repository for the user's favorite items.

ShellFolders.Fonts

A virtual folder that contains fonts.

ShellFolders.History

The directory that serves as a common repository for Internet history items.

ShellFolders.InternetCache

The directory that serves as a common repository for temporary Internet files.

ShellFolders.LocalApplicationData

The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.

ShellFolders.LocalizedResources

The file system directory that contains localized resource data.

ShellFolders.MyComputer

The My Computer folder.

ShellFolders.MyDocuments

The My Documents folder.

ShellFolders.MyMusic

The My Music folder.

ShellFolders.MyPictures

The My Pictures folder.

ShellFolders.MyVideos

The file system directory that serves as a repository for videos that belong to a user.

ShellFolders.NetworkShortcuts

A file system directory that contains the link objects that may exist in the My Network Places virtual folder.

ShellFolders.Personal

The directory that serves as a common repository for documents.

ShellFolders.PrinterShortcuts

The file system directory that contains the link objects that can exist in the Printers virtual folder.

ShellFolders.ProgramFiles

The program files directory.

ShellFolders.ProgramFilesX86

The x86 Program Files folder.

ShellFolders.Programs

The directory that contains the user's program groups.

ShellFolders.Recent

The directory that contains the user's most recently used documents.

ShellFolders.Resources

The file system directory that contains resource data.

ShellFolders.SendTo

The directory that contains the Send To menu items.

ShellFolders.StartMenu

The directory that contains the Start menu items.

ShellFolders.Startup

The directory that corresponds to the user's Startup program group.

ShellFolders.System

The System directory.

ShellFolders.SystemX86

The Windows System folder.

ShellFolders.Templates

The directory that serves as a common repository for document templates.

ShellFolders.UserProfile

The user's profile folder.

ShellFolders.Windows

The Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables.


Environment variables

The environment variables of your Windows installation that are defined in the PowerShell drive Env: are also available in the Packaging PowerBench. Which variables are defined on your system depends on your environment. The table below lists the environment variables commonly available on Windows 10 clients. For referencing purposes, prefix the name of the variable with the drive name Env:.

Variable name

Description

Env:ALLUSERSPROFILE

The full path of the All Users profile directory, which contains default profile information shared by every user.

Env:APPDATA

Location of AppData hidden folder, used by some installed programs to store user application data.

Env:CommonProgramFiles

Location of the Common Files directory. This folder contains files for common programs and utilities on a computer, mostly system and services related.

Env:CommonProgramFiles(x86)

Location of the Common Files directory used by 32-bit programs. Only used in 64-bit versions of Windows.

Env:CommonProgramW6432

Only used in 64-bit versions of Windows.

Env:COMPUTERNAME

The name of your computer, as set in Control Panel > System > Computer Name.

Env:ComSpec

Location of the default command interpreter.

Env:HOMEDRIVE

The drive letter assigned to the volume which contains your user profiles.

Env:HOMEPATH

The path, minus the drive letter, of the current user's profile directory.

Env:LOCALAPPDATA

Location of the Local subfolder of AppData, used by some installed programs to store user data. Common temporary files to be stored here are desktop themes, Windows error reporting, program caching and Internet browser profiles.

Env:LOGONSERVER

The network location of the logon server.

Env:NUMBER_OF_PROCESSORS

Number of processor cores (doubled when hyperthreading is activated)

Env:OS

Contains "Windows_NT" for all actual Windows operating systems

Env:Path

List of paths, delimited by a semicolon, to be automatically searched for files. Specifically, files with an extension listed in %PATHEXT% are looked for in %PATH% if they are not found in the current directory. Paths are searched in the order listed.

Env:PATHEXT

Files with these extensions, if not found in the current directory, are looked for in %PATH%.

Env:PROCESSOR_ARCHITECTURE

Abbreviation of the processor architecture (AMD64 oder X86)

Env:PROCESSOR_IDENTIFIER

Identifier of the processor

Env:PROCESSOR_LEVEL

Level of the processor

Env:PROCESSOR_REVISION

Revision of the processor

Env:ProgramData

Location of the ProgramData hidden folder, used by some installed programs to store user data.

Env:ProgramFiles

Location of the Program Files directory, the default location of installed programs. On 64-bit versions of Windows, this directory is the default location of 64-bit programs.

Env:ProgramFiles(x86)

The default location of 32-bit programs. This variable is only present in 64-bit versions of Windows.

Env:ProgramW6432

This variable is used by the WOW64 emulation layer, and is only present in 64-bit versions of Windows.

Env:PSModulePath

Location of modules used by Windows PowerShell.

Env:PUBLIC

Location of the Public user profile.

Env:SESSIONNAME

When logging on directly to machine, returns "Console". When client connects via terminal server session, is combination of connection name, followed by pound symbol {#} and session number.

Env:SystemDrive

The drive letter of the volume where Windows is installed.

Env:SystemRoot

The directory containing the Windows system.

Env:TEMP

The default location of temporary files. The files located in this directory can be deleted periodically to help improve computer performance.

Env:TMP

The default location of temporary files. The files located in this directory can be deleted periodically to help improve computer performance.

Env:USERDOMAIN

The domain of where the current user belongs.

Env:USERDOMAIN_ROAMINGPROFILE

The network domain name associated with the current roaming profile.

Env:USERNAME

The username of the current user

Env:USERPROFILE

The path to the current user's profile directory where the current logged in user's profile data is stored.

Env:windir

A modern equivalent of/replacement for %SystemRoot%. This directory is where Windows will install.


PowerShell variables

The variables in the following table are defined directly by PowerShell and are available in the PPB. Which variables exactly are available depends on the PowerShell version you have installed. The list below refers to PowerShell 5.1.

Variable name

Description

$

Contains the last token in the last line received by the session.

?

Contains the execution status of the last command. It contains True if the last command succeeded and False if it failed.

^

Contains the first token in the last line received by the session.

ConfirmPrefence

Determines whether PowerShell automatically prompts you for confirmation before running a cmdlet or function.

ConsoleFileName

Contains the path of the console file (.psc1) that was most recently used in the session.

DebugPreference

Determines how PowerShell responds to debugging messages generated by a script, cmdlet or provider, or by a Write-Debug command at the command line.

Error

Contains an array of error objects that represent the most recent errors.

ErrorActionPreference

Determines how PowerShell responds to a non-terminating error, an error that doesn't stop the cmdlet processing.

ErrorView

Contains the value controlling the view in which errors are displayed.

ExecuctionContext

Contains an EngineIntrinsics object that represents the execution context of the PowerShell host.

false

Contains False. You can use this variable to represent False in commands and scripts instead of using the string "false"

FormatEnumerationLimit

Determines how many enumerated items are included in a display.

HOME

Contains the full path of the user's home directory. 

Host

Contains an object that represents the current host application for PowerShell.

InformationPreference

The ${InformationPreference} variable lets you set information stream preferences that you want displayed to users.

MaximumAliasCount

Determines how many aliases are permitted in a PowerShell session.

MaximumDriveCount

Determines how many PowerShell drives are permitted in a given session.

MaximumErrorCount

Determines how many errors are saved in the error history for the session.

MaximumFunctionCount

Determines how many functions are permitted in a given session.

MaximumHistoryCount

Determines how many commands are saved in the command history for the current session.

MaximumVariableCount

Determines how many variables are permitted in a given session, including automatic variables, preference variables, and the variables that you create in commands and scripts.

NestedPromptLevel

Contains the current prompt level. A value of 0 indicates the original prompt level.

null

${null} is an automatic variable that contains a null or empty value. You can use this variable to represent an absent or undefined value in commands and scripts.

OutputEncoding

Determines the character encoding method that PowerShell uses when it sends text to other applications.

PID

Contains the process identifier (PID) of the process that is hosting the current PowerShell session.

ProgressPreference

Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by the Write-Progress cmdlet.

PSCommandPath

Contains the full path and file name of the script that's being run.

PSCulture

Beginning in PowerShell 7, ${PSCulture} reflects the culture of the current PowerShell runspace (session). 

PSDefaultParameterValues

Specifies default values for the parameters of cmdlets and advanced functions. 

PSEdition

In PowerShell 5.1 and above, you can find out what edition you are running with the $PSEdition automatic variable.

PSEmailServer

Specifies the default e-mail server that is used to send email messages.

PSHOME

Contains the full path of the installation directory for PowerShell, typically, $env:windir\System32\PowerShell\v1.0 in Windows systems.

PSScriptRoot

Contains the full path of the executing script's parent directory.

PSSessionApplicationName

Specifies the default application name for a remote command that uses Web Services for Management (WS-Management) technology.

PSSessionConfigurationName

Specifies the default session configuration that is used for PSSessions created in the current session.

PSSessionOption

Establishes the default values for advanced user options in a remote session.

PSUICulture

Contains the name of the user interface (UI) culture that's currently in use in the operating system.

PSVersionTable

Contains a read-only hash table that displays details about the version of PowerShell that is running in the current session.

PWD

Contains a path object that represents the full path of the current directory location for the current PowerShell runspace.

ShellId

Contains the identifier of the current shell.

StackTrace

Contains a stack trace for the most recent error.

true

Contains True. You can use this variable to represent True in commands and scripts.

VerbosePreference

Determines how PowerShell responds to verbose messages generated by a script, cmdlet, or provider, such as the messages generated by the Write-Verbose cmdlet.

WarningPreference

Determines how PowerShell responds to warning messages generated by a script, cmdlet, or provider, such as the messages generated by the Write-Warning cmdlet.

WhatIfPreference

Determines whether WhatIf is automatically enabled for every command that supports it.