Notes on PSADT

Been a while since I worked with PSADT so here’s a quick reminder to myself. PSADT is a god-send for anyone deploying applications via SCCM.

To install just run the script:

To uninstall:

You can deploy in the following -DeployModeInteractive (the default) or Silent or Noninteractive (very silent?).

When calling via SCCM you can use the Deploy-Application.exe helper instead. This will launch the script via PowerShell. Thus do the following for example:

As opposed to:

If you decide to rename Deploy-Application.ps1 or have another copy in the same folder you could run it thus:

By default if there’s a reboot requirement from the MSI this is passed on to the calling process. You can suppress it:

Logs are stored at C:\Windows\Logs\Software.

The only file you need to modify with PSADT is the Deploy-Application.ps1 file. Apart from that there are Files and SupportFiles folders – use the former for storing any MSI and setup files, use the latter for any other files you want to copy over to the target machine. Easy peasy. All other files can be ignored, but you can tweak them if you want to customize PSADT further such as add a logo and change colours etc. I haven’t customized them ever but I know my colleagues tend to do.

There’s a Zero Config MSI install method. This means you don’t modify the Deploy-Application.ps` file at all. You put the MSI in the Files folder. (Note: you can have only one MSI, so if more than one is put there only the first is used). You put the corresponding MST file (if any) in the Files folder. It must have the same name as the MSI, but with an MST extension of course. Finally you put any patches (MSP files) in the same Files folder – there can be more than one of these and they are installed in alphabetical order (so rename the files if order matters). All you do then is run the Deploy-Application.ps1 script.

The beauty of PSADT is that it gives you a ton of variables and helper functions you can use in the script. The best reference for all theses is their PDF guide. Pages 36-41 (as of this writing) have a list of all the variables while Page 41 onwards has a list of function.

You can determine if you are on a server for instance via the $IsServerOS variable, refer a user’s Desktop via $envUserDesktop or the profile itself via $envUserProfile, even things like the public desktop via $envCommonDesktop. These are just some examples, and nothing you can’t do in a longer way via PowerShell, but using PSADT gives you all these for free (which is always the point of a framework or language – give you things for free so you can focus on the bigger stuff). You can refer to the Files folder via $dirFiles and SupportFiles via $dirSupportFiles. For example the following uses a function provided by PSADT to copy over some files to C:\Windows:

An especially useful function is the Execute-MSI one. Here’s me using it to install Teams:

Notice I can specify:

  • an action (-Action 'Install', -Action 'Uninstall', Action 'Repair', -Action 'Patch', -Action 'ActiveSetup'),
  • parameters to the msixec process (the -Parameters switch overrides the defaults, but we can do -AddParameters to add instead or -SecureParameters to not show the paramters in any logs),
  • transforms (not shown above but use the -Transform switch),
  • any logging options via -LoggingOptions (default is /l*v to the default logging path)

I find this file to be a useful reference of all the functions. This is what gets pulled in to define the functions and variables. Some useful functions are the Get-UserProfiles which lists all the userprofiles on the machine (and the Profilepath property can be used to get the path of the profile) or Invoke-HKCURegistrySettingsForAllUsers which can do a registry operation against all the HKCU registry keys. Here’s me using the latter to delete certain Teams related keys:

I’ve put the Teams PSADT script I made (from which I showed snippets above) in this GitHub repo.

Useful links:

  • File with all the functions (you can search through it)
  • PDF guide
  • Not sure if this is an official site (doesn’t seem to be) but it has a reference of all the functions (it seems to be a website version of the PDF)