PSApp Deployment Toolkit Admin Guide
PSApp Deployment Toolkit Admin Guide
PSApp Deployment Toolkit Admin Guide
http://psappdeploytoolkit.com
Overview......................................................................................................................................................................................................5
Introduction.............................................................................................................................................................................................5
Features...................................................................................................................................................................................................5
System Requirements and Support........................................................................................................................................................6
Licensing..................................................................................................................................................................................................6
Donations................................................................................................................................................................................................6
Toolkit Functionality....................................................................................................................................................................................7
User Interface..........................................................................................................................................................................................7
Functions/Logic.......................................................................................................................................................................................7
Integration with SCCM............................................................................................................................................................................8
Help Console............................................................................................................................................................................................8
Toolkit Components....................................................................................................................................................................................8
Toolkit File Structure...............................................................................................................................................................................8
Files.....................................................................................................................................................................................................8
Directories...........................................................................................................................................................................................9
Toolkit User Interface............................................................................................................................................................................10
INSTALLATION PROGRESS........................................................................................................................................................................10
Installation Welcome Prompt...........................................................................................................................................................11
Welcome prompt with close programs option and defer option....................................................................................................12
Welcome prompt with close programs options and countdown to automatic closing of applications..........................................13
Welcome prompt with just a defer option.......................................................................................................................................13
Block Application Execution..............................................................................................................................................................14
Disk Space Requirements.................................................................................................................................................................14
Custom Installation Prompt..............................................................................................................................................................15
Installation Restart Prompt...............................................................................................................................................................15
Balloon tip notifications....................................................................................................................................................................16
Custom Dialog box............................................................................................................................................................................16
Logging..................................................................................................................................................................................................17
Toolkit Usage.............................................................................................................................................................................................18
Overview...............................................................................................................................................................................................18
Launching the Toolkit............................................................................................................................................................................18
Overview...........................................................................................................................................................................................18
Toolkit Parameters............................................................................................................................................................................19
Customizing the Toolkit.........................................................................................................................................................................19
OVERVIEW
INTRODUCTION
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
The PowerShell App Deployment Toolkit provides a set of functions to perform common application deployment tasks and to
interact with the user during a deployment. It simplifies the complex scripting challenges of deploying applications in the enterprise,
provides a consistent deployment experience and improves installation success rates.
The PowerShell App Deployment Toolkit can be used to replace your WiseScript, VBScript and Batch script wrappers with one
versatile, re-usable and extensible tool.
FEATURES
Easy to Use - Any PowerShell beginner can use the template and the functions provided with the Toolkit to perform application
deployments.
Consistent - Provides a consistent look and feel for all application deployments, regardless of complexity.
Powerful - Provides a set of functions to perform common deployment tasks, such as installing or uninstalling multiple applications,
prompting users to close apps, setting registry keys, copying files, etc.
User Interface - Provides user interaction through, customizable user interface dialog boxes, progress dialogs and balloon tip
notifications that can all be branded with custom logo and banner.
Localized - The UI is localized in several languages and more can easily be added using the XML configuration file.
Integration - Integrates well with SCCM 2007/2012; provides installation and uninstallation deployment types with options on how
to handle exit codes, such as supressing reboots or returning a fast retry code.
Updatable - The logic engine and functions are separated from per-application scripts, so that you can update the toolkit when a
new version is released and maintain backwards compatibility with your deployment scripts.
Extensible - The Toolkit can be easily extended to add custom scripts and functions.
Helpful - The Toolkit provides detailed logging of all actions performed and even includes a graphical console to browse the help
documentation for the Toolkit functions.
The PowerShell App Deployment Toolkit has been developed (and tested) to work with a wide range of Operating Systems from
Windows XP to Windows 8.1 (and the Windows Server equivalents) to provide enterprise-wide compatibility. The system
requirements are as follows:
PowerShell 2.0
While we have attempted to maintain this backwards compatibility through the lifecycle of the toolkit, the degree of testing
performed across older Operating Systems such as XP and Vista is limited as the bulk of testing is performed on the latest OS
versions. However, the toolkit has widespread adoption in the enterprise from SMEs to large multinationals so there is safety in
numbers and the assurance that the toolkit has been put through its paces on hundreds of thousands of clients around the globe.
LICENSING
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see
<http://www.gnu.org/licenses/>.
DONATIONS
We have invested our spare time in the creation and ongoing development, maintenance and support of this community tool on a
voluntary basis – it is not part of our day jobs! Donations to the project are welcome, please visit the following page for details on
contributing:
https://psappdeploytoolkit.com/donate/
USER INTERFACE
An interface to prompt the user to close specified applications that are open prior to starting the application deployment.
The user is prompted to save their documents and has the option to close the programs themselves, have the toolkit close
the programs, or optionally defer. Optionally, a countdown can be displayed until the applications are automatically closed.
The ability to allow the user to defer an installation X number of times, X number of days or until a deadline date is reached.
The ability to prevent the user from launching the applications that need to be closed while the application installation is in
progress.
An indeterminate progress dialog with customizable message text that can be updated throughout the deployment.
A restart prompt with an option to restart later or restart now and a countdown to automatic restart.
The ability to notify the user if disk space requirements are not met.
Custom dialog boxes with options to customize title, text, buttons & icon.
Balloon tip notifications to indicate the beginning and end of an installation and the success or failure of an installation.
Branding of the above UI components using a custom logo icon and banner for your own Organization.
The ability to run in interactive, silent (no dialogs) or non-interactive mode (default for running SCCM task sequence or
session 0).
The UI is localized into several languages and more can be easily added using the XML configuration file.
FUNCTIONS/LOGIC
Provides extensive logging of both the Toolkit functions and any MSI installation / uninstallation.
Provides the ability to execute any type of setup (MSI or EXEs) and handle the return codes.
Mass remove MSI applications with a partial match (e.g. remove all versions of all MSI applications which match "Office")
Perform SCCM actions such as Machine and User Policy Refresh, Inventory Update and Software Update
Handles SCCM exit codes, including time sensitive dialogs supporting SCCM's Fast Retry feature - providing more accurate
SCCM Reporting (no more Failed due to timeout errors).
Ability to prevent reboot codes (3010) from being passed back to SCCM, which would cause a reboot prompt.
Supports the CM12 application model by providing an install and uninstall deployment type for every deployment script.
Bundle multiple application installations to overcome the supported limit of 5 applications in the CM12 application
dependency chain.
Compared to compiled deployment packages, e.g. WiseScript, the Toolkit utilises the SCCM cache correctly and SCCM
Distribution Point bandwidth more efficiently by using loose files.
HELP CONSOLE
A graphical console for browsing the help documentation for the toolkit functions.
TOOLKIT COMPONENTS
FILES
The toolkit is comprised of the following files:
DEPLOY-APPLICATION.PS1
Performs the actual install / uninstall and is the only file that needs to be modified, depending on your level of customisation.
DEPLOY-APPLICATION.EXE
An optional executable that can be used to launch the Deploy-Application.ps1 script without opening a PowerShell console window.
Supports passing command-line parameters to the script.
APPDEPLOYTOOLKITMAIN.PS1
Contains all of the functions and logic used by the installation script. By Separating the logic from the installation script, we can
obfuscate away the complex code and make enhancements independently of the installation scripts that contain per-application
actions.
APPDEPLOYTOOLKITCONFIG.XML
Contains configurable options referenced by the AppDeployToolkitMain.ps1 script, such as MSI switches and User Interface
messages, which are customizable and localized in several languages. This is intended to be a static file that is configured once, not
on a per-application basis.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
APPDEPLOYTOOLKITEXTENSIONS.PS1
This is an optional PowerShell script that can be used to extend the toolkit functionality with custom functions. It is automatically
dot-sourced by the AppDeployToolkitMain.ps1 script.
APPDEPLOYTOOLKITHELP.PS1
This is a script that displays a help console to browse the functions included in the Toolkit and copy and paste examples into your
deployment script.
DIRECTORIES
The Root folder contains the Deploy-Application.exe and Deploy-Application.ps1 files. The Deploy-Application.ps1 file is the only file
that should be modified on a per-application basis.
The directories below contain the installation files and supporting files referenced by the toolkit.
APPDEPLOYTOOLKIT
Folder containing the toolkit dependency files.
FILES
Folder containing your main setup files, e.g. MSI
SUPPORTFILES
Folder containing any supporting files such as files you need to copy to the target machine using the toolkit during deployment.
The user interface consists of several components detailed below. The user interface can be branded with a custom logo and
banner.
All of the UI components include message text that is customizable in the AppDeployToolkitConfig.xml. The UI has been localised in
11 different languages: English, French, Spanish, Portuguese, German, Italian, Dutch, Swedish, Danish, Norweigan and Japanese.
Additional languages can be easily added in the XML configuration file.
The language used by the Toolkit UI is selected automatically based on the language culture of the operating system, so the same
AppDeployToolkitConfig file can be used in a multi-language environment.
The user interface can be suppressed by specifying the deploy mode parameter as follows:
INSTALLATION PROGRESS
The installation progress message displays an indeterminate progress ring to indicate an installation is in progress and display status
messages to the end user. This is invoked using the “Show-InstallationProgress” function.
The progress message can be dynamically updated to indicate the stage of the installation or to display custom messages to the
user, using the “Show-InstallationProgress” function.
Additionally, the prompt can be displayed asynchronously, e.g. to display a message at the end of the installation but allow the
installation to return the exit code to the parent process without waiting for the user to respond to the message.
The toolkit generates extensive logging for all toolkit and MSI operations.
The default log directory for the toolkit and MSI log files can be specified in the XML configuration file. The default directory is
<C:\Windows\Logs\Software>.
The toolkit log file is named after the application with _PSAppDeployToolkit appended to the end, e.g.
Oracle_JavaRuntime_1.7.0.17_EN_01_PSAppDeployToolkit.log
All MSI actions are logged and the log file is named according to the MSI file used on the command line, with the action appended to
the log file name. For uninstallations, the MSI product code is resolved to the MSI application name and version to keep the same
log file format, e.g.
Oracle_JavaRuntimeEnvironmentx86_1.7.0.17_EN_01_Install.log
Oracle_JavaRuntimeEnvironmentx86_1.7.0.17_EN_01_Repair.log
Oracle_JavaRuntimeEnvironmentx86_1.7.0.17_EN_01_Patch.log
Oracle_JavaRuntimeEnvironmentx86_1.7.0.17_EN_01_Uninstall.log
OVERVIEW
The Deploy-Application.ps1 script is the only script you need to modify to deploy your application.
Initialization e.g. Variables such as App Vendor, App Name, App Version
OVERVIEW
There are two ways to launch the toolkit for deployment of applications.
2. Launch “Deploy-Application.exe” as administrator. This will launch the “Deploy-Application.ps1” PowerShell script without
opening a PowerShell command window. Note, if the x86 PowerShell is required (for example, if CAPICOM or another x86
library is needed), launch Deploy-Application.exe /32
EXAMPLES:
Deploy-Application.ps1
Deploy-Application.exe -AllowRebootPassThru
Deploy an application for installation, supressing the PowerShell console window and allowing reboot codes to be returned to
the parent process.
Deploy-Application.exe "Custom-Script.ps1"
Deploy an application with a custom name and custom location for the script file.
Specify whether the installation should be run in Interactive, Silent or NonInteractive mode.
NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not
user interactive.
Specify whether to allow the 3010 exit code (reboot required) to be passed back to the parent process (e.g. SCCM) if detected during
an installation. If a 3010 code is passed to SCCM, the SCCM client will display a reboot prompt. If set to false, the 3010 return code
will be replaced by a “0” (successful, no restart required).
Changes to user install mode and back to user execute mode for installing/uninstalling applications on Remote Desktop Session
Host/Citrix servers
Aside from customizing the “Deploy-Application.ps1” script to deploy your application, no configuration is necessary out of the box.
The following components can be configured as required:
AppDeployToolkitConfig.xml - Configure the default UI messages, MSI parameters, log file location, whether Admin rights should be
required, whether log files should be compressed, log style (CMTrace or Legacy), max log size, whether debug messages should be
logged, whether log entries should be written to the console, whether toolkit should re-launch as elevated logged-on console user
when in SYSTEM context, whether toolkit should fall back to SYSTEM context if failure to launch toolkit as user, and whether toolkit
should attempt to launch as a non-console logged on user (e.g. user logged on via terminal services) when in SYSTEM context.
AppDeployToolkitLogo.ico - To brand the balloon notifications and UI window title bars with your own custom/corporate logo,
replace the AppDeployToolkitLogo.ico file with your own .ico file (retaining the file name)
AppDeployToolkitBanner.png - To brand the toolkit UI prompts with your own custom/corporate banner, replace the
AppDeployToolkitBanner.png file with your own .png file (retaining the file name). The file must be in PNG format and must be 450 x
50 in size.
CompressLogs (option in AppDeployToolkitConfig.xml) - One of the Toolkit Options in the AppDeployToolkitConfig.xml file is
CompressLogs. Enabling this option will create a temporary logging folder where you can save all of the log files you want to include
in the single ZIP file that will be created from this folder.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
To enable the CompressLogs, set the follow option in AppDeployToolkitConfig.xml to True:
<Toolkit_CompressLogs>True</Toolkit_CompressLogs>
Both toolkit and MSI logs are temporally placed in $envTemp\$installName which gets cleaned up at the end of the
install.
At the end of the install / uninstall, the logs are compressed into a new zip file which is placed in the LogFolder location
in the config file.
The Zip file name indicates whether it is an Install / Uninstall and has the timestamp in the filename so previous logs do
not get overwritten.
If your package creates other log files, you can send them to the temporary logging FOLDER at $envTemp\
$installName.
EXAMPLE DEPLOYMENTS
BUILDING AN ADOBE READER INSTALLATION WITH THE POWERSHELL APP DEPLOYMENT TOOLKIT
In this example, we will build an Adobe Reader installation which provides the following benefits over using a standard MSI based
SCCM deployment:
This example is provided as a script with the toolkit, in the “Examples” folder.
PRE-INSTALL
# Prompt the user to close the following applications if they are running and allow the option to defer the installation up to 3 times:
Show-InstallationWelcome -CloseApps 'iexplore,AcroRd32,cidaemon' -AllowDefer -DeferTimes 3
# Show Progress Message (with the default message)
Show-InstallationProgress
# Remove any previous versions of Adobe Reader
Remove-MSIApplications -Name 'Adobe Reader'
INSTALLATION
# Install the base MSI and apply a transform
Execute-MSI -Action Install -Path 'Adobe_Reader_11.0.0_EN.msi' -Transform 'Adobe_Reader_11.0.0_EN_01.mst'
# Install the patch
Execute-MSI -Action Patch -Path 'Adobe_Reader_11.0.3_EN.msp'
POST-INSTALLATION
# No actions required here
UNINSTALLATION
# Prompt the user to close the following applications if they are running:
Show-InstallationWelcome -CloseApps 'iexplore,AcroRd32,cidaemon'
# Show Progress Message (with a message to indicate the application is being uninstalled)
Show-InstallationProgress -StatusMessage "Uninstalling Application $installTitle. Please Wait..."
# Remove this version of Adobe Reader
Execute-MSI -Action Uninstall -Path '{AC76BA86-7AD7-1033-7B44-AB0000000001}'
Accept the defaults for the rest of the package (or modify according to your environment)
Distribute the content of the package to the relevant Distribution Points
Create a new Program for the package:
Accept the defaults for the rest of the program (or modify according to your environment)
Set a recurring schedule for the Mandatory Assignment. This dictates how frequently the application should attempt to
install. Additionally, ensure that “Rerun if failed previous attempt” is enabled. These settings are required when using the
deferral system and ensure that if a user defers the install, the install will retry after the specified interval:
Accept the defaults for the rest of the advertisement (or modify according to your environment). The deployment should
start on your target machines shortly.
DEPLOY THE ADOBE READER INSTALLATION USING SCCM 2012 APPLICATION MODEL
Copy the installation files to a network location accessible by SCCM.
Create a new Application and manually specify the application information:
Set the content location. Additionally, set the Install and Uninstall programs accordingly. They should be Deploy-
Application.exe -DeploymentType "Install" and Deploy-Application.exe -DeploymentType "Uninstall" respectively:
On the User Experience page, ensure you use a combination of settings that allows the user to interact with the application.
Failure to do so will result in the application installing silently:
Leave the requirements page blank (or modify according to your environment)
Leave the software dependencies page blank (or modify according to your environment)
Accept the defaults to create the Application
Deploy the Application:
Specify User notification settings. In order to prevent excess noise, we recommend only showing notifications for computer
restarts:
A component-based architecture so that core products can be installed, and subsequent components can be installed using
the same package with different command-line switches
The ability to defer the installation up to 3 times
The ability to close any applications that could cause errors during the installation
Verification that the required disk space is available
Full removal of any previous version of Microsoft Office 2007, 2010 or 2013
Installation of any subsequent patches required after the base installation
Activation of Microsoft Office components
Note: Office requires a number of modifications in order to install. Please refer to Microsoft’s documentation on configuration. This
installation script tries to take a lot of work out of the process for you, but you still need to know what you’re doing in order to set it
up correctly.
Files
o Office installation files should be placed here
Office Configuration MSP created with the Office Customisation Tool should be placed in the “Config”
subfolder and be named Office2013ProPlus.MSP. Modify the script accordingly if you wish to change. For
a basic MSP, you should probably configure Access, Word, Excel and PowerPoint to be the only core
applications to install. We can add everything else as components.
Customised Config.xml file should be edited in “ProPlus.WW” subfolder. At a minimum, you should
modify the settings as follows:
<Display Level="none" CompletionNotice="no" SuppressModal="yes" NoCancel="yes"
AcceptEula="yes" />
Security updates and service pack extracted MSPs should be placed in the “Updates” subfolder
SupportFiles
o Contains custom Config.XML files which are used to add specific components that might be considered
unnecessary in a standard Office install, but could be added later using command-line switches
o Contains Office Scrub tools for Office 2007, 2010 and 2013
Deploy-Application.exe
o Installs Office 2010 with core products
Deploy-Application.exe -AddInfoPath
o Installs Office 2010 with core products and InfoPath
Deploy-Application.exe -AddComponentsOnly -AddInfoPath
o Installs InfoPath to an existing Office 2013 installation
The toolkit has a zero-config MSI install feature which allows you to quickly execute an installation with zero configuration of the
Deploy-Application.ps1 file.
Place your MSI file into the “Files” directory of the toolkit. This method only support the installation of one MSI, so if more
than one MSI is found, then only the first one is selected.
If you have an MST file, then place it into the “Files” directory of the toolkit. The MST file must have the same name as the
MSI file. For example, if your MSI file name is test01.msi, then the MST file must be named test01.mst.
If you have any MSP files, then place it into the “Files” directory of the toolkit. You can place more than one MSP file in the
folder, but you must name the files in alphabetical order to control the order in which they are installed. MSP file will be
installed in alphabetical order.
TOOLKIT VARIABLES
The toolkit has several internal variables which can be used in your script. Outlined below are each of them:
Variable Description
TOOLKIT NAME
$appDeployToolkitName Short name of toolkit without spaces
$appDeployMainScriptFriendl
Full name of toolkit including spaces
yName
Script Info
$appDeployMainScriptVersio
Version number of the toolkit
n
$appDeployMainScriptMinim
Minimum version of the config XML file required by the toolkit
umConfigVersion
$appDeployMainScriptDate Date toolkit was last modified
$appDeployMainScriptParam
Contains all parameters and values specified when toolkit was launched
eters
DATETIME AND CULTURE
$currentDateTime Current date & time when the toolkit was launched
$currentTime Current time when toolkit was launched
$currentDate Current date when toolkit was launched
$currentTimeZoneBias Time Zone bias based on the current date/time
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
$culture Object which contains all of the current Windows culture settings
$currentLanguage Current Windows two letter ISO language name (e.g. EN, FR, DE, JA etc)
$currentUILanguage Current Windows two letter UI ISO language name (e.g. EN, FR, DE, JA etc)
Environment Variables (path examples are for Windows 7 and higher)
$envHost Object that contains details about the current PowerShell console
$envShellFolders Object 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)
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)
$envCommonProgramFilesX8
%COMMONPROGRAMFILES(x86)% (e.g. C:\Program Files (x86)\Common Files)
6
$envCommonDesktop e.g. C:\Users\Public\Desktop
$envCommonDocuments e.g. C:\Users\Public\Documents
$envCommonStartMenuProgr
e.g. C:\ProgramData\Microsoft\Windows\Start Menu\Programs
ams
$envCommonStartMenu e.g. C:\ProgramData\Microsoft\Windows\Start Menu
$envCommonStartUp e.g. C:\ProgramData\Microsoft\Windows\Start Menu
$envCommonTemplates e.g. C:\ProgramData\Microsoft\Windows\Templates
$envComputerName $COMPUTERNAME% (e.g. computer1)
$envComputerNameFQDN Fully qualified computer name (e.g. computer1.conto.contoso.com)
$envHomeDrive %HOMEDRIVE% (e.g. C:)
$envHomePath %HOMEPATH% (e.g. \Users\{username})
$envHomeShare %HOMESHARE%
Used instead of HOMEDRIVE if the home directory uses UNC paths.
$envLocalAppData %LOCALAPPDATA% (e.g. C:\Users\{username}\AppData\Local)
$envLogicalDrives An 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 systems, is used to store 32 bit programs.
$envProgramData %PROGRAMDATA% (e.g. C:\ProgramData)
$envPublic %PUBLIC% (e.g. C:\Users\Public)
$envSystemDrive %SYSTEMDRIVE% (e.g. C:)
$envSystemRAM System RAM as an integer
$envSystemRoot %SYSTEMROOT% (e.g. C:\Windows)
$envTemp Checks for the existence of environment variables in the following order and uses the first path
found:
•The path specified by the TMP environment variable.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
•The path specified by the TEMP (e.g. C:\Users\{Username}\AppData\Local\Temp) environment
variable.
•The path specified by the USERPROFILE environment variable.
•The Windows root (C:\Windows) directory.
$envUserCookies C:\Users\{username}\AppData\Local\Microsoft\Windows\INetCookies
$envUserDesktop C:\Users\{username}\Desktop
$envUserFavorites C:\Users\{username}\Favorites
$envUserInternetCache C:\Users\{username}\AppData\Local\Microsoft\Windows\INetCache
$envUserInternetHistory C:\Users\{username}\AppData\Local\Microsoft\Windows\History
$envUserMyDocuments C:\Users\{username}\Documents
$envUserName %USERNAME% (e.g. {username})
$envUserProfile %USERPROFILE% (e.g. %SystemDrive%\Users\{username})
$envUserSendTo C:\Users\{username}\AppData\Roaming\Microsoft\Windows\SendTo
$envUserStartMenu C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu
$envUserStartMenuPrograms C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
$envUserStartUp C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
$envSystem32Directory C:\WINDOWS\system32
$envWinDir %WINDIR% (e.g. C:\Windows)
DOMAIN MEMBERSHIP
$IsMachinePartOfDomain Is machine joined to a domain (e.g. $true/$false)
$envMachineWorkgroup If machine not joined to domain, what is the WORKGROUP it belongs to?
$envMachineADDomain Root AD domain name for machine (e.g. <name>.<suffix>.contoso.com)
$envLogonServer FQDN of %LOGONSERVER% used for authenticating logged in user
$MachineDomainController FQDN of an AD domain controller used for authentication
$envMachineDNSDomain Full Domain name for machine (e.g. <name>.conto.contoso.com)
$envUserDNSDomain %USERDNSDOMAIN%. Root AD domain name for user (e.g. <name>.<suffix>.contoso.com)
$envUserDomain %USERDOMAIN% (e.g. <name>.<suffix>.CONTOSO.<tld>)
Operating System
$envOS Object that contains details about the operating system
$envOSName Name of the operating system (e.g. Microsoft Windows 8.1 Pro)
$envOSServicePack Latest service pack installed on the system (e.g. Service Pack 3)
$envOSVersion Full version number of the OS (e.g. {major}.{minor}.{build}.{revision})
$envOSVersionMajor Major portion of the OS version number (e.g. {major}.{minor}.{build}.{revision})
$envOSVersionMinor Minor portion of the OS version number (e.g. {major}.{minor}.{build}.{revision})
$envOSVersionBuild Build portion of the OS version number (e.g. {major}.{minor}.{build}.{revision})
$envOSVersionRevision Revision portion of the OS version number (e.g. {major}.{minor}.{build}.{revision})
$envOSProductType OS product type represented as an integer (e.g. 1/2/3)
$IsServerOS Is server OS? (e.g. $true/$false)
$IsDomainControllerOS Is domain controller OS? (e.g. $true/$false)
$IsWorkStationOS Is workstation OS? (e.g. $true/$false)
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
$envOSProductTypeName OS product type name (e.g. Server/Domain Controller/Workstation/Unknown)
$Is64Bit Is this a 64-bit OS? (e.g. $true/$false)
$envOSArchitecture Represents the OS architecture (e.g. 32-Bit/64-Bit)
CURRENT PROCESS ARCHITECTURE
$Is64BitProcess Is the current process 64-bits? (e.g. $true/$false)
$psArchitecture Represents the current process architecture (e.g. x86/x64)
POWERSHELL AND CLR (.NET) VERSIONS
$envPSVersionTable Object containing PowerShell version details from PS variable $PSVersionTable
$envPSVersion Full version number of PS (e.g. {major}.{minor}.{build}.{revision})
$envPSVersionMajor Major portion of PS version number (e.g. {major}.{minor}.{build}.{revision})
$envPSVersionMinor Minor portion of PS version number (e.g. {major}.{minor}.{build}.{revision})
$envPSVersionBuild Build portion of PS version number (e.g. {major}.{minor}.{build}.{revision})
$envPSVersionRevision Revision portion of PS version number (e.g. {major}.{minor}.{build}.{revision})
$envCLRVersion Full version number of .NET used by PS (e.g. {major}.{minor}.{build}.{revision})
$envCLRVersionMajor Major portion of PS .NET version number (e.g. {major}.{minor}.{build}.{revision})
$envCLRVersionMinor Minor portion of PS .NET version number (e.g. {major}.{minor}.{build}.{revision})
$envCLRVersionBuild Build portion of PS .NET version number (e.g. {major}.{minor}.{build}.{revision})
$envCLRVersionRevision Revision portion of PS .NET version number (e.g. {major}.{minor}.{build}.{revision})
PERMISSIONS/ACCOUNTS
Object that represents the current processes Windows Identity user token. Contains all details
$CurrentProcessToken
regarding user permissions.
$CurrentProcessSID Object that represents the current process account SID (e.g. S-1-5-32-544)
$ProcessNTAccount Current process NT Account (e.g. NT AUTHORITY\SYSTEM)
$ProcessNTAccountSID Current process account SID (e.g. S-1-5-32-544)
$IsAdmin Is the current process running with elevated admin privileges? (e.g. $true/$false)
$IsLocalSystemAccount Is the current process running under the SYSTEM account? (e.g. $true/$false)
$IsLocalServiceAccount Is the current process running under LOCAL SERVICE account? (e.g. $true/$false)
$IsNetworkServiceAccount Is the current process running under the NETWORK SERVICE account? (e.g. $true/$false)
$IsServiceAccount Is the current process running as a service? (e.g. $true/$false)
$IsProcessUserInteractive Is the current process able to display a user interface?
$LocalSystemNTAccount Localized NT account name of the SYSTEM account (e.g. NT AUTHORITY\SYSTEM)
Is the current process currently in session zero? In session zero isolation, process is not able to
$SessionZero
display a user interface. (e.g. $true/$false)
SCRIPT NAME AND SCRIPT PATHS
$scriptPath Fully qualified path of the toolkit (e.g. C:\Testing\AppDeployToolkit\AppDeployToolkitMain.ps1)
$scriptName Name of toolkit without file extension (e.g. AppDeployToolkitMain)
$scriptFileName Name of toolkit file (e.g. AppDeployToolkitMain.ps1)
$scriptRoot Folder that the toolkit is located in. (e.g. C:\Testing\AppDeployToolkit)
$invokingScript Fully qualified path of the script that invoked the toolkit (e.g. C:\Testing\Deploy-Application.ps1)
$scriptParentPath If toolkit was invoked by another script: contains folder that the invoking script is located in.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
If toolkit was not invoked by another script: contains parent folder of the toolkit.
APP DEPLOY SCRIPT DEPENDENCY FILES
$appDeployLogoIcon Path to the logo icon file for the toolkit (e.g. $scriptRoot\AppDeployToolkitLogo.ico)
$appDeployLogoBanner Path to the logo banner file for the toolkit (e.g. $scriptRoot\AppDeployToolkitBanner.png)
$appDeployConfigFile Path to the config XML file for the toolkit (e.g. $scriptRoot\AppDeployToolkitConfig.xml)
$appDeployToolkitDotSource
Name of the optional extensions file for the toolkit (e.g. AppDeployToolkitExtensions.ps1)
Extensions
$xmlConfigFile Contains the entire contents of the XML config file
$configConfigVersion Version number of the config XML file
$configConfigDate Last modified date of the config XML file
SCRIPT DIRECTORIES
$dirFiles "Files" sub-directory of the toolkit
$dirSupportFiles "SupportFiles" sub-directory of the toolkit
Toolkit temp directory. Configured in XML Config file option "Toolkit_TempPath". (e.g.
$dirAppDeployTemp
Toolkit_TempPath\$appDeployToolkitName)
SCRIPT NAMING CONVENTION
$appVendor Name of the manufacturer that created the package being deployed (e.g. Microsoft)
$appName Name of the application being packaged (e.g. Office 2010)
$appVersion Version number of the application being packaged (e.g. 14.0)
$appLang UI language of the application being packaged (e.g. EN)
$appRevision Revision number of the package (e.g. 01)
$appArch Architecture of the application being packaged (e.g. x86/x64)
Combination of the most important details about the application being packaged (e.g.
$installTitle
"$appVendor $appName $appVersion")
Combination of any of the following details which were provided: $appVendor + '_' + $appName
$installName
+ '_' + $appVersion + '_' + $appArch + '_' + $appLang + '_' + $appRevision
EXECUTABLES
$exeWusa Name of system utility that installs Standalone Windows Updates (e.g. wusa.exe)
$exeMsiexec Name of system utility that install Windows Installer files (e.g. msiexec.exe)
Path of system utility that allows management of scheduled tasks (e.g.
$exeSchTasks
$envWinDir\System32\schtasks.exe)
REGEX PATTERNS
$MSIProductCodeRegExPatter
Contains the regex pattern used to detect a MSI product code.
n
REGISTRY KEYS
Array containing the path to the 32-bit and 64-bit portions of the registry that contain
information about programs installed on the system.
$regKeyApplications
'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:SOFTWARE\Wow6432
Node\Microsoft\Windows\CurrentVersion\Uninstall'
Contains the registry path that stores information about a Lotus Notes installation.
$regKeyLotusNotes
'HKLM:SOFTWARE\Lotus\Notes','HKLM:SOFTWARE\Wow6432Node\Lotus\Notes'
$regKeyAppExecution Contains the registry path where application execution can be blocked by configuring the
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
‘Debugger’ value.
'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
The path in the registry where the defer history for the package being installed is stored.
$regKeyDeferHistory
"$configToolkitRegPath\$appDeployToolkitName\DeferHistory\$installName"
COM OBJECTS
$Shell Represents and allows use of the WScript.Shell COM object
$ShellApp Represents and allows use of the Shell.Application COM object
Log File
Name of the script log file: $installName + '_' + $appDeployToolkitName + '_' +
$logName
$deploymentType + '.log'
Temporary log file directory used if the option to compress log files was selected in the config
$logTempFolder XML file:
$envTemp\$installName
$configToolkitLogDir Path to log directory defined in XML config file
$DisableScriptLogging Dot source this ScriptBlock to disable logging messages to the log file.
$RevertScriptLogging Dot source this ScriptBlock to revert script logging back to its original setting.
SCRIPT PARAMETERS
$deployAppScriptParameters Non-default parameters that Deploy-Application.ps1 was launched with
$appDeployMainScriptParam
Non-default parameters that AppDeployToolkitMain.ps1 was launched with
eters
$appDeployExtScriptParamet
Non-default parameters that AppDeployToolkitExtensions.ps1 was launched with
ers
LOGGED ON USERS
$LoggedOnUserSessions Object that contains account and session details for all users
$usersLoggedOn Array that contains all of the NTAccount names of logged in users
Object that contains account and session details for the current process if it is running as a
$CurrentLoggedOnUserSessio
logged in user. This is the object from $LoggedOnUserSessions where the IsCurrentSession
n
property is $true.
Objects that contains the account and session details of the console user (user with control of
$CurrentConsoleUserSession the physical monitor, keyboard, and mouse). This is the object from $LoggedOnUserSessions
where the IsConsoleSession property is $true.
The active console user. If no console user exists but users are logged in, such as on terminal
$RunAsActiveUser
servers, then the first logged-in non-console user.
MISCELLANEOUS
$dpiPixels DPI Scale (property only exists if DPI scaling has been changed on the system at least once)
$runningTaskSequence Is the current process running in a SCCM task sequence? (e.g. $true/$false)
$IsTaskSchedulerHealthy Are the task scheduler services in a healthy state? (e.g. $true/$false)
Array of all invalid file name characters used to sanitize variables which may be used to create
$invalidFileNameChars
file names.
$useDefaultMsi A Zero-Config MSI installation was detected.
TOOLKIT FUNCTIONS
CONVERT-REGISTRYPATH
SYNOPSIS
Converts the specified registry key path to a format that is compatible with built-in PowerShell cmdlets.
SYNTAX
DESCRIPTION
Converts the specified registry key path to a format that is compatible with built-in PowerShell cmdlets.
Converts registry key hives to their full paths. Example: HKLM is converted to "Registry::HKEY_LOCAL_MACHINE".
PARAMETERS
-Key <String>
Path to the registry key to convert (can be a registry hive or fully qualified path)
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
-SID <String>
The security identifier (SID) for a user. Specifying this parameter will convert a HKEY_CURRENT_USER registry key to the
HKEY_USERS\$SID format.
Specify this parameter from the Invoke-HKCURegistrySettingsForAllUsers function to read/edit HKCU registry settings for all
users on the system.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
COPY-FILE
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-Path <String[]>
-Destination <String>
-Recurse [<SwitchParameter>]
-ContinueOnError <Boolean>
Continue if an error is encountered. This will continue the deployment script, but will not continue copying files if an error is
encountered. Default is: $true.
-ContinueFileCopyOnError <Boolean>
Continue copying files if an error is encountered. This will continue the deployment script and will warn about files that failed to
be copied. Default is: $false.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
DISABLE-TERMINALSERVERINSTALLMODE
SYNOPSIS
Changes to user install mode for Remote Desktop Session Host/Citrix servers.
DESCRIPTION
Changes to user install mode for Remote Desktop Session Host/Citrix servers.
PARAMETERS
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Disable-TerminalServerInstallMode
REMARKS
ENABLE-TERMINALSERVERINSTALLMODE
SYNOPSIS
Changes to user install mode for Remote Desktop Session Host/Citrix servers.
SYNTAX
DESCRIPTION
Changes to user install mode for Remote Desktop Session Host/Citrix servers.
PARAMETERS
-ContinueOnError <Boolean>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Enable-TerminalServerInstall
REMARKS
EXECUTE-MSI
SYNOPSIS
Executes msiexec.exe to perform the following actions for MSI & MSP files and MSI product codes: install, uninstall, patch, repair,
active setup.
SYNTAX
Execute-MSI [[-Action] <String>] [-Path] <String> [[-Transform] <String>] [[-Parameters] <String>] [[-AddParameters] <String>] [-
SecureParameters] [[-Patch] <String>] [[-LoggingOptions]
[<CommonParameters>]
DESCRIPTION
Executes msiexec.exe to perform the following actions for MSI & MSP files and MSI product codes: install, uninstall, patch, repair,
active setup.
If the -Action parameter is set to "Install" and the MSI is already installed, the function will exit.
Sets default switches to be passed to msiexec based on the preferences in the XML configuration file.
Automatically generates a log file name and creates a verbose log file for all msiexec operations.
Expects the MSI or MSP file to be located in the "Files" sub directory of the App Deploy Toolkit. Expects transform files to be in the
same directory as the MSI file.
-Action <String>
-Path <String>
The path to the MSI/MSP file or the product code of the installed MSI.
-Transform <String>
The name of the transform file(s) to be applied to the MSI. The transform file is expected to be in the same directory as the MSI
file.
-Parameters <String>
Overrides the default parameters specified in the XML configuration file. Install default is: "REBOOT=ReallySuppress /QB!".
Uninstall default is: "REBOOT=ReallySuppress /QN".
-AddParameters <String>
Adds to the default parameters specified in the XML configuration file. Install default is: "REBOOT=ReallySuppress /QB!".
Uninstall default is: "REBOOT=ReallySuppress /QN".
-SecureParameters [<SwitchParameter>]
Hides all parameters passed to the MSI or MSP file from the toolkit Log file.
-Patch <String>
The name of the patch (msp) file(s) to be applied to the MSI for use with the "Install" action. The patch file is expected to be in
the same directory as the MSI file.
-LoggingOptions <String>
Overrides the default logging options specified in the XML configuration file. Default options are: "/L*v".
-private:LogName <String>
-WorkingDirectory <String>
Overrides the working directory. The working directory is set to the location of the MSI file.
-SkipMSIAlreadyInstalledCheck [<SwitchParameter>]
Skips the check to determine if the MSI is already installed on the system. Default is: $false.
-IncludeUpdatesAndHotfixes [<SwitchParameter>]
-PassThru [<SwitchParameter>]
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Installs an MSI
Installs an MSI, applying a transform and overriding the default MSI toolkit parameters
Installs an MSI and stores the result of the execution into a variable by using the -PassThru option
Installs an MSP
REMARKS
EXECUTE-MSP
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
SYNOPSIS
Reads SummaryInfo targeted product codes in MSP file and determines if the MSP file applies to any installed products
If a valid installed product is found, triggers the Execute-MSI function to patch the installation.
SYNTAX
DESCRIPTION
PARAMETERS
-Path <String>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
EXECUTE-PROCESS
SYNOPSIS
SYNTAX
Execute-Process [-Path] <String> [[-Parameters] <String[]>] [-SecureParameters] [[-WindowStyle] {Normal | Hidden | Minimized |
Maximized}] [-CreateNoWindow] [[-WorkingDirectory] <String>]
DESCRIPTION
Executes a process, e.g. a file included in the Files directory of the App Deploy Toolkit, or a file on the local machine.
PARAMETERS
-Path <String>
Path to the file to be executed. If the file is located directly in the "Files" directory of the App Deploy Toolkit, only the file name
needs to be specified.
Otherwise, the full path of the file must be specified. If the files is in a subdirectory of "Files", use the "$dirFiles" variable as
shown in the example.
-Parameters <String[]>
-SecureParameters [<SwitchParameter>]
Hides all parameters passed to the executable from the Toolkit log file
-WindowStyle
Style of the window of the process executed. Options: Normal, Hidden, Maximized, Minimized. Default: Normal.
Note: Not all processes honor the "Hidden" flag. If it it not working, then check the command line options for the process being
executed to see it has a silent option.
-CreateNoWindow [<SwitchParameter>]
Specifies whether the process should be started with a new window to contain it. Default is false.
-WorkingDirectory <String>
The working directory used for executing the process. Defaults to the directory of the file being executed.
-NoWait [<SwitchParameter>]
-PassThru [<SwitchParameter>]
-WaitForMsiExec [<SwitchParameter>]
Sometimes an EXE bootstrapper will launch an MSI install. In such cases, this variable will ensure that
this function waits for the msiexec engine to become available before starting the install.
-MsiExecWaitTime <TimeSpan>
Specify the length of time in seconds to wait for the msiexec engine to become available. Default: 600 seconds (10 minutes).
-IgnoreExitCodes <String>
-ContinueOnError <Boolean>
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
Continue if an exit code is returned by the process that is not recognized by the App Deploy Toolkit. Default: $false.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
If the file is in the "Files" directory of the App Deploy Toolkit, only the file name needs to be specified.
Launch InstallShield "setup.exe" from the ".\Files" sub-directory and force log files to the logging folder.
Launch InstallShield "setup.exe" with embedded MSI and force log files to the logging folder.
REMARKS
EXECUTE-PROCESSASUSER
SYNOPSIS
Execute a process with a logged in user account, by using a scheduled task, to provide interaction with user in the SYSTEM context.
SYNTAX
DESCRIPTION
Execute a process with a logged in user account, by using a scheduled task, to provide interaction with user in the SYSTEM context.
PARAMETERS
-UserName <String>
Logged in Username under which to run the process from. Default is: The active console user. If no console user exists but users
are logged in, such as on terminal servers, then the first
-Path <String>
-Parameters <String>
-SecureParameters [<SwitchParameter>]
Hides all parameters passed to the executable from the Toolkit log file.
-RunLevel <String>
Specifies the level of user rights that Task Scheduler uses to run the task. The acceptable values for this parameter are:
- HighestAvailable: Tasks run by using the highest available privileges (Admin privileges for Administrators). Default Value.
- LeastPrivilege: Tasks run by using the least-privileged user account (LUA) privileges.
-Wait [<SwitchParameter>]
Wait for the process, launched by the scheduled task, to complete execution before accepting more input. Default is $false.
-PassThru [<SwitchParameter>]
Returns the exit code from this function or the process launched by the scheduled task.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Execute process under a user account by specifying a username under which to execute it.
Execute process under a user account by using the default active logged in user that was detected when the toolkit was launched.
REMARKS
EXIT-SCRIPT
SYNOPSIS
Exit the script, perform cleanup actions, and pass an exit code to the parent process.
SYNTAX
DESCRIPTION
Always use when exiting the script to ensure cleanup actions are performed.
PARAMETERS
-ExitCode <Int32>
The exit code to be passed from the script to the parent process, e.g. SCCM
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Exit-Script -ExitCode 0
REMARKS
GET-FILEVERSION
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-File <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
GET-FREEDISKSPACE
SYNOPSIS
Retrieves the free disk space in MB on a particular drive (defaults to system drive)
SYNTAX
DESCRIPTION
Retrieves the free disk space in MB on a particular drive (defaults to system drive)
PARAMETERS
-Drive <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
GET-HARDWAREPLATFORM
SYNTAX
DESCRIPTION
PARAMETERS
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Get-HardwarePlatform
REMARKS
GET-INIVALUE
SYNOPSIS
Parses an INI file and returns the value of the specified section and key.
SYNTAX
Get-IniValue [-FilePath] <String> [-Section] <String> [-Key] <String> [[-ContinueOnError] <Boolean>] [<CommonParameters>]
DESCRIPTION
Parses an INI file and returns the value of the specified section and key.
-FilePath <String>
-Section <String>
-Key <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
SYNTAX
DESCRIPTION
Retrieves information about installed applications by querying the registry. You can specify an application name, a product code,
or both.
Returns information about application publisher, name & version, product code, uninstall string, install source, location, date, and
application architecture.
PARAMETERS
-Name <String[]>
The name of the application to retrieve information for. Performs a contains match on the application display name by default.
-Exact [<SwitchParameter>]
Specifies that the named application must be matched using the exact name.
-WildCard [<SwitchParameter>]
Specifies that the named application must be matched using a wildcard search.
-RegEx [<SwitchParameter>]
Specifies that the named application must be matched using a regular expression search.
-ProductCode <String>
-IncludeUpdatesAndHotfixes [<SwitchParameter>]
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
GET-LOGGEDONUSER
SYNOPSIS
Get session details for all local and RDP logged on users.
SYNTAX
Get-LoggedOnUser [<CommonParameters>]
DESCRIPTION
Get session details for all local and RDP logged on users using Win32 APIs. Get the following session details:
PARAMETERS
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Get-LoggedOnUser
REMARKS
GET-PENDINGREBOOT
SYNOPSIS
SYNTAX
Get-PendingReboot [<CommonParameters>]
DESCRIPTION
Check WMI and the registry to determine if the system has a pending reboot operation from any of the following:
PARAMETERS
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Get-PendingReboot
PendingFileRenameOperations, ErrorMsg
Returns boolean value determining whether or not there is a pending reboot operation.
REMARKS
GET-REGISTRYKEY
SYNOPSIS
Retrieves value names and value data for a specified registry key or optionally, a specific value.
SYNTAX
DESCRIPTION
Retrieves value names and value data for a specified registry key or optionally, a specific value.
If the registry key does not exist or contain any values, the function will return $null by default. To test for existence of a registry
key path, use built-in Test-Path cmdlet.
PARAMETERS
-Key <String>
-Value <String>
-SID <String>
The security identifier (SID) for a user. Specifying this parameter will convert a HKEY_CURRENT_USER registry key to the
HKEY_USERS\$SID format.
Specify this parameter from the Invoke-HKCURegistrySettingsForAllUsers function to read/edit HKCU registry settings for all
users on the system.
-ReturnEmptyKeyIfExists [<SwitchParameter>]
Return the registry key if it exists but it has no property/value pairs underneath it. Default is: $false.
-DoNotExpandEnvironmentNames [<SwitchParameter>]
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
GET-SCHEDULEDTASK
SYNOPSIS
SYNTAX
DESCRIPTION
Retrieve all details for scheduled tasks on the local computer using schtasks.exe. All property names have spaces and colons
removed.
PARAMETERS
-TaskName <String>
Specify the name of the scheduled task to retrieve details for. Uses regex match to find scheduled task.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Get-ScheduledTask
PS C:\>Get-ScheduledTask | Out-GridView
REMARKS
SYNTAX
DESCRIPTION
PARAMETERS
-Name <String>
-ComputerName <String>
Specify the name of the computer. Default is: the local computer.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
GET-UNIVERSALDATE
SYNOPSIS
SYNTAX
DESCRIPTION
Converts the current datetime or a datetime string for the current culture into a universal sortable date time pattern, e.g. 2013-
08-22 11:51:52Z
PARAMETERS
-DateTime <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Get-UniversalDate
Returns the date for the current culture in a universal sortable date time pattern.
REMARKS
GET-USERPROFILES
SYNOPSIS
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
Get the User Profile Path, User Account Sid, and the User Account Name for all users that log onto the machine and also the
Default User (which does not log on).
SYNTAX
DESCRIPTION
Get the User Profile Path, User Account Sid, and the User Account Name for all users that log onto the machine and also the
Default User (which does not log on).
Please note that the NTAccount property may be empty for some user profiles but the SID and ProfilePath properties will always
be populated.
PARAMETERS
-ExcludeNTAccount <String[]>
Specify NT account names in Domain\Username format to exclude from the list of user profiles.
-ExcludeSystemProfiles <Boolean>
Exclude system profiles: SYSTEM, LOCAL SERVICE, NETWORK SERVICE. Default is: $true.
-ExcludeDefaultUser [<SwitchParameter>]
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Get-UserProfiles
Returns the following properties for each user profile on the system: NTAccount, SID, ProfilePath
Returns the user profile path for each user on the system. This information can then be used to make modifications under the user
profile on the filesystem.
GET-WINDOWTITLE
SYNOPSIS
Search for an open window title and return details about the window.
SYNTAX
DESCRIPTION
Search for a window title. If window title searched for returns more than one result, then details for each window will be
displayed.
Returns the following properties for each window: WindowTitle, WindowHandle, ParentProcess,
ParentProcessMainWindowHandle, ParentProcessId.
Function does not work in SYSTEM context unless launched with "psexec.exe -s -i" to run it as an interactive process under the
SYSTEM account.
PARAMETERS
-WindowTitle <String>
The title of the application window to search for using regex matching.
-GetAllWindowTitles [<SwitchParameter>]
-DisableFunctionLogging [<SwitchParameter>]
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Gets details for each window that has the words "Microsoft Word" in the title.
PS C:\>Get-WindowTitle -GetAllWindowTitles
Get details for all windows belonging to Microsoft Word process with name "WINWORD".
REMARKS
INSTALL-MSUPDATES
SYNOPSIS
SYNTAX
DESCRIPTION
Install all Microsoft Updates of type ".exe", ".msu", or ".msp" in a given directory (recursively search directory).
PARAMETERS
-Directory <String>
<CommonParameters>
REMARKS
INSTALL-SCCMSOFTWAREUPDATES
SYNOPSIS
Scans for outstanding SCCM updates to be installed and installs the pending updates.
SYNTAX
DESCRIPTION
Scans for outstanding SCCM updates to be installed and installs the pending updates.
Only compatible with SCCM 2012 Client or higher. This function can take several minutes to run.
PARAMETERS
-SoftwareUpdatesScanWaitInSeconds <Int32>
The amount of time to wait in seconds for the software updates scan to complete. Default is: 180 seconds.
-WaitForPendingUpdatesTimeout <TimeSpan>
The amount of time to wait for missing and pending updates to install before exiting the function. Default is: 45 minutes.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
INVOKE-HKCUREGISTRYSETTINGSFORALLUSERS
SYNOPSIS
Set current user registry settings for all current users and any new users in the future.
SYNTAX
DESCRIPTION
Set HKCU registry settings for all current and future users by loading their NTUSER.dat registry hive file, and making the
modifications.
This function will modify HKCU settings for all users even when executed under the SYSTEM account.
To ensure new users in the future get the registry edits, the Default User registry hive used to provision the registry for new users
is modified.
This function can be used as an alternative to using ActiveSetup for registry settings.
The advantage of using this function over ActiveSetup is that a user does not have to log off and log back on before the changes
take effect.
PARAMETERS
-RegistrySettings <ScriptBlock>
Script block which contains HKCU registry settings which should be modified for all users on the system. Must specify the -SID
parameter for all HKCU settings.
-UserProfiles <PSObject[]>
Specify the user profiles to modify HKCU registry settings for. Default is all user profiles except for system profiles.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>[scriptblock]$HKCURegistrySettings = {
REMARKS
INVOKE-REGISTERORUNREGISTERDLL
SYNOPSIS
SYNTAX
DESCRIPTION
Register or unregister a DLL file using regsvr32.exe. Function can be invoked using alias: 'Register-DLL' or 'Unregister-DLL'.
PARAMETERS
-FilePath <String>
-DLLAction <String>
Specify whether to register or unregister the DLL. Optional if function is invoked using 'Register-DLL' or 'Unregister-DLL' alias.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Register DLL file using the "Register-DLL" alias for this function
Unregister DLL file using the "Unregister-DLL" alias for this function
REMARKS
INVOKE-SCCMTASK
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-ScheduleID <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Invoke-SCCMTask 'SoftwareUpdatesScan'
PS C:\>Invoke-SCCMTask
REMARKS
NEW-FOLDER
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-Path <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
NEW-MSITRANSFORM
SYNOPSIS
SYNTAX
DESCRIPTION
Create a transform file for an MSI database and create/modify properties in the Properties table.
PARAMETERS
-MsiPath <String>
Specify the path to a transform which should be applied to the MSI database before any new properties are created or
modified.
-NewTransformPath <String>
Specify the path where the new transform file with the desired properties will be created. If a transform file of the same name
already exists, it will be deleted before a new one is
created.
Default is: a) If -ApplyTransformPath was specified but not -NewTransformPath, then <ApplyTransformPath>.new.mst
-TransformProperties <Hashtable>
Hashtable which contains calls to Set-MsiProperty for configuring the desired properties which should be included in new
transform file.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>[hashtable]$TransformProperties = {
'ALLUSERS' = '1'
'AgreeToLicense' = 'Yes'
'REBOOT' = 'ReallySuppress'
'RebootYesNo' = 'No'
'ROOTDRIVE' = 'C:'
REMARKS
NEW-SHORTCUT
SYNOPSIS
SYNTAX
New-Shortcut [-Path] <String> [-TargetPath] <String> [[-Arguments] <String>] [[-IconLocation] <String>] [[-IconIndex] <String>] [[-
Description] <String>] [[-WorkingDirectory] <String>]
DESCRIPTION
PARAMETERS
-Path <String>
-TargetPath <String>
-Arguments <String>
-IconLocation <String>
-IconIndex <String>
Executables, DLLs, ICO files with multiple icons need the icon index to be specified
-Description <String>
-WorkingDirectory <String>
-WindowStyle <String>
Windows style of the application. Options: Normal, Maximized, Minimized. Default is: Normal.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
-RunAsAdmin [<SwitchParameter>]
Set shortcut to run program as administrator. This option will prompt user to elevate when executing shortcut.
-Hotkey <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
REMOVE-FILE
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
-Path <String[]>
Specifies the path on the filesystem to be resolved. The value of Path will accept wildcards. Will accept an array of values.
-LiteralPath <String[]>
Specifies the path on the filesystem to be resolved. The value of LiteralPath is used exactly as it is typed; no characters are
interpreted as wildcards. Will accept an array of values.
-Recurse [<SwitchParameter>]
Deletes the files in the specified location(s) and in all child items of the location(s).
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
REMOVE-FOLDER
SYNOPSIS
SYNTAX
DESCRIPTION
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
Remove folder and all files recursively in a given path.
PARAMETERS
-Path <String>
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
REMOVE-MSIAPPLICATIONS
SYNOPSIS
SYNTAX
Remove-MSIApplications [-Name] <String> [-Exact] [-WildCard] [[-Parameters] <String>] [[-AddParameters] <String>] [[-
FilterApplication] <Array>] [[-ExcludeFromUninstall] <Array>]
DESCRIPTION
"msiexec".
PARAMETERS
-Name <String>
The name of the application to uninstall. Performs a contains match on the application display name by default.
-Exact [<SwitchParameter>]
Specifies that the named application must be matched using the exact name.
-WildCard [<SwitchParameter>]
Specifies that the named application must be matched using a wildcard search.
-Parameters <String>
Overrides the default parameters specified in the XML configuration file. Uninstall default is: "REBOOT=ReallySuppress /QN".
-AddParameters <String>
Adds to the default parameters specified in the XML configuration file. Uninstall default is: "REBOOT=ReallySuppress /QN".
-FilterApplication <Array>
Two-dimensional array that contains one or more (property, value, match-type) sets that should be used to filter the list of
results returned by Get-InstalledApplication to only those that
should be uninstalled.
Properties that can be filtered upon: ProductCode, DisplayName, DisplayVersion, UninstallString, InstallSource, InstallLocation,
InstallDate, Publisher, Is64BitApplication
-ExcludeFromUninstall <Array>
Two-dimensional array that contains one or more (property, value, match-type) sets that should be excluded from uninstall if
found.
Properties that can be excluded: ProductCode, DisplayName, DisplayVersion, UninstallString, InstallSource, InstallLocation,
InstallDate, Publisher, Is64BitApplication
-IncludeUpdatesAndHotfixes [<SwitchParameter>]
-LoggingOptions <String>
Overrides the default logging options specified in the XML configuration file. Default options are: "/L*v".
-private:LogName <String>
-PassThru [<SwitchParameter>]
-ContinueOnError <Boolean>
Continue if an exit code is returned by msiexec that is not recognized by the App Deploy Toolkit. Default is: $true.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Removes all versions of software that match the name "Adobe Flash"
Removes all versions of software that match the name "Java 8 Update" where the software is 32-bits and the publisher is "Oracle
Corporation".
Removes all versions of software that match the name "Java 8 Update" and also have "Oracle Corporation" as the Publisher;
however, it does not uninstall "Java 8 Update 45" of the software.
NOTE: if only specifying a single row in the two-dimensional arrays, the array must have the extra parentheses and leading comma
as in this example.
PS C:\>Remove-MSIApplications -Name 'Java 8 Update' -ExcludeFromUninstall (,('DisplayName', 'Java 8 Update 45', 'Contains'))
Removes all versions of software that match the name "Java 8 Update"; however, it does not uninstall "Java 8 Update 45" of the
software.
NOTE: if only specifying a single row in the two-dimensional array, the array must have the extra parentheses and leading comma
as in this example.
Removes all versions of software that match the name "Java 8 Update"; however, it does not uninstall 64-bit versions of the
software, Update 45 of the software, or any Update that starts with
4.
REMARKS
REMOVE-REGISTRYKEY
SYNOPSIS
SYNTAX
Remove-RegistryKey [-Key] <String> [[-Name] <String>] [-Recurse] [[-SID] <String>] [[-ContinueOnError] <Boolean>]
[<CommonParameters>]
DESCRIPTION
PARAMETERS
-Key <String>
-Name <String>
-Recurse [<SwitchParameter>]
-SID <String>
The security identifier (SID) for a user. Specifying this parameter will convert a HKEY_CURRENT_USER registry key to the
HKEY_USERS\$SID format.
Specify this parameter from the Invoke-HKCURegistrySettingsForAllUsers function to read/edit HKCU registry settings for all
users on the system.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
RESOLVE-ERROR
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-ErrorRecord <Array>
The error record to resolve. The default error record is the latest one: $global:Error[0]. This parameter will also accept an array
of error records.
-Property <String[]>
The list of properties to display from the error record. Use "*" to display all properties.
Default list of error properties is: Message, FullyQualifiedErrorId, ScriptStackTrace, PositionMessage, InnerException
-GetErrorRecord [<SwitchParameter>]
-GetErrorInvocation [<SwitchParameter>]
-GetErrorException [<SwitchParameter>]
-GetErrorInnerException [<SwitchParameter>]
Get error record inner exception details as represented by $_.Exception.InnerException. Will retrieve all inner exceptions if
there is more than one.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Resolve-Error
PS C:\>Resolve-Error -Property *
PS C:\>Resolve-Error -GetErrorInvocation:$false
SEND-KEYS
SYNOPSIS
SYNTAX
DESCRIPTION
Send a sequence of keys to one or more application window. If window title searched for returns more than one window, then all
of them will receive the sent keys.
Function does not work in SYSTEM context unless launched with "psexec.exe -s -i" to run it as an interactive process under the
SYSTEM account.
PARAMETERS
-WindowTitle <String>
The title of the application window to search for using regex matching.
-GetAllWindowTitles [<SwitchParameter>]
-WindowHandle <IntPtr>
Send keys to a specific window where the Window Handle is already known.
-Keys <String>
-WaitSeconds <Int32>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Send the sequence of keys "Hello world" to the application titled "foobar - Notepad".
Send the sequence of keys "Hello world" to the application titled "foobar - Notepad" and wait 5 seconds.
Send the sequence of keys "Hello world" to the application with a Window Handle of '17368294'.
REMARKS
SET-ACTIVESETUP
SYNOPSIS
Creates an Active Setup entry in the registry to execute a file for each user upon login.
SYNTAX
Set-ActiveSetup -StubExePath <String> [-Arguments <String>] [-Description <String>] [-Key <String>] [-Version <String>] [-Locale
<String>] [-DisableActiveSetup] [-ContinueOnError <Boolean>]
[<CommonParameters>]
DESCRIPTION
Active Setup allows handling of per-user changes registry/file changes upon login.
A registry key is created in the HKLM registry hive which gets replicated to the HKCU hive when a user logs in.
This Function:
- Creates StubPath value depending on the file extension of the $StubExePath parameter.
- Handles Version value with YYYYMMDDHHMMSS granularity to permit re-installs on the same day and still trigger Active Setup
after Version increase.
- Copies/overwrites the StubPath file to $StubExePath destination path if file exists in 'Files' subdirectory of script directory.
- Executes the StubPath file for the current user as long as not in Session 0 (no need to logout/login to trigger Active Setup).
PARAMETERS
-StubExePath <String>
Full destination path to the file that will be executed for each user that logs in.
If this file exists in the 'Files' subdirectory of the script directory, it will be copied to the destination path.
-Arguments <String>
-Description <String>
Description for the Active Setup. Users will see "Setting up personalized settings for: $Description" at logon. Default is:
$installName.
-Key <String>
Name of the registry key for the Active Setup entry. Default is: $installName.
-Version <String>
Optional. Specify version for Active setup entry. Active Setup is not triggered if Version value has more than 8 consecutive digits.
Use commas to get around this limitation.
-Locale <String>
Optional. Arbitrary string used to specify the installation language of the file being executed. Not replicated to HKCU.
-DisableActiveSetup [<SwitchParameter>]
Disables the Active Setup entry so that the StubPath file will not be executed.
-PurgeActiveSetupKey [<SwitchParameter>]
Remove Active Setup entry from HKLM registry hive. Will also load each logon user's HKCU registry hive to remove Active Setup
entry.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
SET-INIVALUE
SYNOPSIS
Opens an INI file and sets the value of the specified section and key.
SYNTAX
Set-IniValue [-FilePath] <String> [-Section] <String> [-Key] <String> [-Value] <Object> [[-ContinueOnError] <Boolean>]
[<CommonParameters>]
DESCRIPTION
Opens an INI file and sets the value of the specified section and key.
-FilePath <String>
-Section <String>
-Key <String>
-Value <Object>
Value for the key within the section of the INI file. To remove a value, set this variable to $null.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
SET-PINNEDAPPLICATION
SYNOPSIS
SYNTAX
This should typically be run in the user context, as pinned items are stored in the user profile.
PARAMETERS
-Action <String>
-FilePath <String>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
SET-REGISTRYKEY
SYNOPSIS
Creates a registry key name, value, and value data; it sets the same if it already exists.
SYNTAX
Set-RegistryKey [-Key] <String> [[-Name] <String>] [[-Value] <Object>] [[-Type] {Unknown | String | ExpandString | Binary | DWord
| MultiString | QWord | None}] [[-SID] <String>]
Creates a registry key name, value, and value data; it sets the same if it already exists.
PARAMETERS
-Key <String>
-Name <String>
-Value <Object>
-Type
-SID <String>
The security identifier (SID) for a user. Specifying this parameter will convert a HKEY_CURRENT_USER registry key to the
HKEY_USERS\$SID format.
Specify this parameter from the Invoke-HKCURegistrySettingsForAllUsers function to read/edit HKCU registry settings for all
users on the system.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
(0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0
x01,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x02,0x02,0x02) -Type 'Binary'
REMARKS
SET-SERVICESTARTMODE
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-Name <String>
-ComputerName <String>
Specify the name of the computer. Default is: the local computer.
-StartMode <String>
Specify startup mode for the service. Options: Automatic, Automatic (Delayed Start), Manual, Disabled, Boot, System.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
SHOW-BALLOONTIP
SYNOPSIS
SYNTAX
Show-BalloonTip [-BalloonTipText] <String> [[-BalloonTipTitle] <String>] [[-BalloonTipIcon] {None | Info | Warning | Error}] [[-
BalloonTipTime] <Int32>] [<CommonParameters>]
DESCRIPTION
PARAMETERS
-BalloonTipText <String>
-BalloonTipTitle <String>
-BalloonTipIcon
Icon to be used. Options: 'Error', 'Info', 'None', 'Warning'. Default is: Info.
-BalloonTipTime <Int32>
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
Time in milliseconds to display the balloon tip. Default: 500.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
SHOW-DIALOGBOX
SYNOPSIS
Display a custom dialog box with optional title, buttons, icon and timeout.
Show-InstallationPrompt is recommended over this function as it provides more customization and uses consistent branding with
the other UI components.
SYNTAX
Show-DialogBox [-Text] <String> [-Title <String>] [-Buttons <String>] [-DefaultButton <String>] [-Icon <String>] [-Timeout <String>]
[-TopMost <Boolean>] [<CommonParameters>]
DESCRIPTION
Display a custom dialog box with optional title, buttons, icon and timeout. The default button is "OK", the default Icon is "None",
and the default Timeout is none.
PARAMETERS
-Text <String>
-Buttons <String>
Buttons to be included on the dialog box. Options: OK, OKCancel, AbortRetryIgnore, YesNoCancel, YesNo, RetryCancel,
CancelTryAgainContinue. Default: OK.
-DefaultButton <String>
The Default button that is selected. Options: First, Second, Third. Default: First.
-Icon <String>
Icon to display on the dialog box. Options: None, Stop, Question, Exclamation, Information. Default: None.
-Timeout <String>
Timeout period in seconds before automatically closing the dialog box with the return message "Timeout". Default: UI timeout
value set in the config XML file.
-TopMost <Boolean>
Specifies whether the message box is a system modal message box and appears in a topmost window. Default: $true.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Show-DialogBox -Title 'Installed Complete' -Text 'Installation has completed. Please click OK and restart your computer.'
-Icon 'Information'
PS C:\>Show-DialogBox -Title 'Installation Notice' -Text 'Installation will take approximately 30 minutes. Do you wish to proceed?'
-Buttons 'OKCancel' -DefaultButton 'Second' -Icon
REMARKS
SYNTAX
DESCRIPTION
Create a WPF window in a separate thread to display a marquee style progress ellipse with a custom message that can be
updated.
The first time this function is called in a script, it will display a balloon tip notification to indicate that the installation has started
(provided balloon tips are enabled in the
configuration).
PARAMETERS
-StatusMessage <String>
The status message to be displayed. The default status message is taken from the XML configuration file.
-WindowLocation <String>
The location of the progress window. Default: just below top, centered.
-TopMost <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Show-InstallationProgress
Uses the default status message from the XML configuration file.
REMARKS
SHOW-INSTALLATIONPROMPT
SYNOPSIS
Displays a custom installation prompt with the toolkit branding and optional buttons.
SYNTAX
Show-InstallationPrompt [[-Title] <String>] [[-Message] <String>] [[-MessageAlignment] <String>] [[-ButtonRightText] <String>] [[-
ButtonLeftText] <String>] [[-ButtonMiddleText] <String>]
[[-Icon] <String>] [-NoWait] [-PersistPrompt] [[-MinimizeWindows] <Boolean>] [[-Timeout] <Int32>] [[-ExitOnTimeout] <Boolean>]
[<CommonParameters>]
DESCRIPTION
Any combination of Left, Middle or Right buttons can be displayed. The return value of the button clicked by the user is the button
text specified.
PARAMETERS
-Title <String>
-Message <String>
-MessageAlignment <String>
Alignment of the message text. Options: Left, Center, Right. Default: Center.
-ButtonRightText <String>
-ButtonLeftText <String>
Show a button on the left of the prompt with the specified text
-ButtonMiddleText <String>
Show a button in the middle of the prompt with the specified text
-Icon <String>
Show a system icon in the prompt. Options: Application, Asterisk, Error, Exclamation, Hand, Information, None, Question, Shield,
Warning, WinLogo. Default: None.
-NoWait [<SwitchParameter>]
Specifies whether to show the prompt asynchronously (i.e. allow the script to continue without waiting for a response). Default:
$false.
-PersistPrompt [<SwitchParameter>]
Specify whether to make the prompt persist in the center of the screen every 10 seconds. The user will have no option but to
respond to the prompt - resistance is futile!
-MinimizeWindows <Boolean>
Specifies whether to minimize other windows when displaying prompt. Default: $false.
-Timeout <Int32>
Specifies the time period in seconds after which the prompt should timeout. Default: UI timeout value set in the config XML file.
-ExitOnTimeout <Boolean>
Specifies whether to exit the script if the UI times out. Default: $true.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Show-InstallationPrompt -Message 'Do you want to proceed with the installation?' -ButtonRightText 'Yes' -ButtonLeftText
'No'
PS C:\>Show-InstallationPrompt -Title 'Funny Prompt' -Message 'How are you feeling today?' -ButtonRightText 'Good'
-ButtonLeftText 'Bad' -ButtonMiddleText 'Indifferent'
PS C:\>Show-InstallationPrompt -Message 'You can customize text to appear at the end of an install, or remove it completely for
unattended installations.' -Icon Information -NoWait
REMARKS
SHOW-INSTALLATIONRESTARTPROMPT
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-CountdownSeconds <Int32>
-CountdownNoHideSeconds <Int32>
Specifies the number of seconds to display the restart prompt without allowing the window to be hidden.
-NoCountdown [<SwitchParameter>]
Specifies not to show a countdown, just the Restart Now and Restart Later buttons.
The UI will restore/reposition itself persistently based on the interval value specified in the config file.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Show-InstallationRestartPrompt -NoCountdown
REMARKS
SHOW-INSTALLATIONWELCOME
SYNOPSIS
Show a welcome dialog prompting the user with information about the installation and actions to be performed before the
installation can begin.
SYNTAX
[<CommonParameters>]
DESCRIPTION
a) Close the specified running applications, or optionally close the applications without showing a prompt (using the -Silent
switch).
b) Defer the installation a certain number of times, for a certain number of days or until a deadline is reached.
d) Prevent users from launching the specified applications while the installation is in progress.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
Notes:
The process descriptions are retrieved from WMI, with a fall back on the process name if no description is available. Alternatively,
you can specify the description yourself with a '=' symbol
- see examples.
The dialog box will timeout after the timeout specified in the XML configuration file (default 1 hour and 55 minutes) to prevent
SCCM installations from timing out and returning a failure
code to SCCM. When the dialog times out, the script will exit and return a 1618 code (SCCM fast retry code).
PARAMETERS
-CloseApps <String>
Name of the process to stop (do not include the .exe). Specify multiple processes separated by a comma. Specify custom
descriptions like this: "winword=Microsoft Office
-Silent [<SwitchParameter>]
-CloseAppsCountdown <Int32>
Option to provide a countdown in seconds until the specified applications are automatically closed. This only takes effect if
deferral is not allowed or has expired.
-ForceCloseAppsCountdown <Int32>
Option to provide a countdown in seconds until the specified applications are automatically closed regardless of whether
deferral is allowed.
-PromptToSave [<SwitchParameter>]
Specify whether to prompt to save working documents when the user chooses to close applications by selecting the "Close
Programs" button. Option does not work in SYSTEM context unless
toolkit launched with "psexec.exe -s -i" to run it as an interactive process under the SYSTEM account.
-PersistPrompt [<SwitchParameter>]
Specify whether to make the prompt persist in the center of the screen every 10 seconds. The user will have no option but to
respond to the prompt. This only takes effect if deferral is
-BlockExecution [<SwitchParameter>]
Option to prevent the user from launching the process/application during the installation.
-AllowDefer [<SwitchParameter>]
Enables an optional defer button to allow the user to defer the installation.
Enables an optional defer button to allow the user to defer the installation only if there are running applications that need to be
closed.
-DeferTimes <Int32>
-DeferDays <Int32>
Specify the number of days since first run that the installation can be deferred. This is converted to a deadline.
-DeferDeadline <String>
Specify the deadline date until which the installation can be deferred.
Specify the date in the local culture if the script is intended for that same culture.
If the script is intended to run on EN-US machines, specify the date in the format: "08/25/2013" or "08-25-2013" or "08-25-2013
18:00:00"
If the script is intended for multiple cultures, specify the date in the universal sortable date/time format: "2013-08-22
11:51:52Z"
The deadline date will be displayed to the user in the format of their culture.
-CheckDiskSpace [<SwitchParameter>]
Specify whether to check if there is enough disk space for the installation to proceed.
If this parameter is specified without the RequiredDiskSpace parameter, the required disk space is calculated automatically
based on the size of the script source and associated files.
-RequiredDiskSpace <Int32>
-MinimizeWindows <Boolean>
Specifies whether to minimize other windows when displaying prompt. Default: $true.
-TopMost <Boolean>
-ForceCountdown <Int32>
Specify a countdown to display before automatically proceeding with the installation when a deferral is enabled.
-CustomText [<SwitchParameter>]
Specify whether to display a custom message specified in the XML file. Custom message must be populated for each language
section in the XML.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Close Word and Excel and prevent the user from launching the applications while the installation is in progress.
Prompt the user to close Word and Excel, with customized descriptions for the applications and automatically close the
applications after 10 minutes.
By using the PersistPrompt switch, the dialog will return to the center of the screen every 10 seconds so the user cannot ignore it
by dragging it aside.
Allow the user to defer the installation until the deadline is reached.
Close Word and Excel and prevent the user from launching the applications while the installation is in progress.
Allow the user to defer the installation a maximum of 10 times or until the deadline is reached, whichever happens first.
REMARKS
START-SERVICEANDDEPENDENCIES
SYNOPSIS
SYNTAX
<Boolean>] [<CommonParameters>]
DESCRIPTION
PARAMETERS
-Name <String>
-ComputerName <String>
Specify the name of the computer. Default is: the local computer.
-SkipServiceExistsTest [<SwitchParameter>]
Choose to skip the test to check whether or not the service exists if it was already done outside of this function.
-SkipDependentServices [<SwitchParameter>]
Choose to skip checking for and starting dependent services. Default is: $false.
-PendingStatusWait <TimeSpan>
The amount of time to wait for a service to get out of a pending state before continuing. Default is 60 seconds.
-PassThru [<SwitchParameter>]
-ContinueOnError <Boolean>
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
Continue if an error is encountered. Default is: $true.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
STOP-SERVICEANDDEPENDENCIES
SYNOPSIS
SYNTAX
<Boolean>] [<CommonParameters>]
DESCRIPTION
PARAMETERS
-Name <String>
-ComputerName <String>
Specify the name of the computer. Default is: the local computer.
-SkipServiceExistsTest [<SwitchParameter>]
Choose to skip the test to check whether or not the service exists if it was already done outside of this function.
POWERSHELL APP DEPLOYMENT TOOLKIT | Administrator’s Guide
-SkipDependentServices [<SwitchParameter>]
Choose to skip checking for and stopping dependent services. Default is: $false.
-PendingStatusWait <TimeSpan>
The amount of time to wait for a service to get out of a pending state before continuing. Default is 60 seconds.
-PassThru [<SwitchParameter>]
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
TEST-BATTERY
SYNOPSIS
SYNTAX
DESCRIPTION
Tests whether the local machine is running on AC power and returns true/false. For detailed information, use -PassThru option.
PARAMETERS
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Test-Battery
PS C:\>(Test-Battery -PassThru).IsLaptop
REMARKS
TEST-MSUPDATES
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-KBNumber <String>
Suppress writing log message to console on failure to write message to log file. Default is: $true.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
Tests for an active local network connection, excluding wireless and virtual network adapters.
SYNTAX
Test-NetworkConnection [<CommonParameters>]
DESCRIPTION
Tests for an active local network connection, excluding wireless and virtual network adapters, by querying the
Win32_NetworkAdapter WMI class.
PARAMETERS
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Test-NetworkConnection
REMARKS
TEST-POWERPOINT
SYNOPSIS
Tests whether PowerPoint is running in either fullscreen slideshow mode or presentation mode.
SYNTAX
Test-PowerPoint [<CommonParameters>]
DESCRIPTION
Tests whether someone is presenting using PowerPoint in either fullscreen slideshow mode or presentation mode.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Test-PowerPoint
REMARKS
TEST-REGISTRYVALUE
SYNOPSIS
SYNTAX
DESCRIPTION
Checks a registry key path to see if it has a value with a given name. Can correctly handle cases where a value simply has an empty
or null value.
PARAMETERS
-Key <Object>
-Value <Object>
-SID <String>
The security identifier (SID) for a user. Specifying this parameter will convert a HKEY_CURRENT_USER registry key to the
HKEY_USERS\$SID format.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
REMARKS
TEST-SERVICEEXISTS
SYNOPSIS
SYNTAX
DESCRIPTION
Check to see if a service exists (using WMI method because Get-Service will generate ErrorRecord if service doesn't exist).
PARAMETERS
-Name <String>
Note: Service name can be found by executing "Get-Service | Format-Table -AutoSize -Wrap" or by using the properties screen
of a service in services.msc.
-ComputerName <String>
Specify the name of the computer. Default is: the local computer.
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
Check if a service exists and then delete it by using the -PassThru parameter.
REMARKS
UPDATE-DESKTOP
SYNOPSIS
Refresh the Windows Explorer Shell, which causes the desktop icons and the environment variables to be reloaded.
SYNTAX
DESCRIPTION
Refresh the Windows Explorer Shell, which causes the desktop icons and the environment variables to be reloaded.
PARAMETERS
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Update-Desktop
REMARKS
UPDATE-GROUPPOLICY
SYNOPSIS
SYNTAX
DESCRIPTION
PARAMETERS
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Update-GroupPolicy
REMARKS
UPDATE-SESSIONENVIRONMENTVARIABLES
SYNOPSIS
Updates the environment variables for the current PowerShell session with any environment variable changes that may have
occurred during script execution.
SYNTAX
DESCRIPTION
Environment variable changes that take place during script execution are not visible to the current PowerShell session.
Use this function to refresh the current PowerShell session with all environment variable settings.
PARAMETERS
-LoadLoggedOnUserEnvironmentVariables [<SwitchParameter>]
If script is running in SYSTEM context, this option allows loading environment variables from the active console user. If no
console user exists but users are logged in, such as on
-ContinueOnError <Boolean>
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Update-SessionEnvironmentVariables
REMARKS
WRITE-LOG
SYNOPSIS
Write messages to a log file in CMTrace.exe compatible format or Legacy text file format.
SYNTAX
Write-Log [-Message] <String[]> [[-Severity] <Int16>] [[-Source] <String>] [[-ScriptSection] <String>] [[-LogType] <String>] [[-
LogFileDirectory] <String>] [[-LogFileName] <String>]
DESCRIPTION
Write messages to a log file in CMTrace.exe compatible format or Legacy text file format and optionally display in the console.
PARAMETERS
-Message <String[]>
-Severity <Int16>
Defines message type. When writing to console or CMTrace.exe log format, it allows highlighting of message type.
-Source <String>
-ScriptSection <String>
The heading for the portion of the script that is being executed. Default is: $script:installPhase.
-LogType <String>
Choose whether to write a CMTrace.exe compatible log file or a Legacy text log file.
-LogFileName <String>
-MaxLogFileSizeMB <Decimal>
Maximum file size limit for log file in megabytes (MB). Default is 10 MB.
-WriteHost <Boolean>
-ContinueOnError <Boolean>
Suppress writing log message to console on failure to write message to log file. Default is: $true.
-PassThru [<SwitchParameter>]
-DebugMessage [<SwitchParameter>]
Specifies that the message is a debug message. Debug messages only get logged if -LogDebugMessage is set to $true.
-LogDebugMessage <Boolean>
Debug messages only get logged if this parameter is set to $true in the config XML file.
<CommonParameters>
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
PS C:\>Write-Log -Message "Script is running on Windows 8" -Source 'Test-ValidOS' -LogType 'Legacy'
REMARKS