Skip to main content

Variables

When you start a PSAppDeployToolkit deployment script, a number of helpful variables become available for you to use, ranging from hardware information such as processor architecture and operating system name, system and user paths such as the Program Data folder, and Users' Home Drive, Active Directory Domain details etc.

Toolkit Name

VariableDescription
$appDeployToolkitNameShort-name of toolkit without spaces
$appDeployMainScriptFriendlyNameFull name of toolkit including spaces

Script Info

VariableDescription
$appDeployMainScriptVersionVersion number of the PSAppDeployToolkit
$appDeployMainScriptMinimumConfigVersionMinimum version of the config XML file required by the PSAppDeployToolkit
$appDeployMainScriptDateDate toolkit was last modified
$appDeployMainScriptParametersContains all parameters and values specified when toolkit was launched

Date, Time & Culture

$currentDateTimeCurrent date & time when the PSAppDeployToolkit was launched
$currentTimeCurrent time when toolkit was launched
$currentDateCurrent date when toolkit was launched
$currentTimeZoneBiasTimeZone bias based on the current date / time
$cultureObject which contains all of the current Windows culture settings
$currentLanguageCurrent Windows two letter ISO language name (e.g. EN, FR, DE, JA etc)
$currentUILanguageCurrent Windows two letter UI ISO language name (e.g. EN, FR, DE, JA etc)

Environment Variables

Path examples are for Windows 7 and higher

VariableDescription
$envHostObject that contains details about the current PowerShell console
$envShellFoldersObject that contains properties from registry path: HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
$envAllUsersProfile%ALLUSERSPROFILE%, e.g. C:\ProgramData
$envAppData%APPDATA%, e.g. C:\Users\%USERNAME%\AppData\Roaming
$envArchitecture%PROCESSOR_ARCHITECTURE%, e.g. AMD64/IA64/x86.
Note - This doesn't tell you the architecture of the processor but only of the current process, so it returns "x86" for a 32-bit WOW process running on 64-bit Windows.
$envCommonProgramFiles%COMMONPROGRAMFILES%, e.g. C:\Program Files\Common Files)
$envCommonProgramFilesX86%COMMONPROGRAMFILES(x86)%, e.g. C:\Program Files (x86)\Common Files
$envCommonDesktope.g. C:\Users\Public\Desktop
$envCommonDocumentse.g. C:\Users\Public\Documents
$envCommonStartMenuProgramse.g. C:\ProgramData\Microsoft\Windows\Start Menu\Programs
$envCommonStartMenue.g. C:\ProgramData\Microsoft\Windows\Start Menu
$envCommonStartUpe.g. C:\ProgramData\Microsoft\Windows\Start Menu
$envCommonTemplatese.g. C:\ProgramData\Microsoft\Windows\Templates
$envComputerName$COMPUTERNAME%, e.g. Computer1
$envComputerNameFQDNFully qualified computer name, e.g. computer1.contoso.com
$envHomeDrive%HOMEDRIVE%, e.g. C:
$envHomePath%HOMEPATH%, e.g. C:\Users\%USERNAME%
$envHomeShare%HOMESHARE% (Used instead of HOMEDRIVE if the home folder uses UNC paths.)
$envLocalAppData%LOCALAPPDATA%, e.g. C:\Users\%USERNAME%\AppData\Local
$envLogicalDrivesAn array containing all of the logical drives on the system.
$envProgramFiles%PROGRAMFILES%, e.g. C:\Program Files
$envProgramFilesX86%ProgramFiles(x86)%, e.g. C:\Program Files (x86) (Only on 64 bit. Used to store 32 bit apps.)
$envProgramData%PROGRAMDATA%, e.g. C:\ProgramData
$envPublic%PUBLIC%, e.g. C:\Users\Public
$envSystemDrive%SYSTEMDRIVE%, e.g. C:
$envSystemRAMSystem RAM as an integer
$envSystemRoot%SYSTEMROOT%, e.g. C:\Windows
$envTempChecks for the existence of environment variables in the following order and uses the first path found:
- The path specified by TEMP environment variable, (e.g. C:\Users\%USERNAME%\AppData\Local\Temp).
- The path specified by the USERPROFILE environment variable.
- The Windows root (C:\Windows) folder.
$envUserCookiesC:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\INetCookies
$envUserDesktopC:\Users\%USERNAME%\Desktop
$envUserFavoritesC:\Users\%USERNAME%\Favorites
$envUserInternetCacheC:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\INetCache
$envUserInternetHistoryC:\Users\%USERNAME%\AppData\Local\Microsoft\Windows\History
$envUserMyDocumentsC:\Users\%USERNAME%\Documents
$envUserName%USERNAME%
$envUserProfile%USERPROFILE%, e.g. %SystemDrive%\Users\%USERNAME%
$envUserSendToC:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\SendTo
$envUserStartMenuC:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu
$envUserStartMenuProgramsC:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
$envUserStartUpC:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
$envSystem32DirectoryC:\WINDOWS\system32
$envWinDir%WINDIR%, e.g. C:\Windows

Domain Membership

VariableDescription
$IsMachinePartOfDomainIs machine joined to a domain, e.g. $true/$false
$envMachineWorkgroupIf machine not joined to domain, what is the WORKGROUP it belongs to?
$envMachineADDomainRoot AD domain name for machine, e.g. domain.contoso.com
$envLogonServerFQDN of %LOGONSERVER% used for authenticating logged in user
$MachineDomainControllerFQDN of an AD domain controller used for authentication
$envMachineDNSDomainFull Domain name for machine, e.g. <name>.contoso.com
$envUserDNSDomain%USERDNSDOMAIN%. Root AD domain name for user, e.g. domain.contoso.com
$envUserDomain%USERDOMAIN%, e.g. domain.contoso.com

Operating System

VariableDescription
$envOSObject that contains details about the operating system
$envOSNameName of the operating system (e.g. Microsoft Windows 8.1 Pro)
$envOSServicePackLatest service pack installed on the system (e.g. Service Pack 3)
$envOSVersionFull version number of the OS (e.g. <major>.<minor>.<build>.<revision>)
$envOSVersionMajorMajor portion of the OS version number (e.g. <major>.<minor>.<build>.<revision>)
$envOSVersionMinorMinor portion of the OS version number (e.g. <major>.<minor>.<build>.<revision>)
$envOSVersionBuildBuild portion of the OS version number (e.g. <major>.<minor>.<build>.<revision>)
$envOSVersionRevisionRevision portion of the OS version number (e.g. <major>.<minor>.<build>.<revision>)
$envOSProductTypeOS product type represented as an integer (e.g. 1/2/3)
$IsServerOSIs server OS? (e.g. $true/$false)
$IsDomainControllerOSIs domain controller OS? (e.g. $true/$false)
$IsWorkStationOSIs workstation OS? (e.g. $true/$false)
$envOSProductTypeNameOS product type name (e.g. Server/Domain Controller/Workstation/Unknown)
$Is64BitIs this a 64-bit OS? (e.g. $true/$false)
$envOSArchitectureRepresents the OS architecture (e.g. 32-Bit/64-Bit)

Current Process Architecture

VariableDescription
$Is64BitProcessIs the current process 64-bits? (e.g. $true/$false)
$psArchitectureRepresents the current process architecture (e.g. x86/x64)

PowerShell And CLR (.NET) Vesions

VariableDescription
$envPSVersionTableObject containing PowerShell version details from PS variable $PSVersionTable
$envPSVersionFull version number of PS (e.g. <major>.<minor>.<build>.<revision>)
$envPSVersionMajorMajor portion of PS version number (e.g. <major>.<minor>.<build>.<revision>)
$envPSVersionMinorMinor portion of PS version number (e.g. <major>.<minor>.<build>.<revision>)
$envPSVersionBuildBuild portion of PS version number (e.g. <major>.<minor>.<build>.<revision>)
$envPSVersionRevisionRevision portion of PS version number (e.g. <major>.<minor>.<build>.<revision>)
$envCLRVersionFull version number of .NET used by PS (e.g. <major>.<minor>.<build>.<revision>)
$envCLRVersionMajorMajor portion of PS .NET version number (e.g. <major>.<minor>.<build>.<revision>)
$envCLRVersionMinorMinor portion of PS .NET version number (e.g. <major>.<minor>.<build>.<revision>)
$envCLRVersionBuildBuild portion of PS .NET version number (e.g. <major>.<minor>.<build>.<revision>)
$envCLRVersionRevisionRevision portion of PS .NET version number (e.g. <major>.<minor>.<build>.<revision>)

Permissions / Accounts

$CurrentProcessTokenObject that represents the current processes Windows Identity user token. Contains all details regarding user permissions.
$CurrentProcessSIDObject that represents the current process account SID (e.g. S-1-5-32-544)
$ProcessNTAccountCurrent process NT Account (e.g. NT AUTHORITY\SYSTEM)
$ProcessNTAccountSIDCurrent process account SID (e.g. S-1-5-32-544)
$IsAdminIs the current process running with elevated admin privileges? (e.g. $true/$false)
$IsLocalSystemAccountIs the current process running under the SYSTEM account? (e.g. $true/$false)
$IsLocalServiceAccountIs the current process running under LOCAL SERVICE account? (e.g. $true/$false)
$IsNetworkServiceAccountIs the current process running under the NETWORK SERVICE account? (e.g. $true/$false)
$IsServiceAccountIs the current process running as a service? (e.g. $true/$false)
$IsProcessUserInteractiveIs the current process able to display a user interface?
$LocalSystemNTAccountLocalized NT account name of the SYSTEM account (e.g. NT AUTHORITY\SYSTEM)
$SessionZeroIs the current process currently in session zero? In session zero isolation, process is not able to display a user interface. (e.g. $true/$false)

Script Name and Script Paths

VariableDescription
$scriptPathFully qualified path of the PSAppDeployToolkit, e.g. C:\Testing\AppDeployToolkit\AppDeployToolkitMain.ps1
$scriptNameName of toolkit without file extension e.g. AppDeployToolkitMain
$scriptFileNameName of toolkit file e.g. AppDeployToolkitMain.ps1
$scriptRootPath that the PSAppDeployToolkit is located in. e.g. C:\Testing\AppDeployToolkit
$invokingScriptFully qualified path of the script that invoked the PSAppDeployToolkit, e.g. C:\Testing\Deploy-Application.ps1
$scriptParentPathIf the PSAppDeployToolkit was invoked by another script, this contains the path that the invoking script is located in.

PSAppDeployToolkit Dependency Files

VariableDescription
$appDeployLogoIconPath to the logo icon file for the PSAppDeployToolkit, e.g. $scriptRoot\AppDeployToolkitLogo.ico
$appDeployLogoBannerPath to the logo banner file for the PSAppDeployToolkit, e.g. $scriptRoot\AppDeployToolkitBanner.png
$appDeployConfigFilePath to the config XML file for the PSAppDeployToolkit, e.g. $scriptRoot\AppDeployToolkitConfig.xml
$appDeployToolkitDotSourceExtensionsName of the optional extensions file for the PSAppDeployToolkit, e.g. AppDeployToolkitExtensions.ps1
$xmlConfigFileContains the entire contents of the XML config file
$configConfigVersionVersion number of the config XML file
$configConfigDateLast modified date of the config XML file

Script Directories

VariableDescription
$dirFilesFiles sub-folder of the PSAppDeployToolkit
$dirSupportFilesSupportFiles sub-folder of the PSAppDeployToolkit
$dirAppDeployTempToolkit temp folder. Configured in XML Config file option Toolkit_TempPath. e.g. Toolkit_TempPath\$appDeployToolkitName

Script Naming Conventions

VariableDescription
$appVendorName of the manufacturer that created the package being deployed (e.g. Microsoft)
$appNameName of the application being packaged (e.g. Office 2010)
$appVersionVersion number of the application being packaged (e.g. 14.0)
$appLangUI language of the application being packaged (e.g. EN)
$appRevisionRevision number of the package (e.g. 01)
$appArchArchitecture of the application being packaged (e.g. x86/x64)
$installTitleCombination of the most important details about the application being packaged (e.g. "$appVendor $appName $appVersion")
$installNameCombination of any of the following details which were provided:
$appVendor + _+ $appName +_ + $appVersion + _+ $appArch +_ + $appLang + _ + $appRevision

Executables

VariableDescription
$exeWusaName of system utility that installs Standalone Windows Updates, e.g. wusa.exe
$exeMsiexecName of system utility that install Windows Installer files, e.g. msiexec.exe
$exeSchTasksPath of system utility that allows management of scheduled tasks, e.g. $envWinDir\System32\schtasks.exe

RegEx Patterns

VariableDescription
$MSIProductCodeRegExPatternContains the regex pattern used to detect a MSI product code.

Registry Keys

VariableDescription
$regKeyApplicationsArray containing the path to the 32-bit and 64-bit portions of the registry that contain information about programs installed on the system.
HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
$regKeyLotusNotesContains the registry path that stores information about a Lotus Notes installation.
- HKLM:SOFTWARE\Lotus\Notes
- HKLM:SOFTWARE\Wow6432Node\Lotus\Notes
$regKeyAppExecutionContains the registry path where application execution can be blocked by configuring the 'Debugger' value.
HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
$regKeyDeferHistoryThe path in the registry where the defer history for the package being installed is stored.
$configToolkitRegPath + \$appDeployToolkitName\DeferHistory\$installName

COM Objects

VariableDescription
$ShellRepresents and allows use of the WScript.Shell COM object
$ShellAppRepresents and allows use of the Shell.Application COM object

Log File

VariableDescription
$logNameName of the script log file: $installName + '_' + $appDeployToolkitName + '_' + $deploymentType + '.log'
$logTempFolderTemporary log file folder used if the option to compress log files was selected in the config XML file: $envTemp\$installName
$configToolkitLogDirPath to log folder defined in XML config file
$DisableScriptLoggingDot source this ScriptBlock to disable logging messages to the log file.
$RevertScriptLoggingDot source this ScriptBlock to revert script logging back to its original setting.

Script Parameters

VariableDescription
$deployAppScriptParametersNon-default parameters that Deploy-Application.ps1 was launched with
$appDeployMainScriptParametersNon-default parameters that AppDeployToolkitMain.ps1 was launched with
$appDeployExtScriptParametersNon-default parameters that AppDeployToolkitExtensions.ps1 was launched with

Logged On Users

VariableDescription
$LoggedOnUserSessionsObject that contains account and session details for all users
$usersLoggedOnArray that contains all of the NTAccount names of logged in users
$CurrentLoggedOnUserSessionObject that contains account and session details for the current process if it is running as a logged in user. This is the object from $LoggedOnUserSessions where the IsCurrentSession property is $true.
$CurrentConsoleUserSessionObjects that contains the account and session details of the console user (user with control of the physical monitor, keyboard, and mouse). This is the object from $LoggedOnUserSessions where the IsConsoleSession property is $true.
$RunAsActiveUserThe active console user. If no console user exists but users are logged in, such as on terminal servers, then the first logged-in non-console user.

Miscellaneous

VariableDescription
$dpiPixelsDPI Scale (property only exists if DPI scaling has been changed on the system at least once)
$runningTaskSequenceIs the current process running in a SCCM task sequence? (e.g. $true/$false)
$IsTaskSchedulerHealthyAre the task scheduler services in a healthy state? (e.g. $true/$false)
$invalidFileNameCharsArray of all invalid file name characters used to sanitize variables which may be used to create file names.
$useDefaultMsiA Zero-Config MSI installation was detected.
$LocalUsersGroupReturns the name of the local Users group, typically BUILTIN\Users
$LocalPowerUsersGroupReturns the name of the local Power Users group, typically BUILTIN\Power Users group
$LocalAdministratorsGroupReturns the name of the local Administrators group, typically BUILTIN\Administrators