Unable to run PSADT within SCCM if there is PSADT module installed

I’ve run into a weird situation here and hope someone can shed me a light here. I am able to manually run PSADT toolkit fine but however it won’t run when I put it into SCCM. The log fie shows DeploymentType is [Installation] then it just stayed at that state until it got timed out. Doing troubleshooting by instead using Deploy-Application.exe, I’ve used deploy-application.ps1 instead and log file now shows it runs the script from installed PSADT module instead from package:
[Initialization] :: Script [C:\Program Files\WindowsPowerShell\Modules\PSADT\3.10.1\Public\AppDeployToolkitExtensions.ps1] dot-source invoked by [C:\WINDOWS\ccmcache\11\AppDeployToolkit\AppDeployToolkitMain.ps1]

After uninstall PSADT module, I am able to run the package fine using SCCM. I have tried to detect module and uninstall it in the deploy-application.ps1 but it still can’t be run since it keeps reading the appdeploytoolkitmain.ps1 first then stuck at that mode.
This issue does not occur if I am using old PSADT standalone tooklit version 3.7.0
Is there a way that I can modify AppDeployToolkitMain.ps1 so it can detect if module installed then it’ll uninstall and run from the package instead?

Update: look like PSADT module interfered all of PSADT standalone package deploy in sccm. I have many application with different version of PSADT standalone deployed and only application that has version 3.7.0 be able to run. Any application with version above 3.7.0 or later are failed. I have to create a task sequence to detect and uninstall PSADT module if installed.

1 Like

It’s strange that it only affects more recent versions, so there may be something that can be done to resolve this. But it should be made clear that the PSADT module is not made or supported by the PSADT team in any way.

In theory, as long as the PSADT module as not being loaded in your PSProfile, and AppDeployToolkitMain.ps1 is being dot-sourced before trying to call any functions that might trigger auto-loading of the module, this should not happen.

You could try adding this near the top of Deploy-Application.ps1 to prevent any modules being loaded automatically:

$PSModuleAutoloadingPreference = 'none'
1 Like