Hi.
Created a package and deployed from intune.
Very basic, copy two files from SupportFiles and working fine.
But, when uninstalling, I cant get the files deleted!
Install command in PSADT:
Copy-File -Path "$dirSupportFiles\*" -Destination "$envCommonDesktop"
Uninstall:
Remove-File -Path '$envCommonDesktop\file1.txt'
Remove-File -Path '$envCommonDesktop\file2.txt'
But - nothing happens when trying to uninstall.
Am I way off?
It looks like this is because you are using single quotes around the path.
If you have a variable within single quotes ($envCommonDesktop in your case), it is not expanded, meaning the command is trying to remove a file named $envCommonDesktop\file1.txt or $envCommonDesktop\file2.txt which neither exists.
IMHO you should change this to use double quotes, so the variable is correctly expanded, plus it is wise to wrap the variable within a $()
so that if the path contains spaces it is determined correctly, this would mean your lines should read::
Remove-File -Path "$($envCommonDesktop)\file1.txt"
Remove-File -Path "$($envCommonDesktop)\file2.txt"
1 Like
Still no luck.
User is not local admin and uninstall command in Intune is:
Deploy-Application.exe -Deploymentype Uninstall
Are you logging anything? if so, what does the log say?
N.B. The default location(s) of the log file are defined in AppDeployToolkitConfig.xml
Line 41:
<Toolkit_LogPath>$envWinDir\Logs\Software</Toolkit_LogPath>
and Line 48 (for no Admin rights):
<Toolkit_LogPathNoAdminRights>$envProgramData\Logs\Software</Toolkit_LogPathNoAdminRights>
See: PSAppDeployToolkit/Toolkit/AppDeployToolkit/AppDeployToolkitConfig.xml at f34b5538ba9dc6c05a6a10d0760be9ead58eca67 · PSAppDeployToolkit/PSAppDeployToolkit · GitHub
As you are using Intune, a hack I have found is updating both lines to “C:\ProgramData\Microsoft\IntuneManagementExtension\Logs” or rather:
$envProgramData\Microsoft\IntuneManagementExtension\Logs
This way you can then download them remotely from a device with the diagnostics bundle (when you run Collect Diagnostics) - see:
1 Like
MS likes to keep us on out toes so are constantly changing things. In my environment, $envCommonDesktop
is an unknown variable. Suggest you use the actual path (C:\Users\Public\Desktop).
1 Like
FYI: $envCommonDesktop
is a PSADT variable, so will only work inside a PSADT script or if you have dot sourced the toolkit
See Reference page (shows all PSADT environment variables):
Yoinks! I didn’t think about the PSADT vars. Good catch.
Still, unless there are overriding reasons for OP to NOT use the absolute path, it’s worth considering.
1 Like