Three thoughts that spring to mind:
-
In what context are you doing the installation (User or System)?
I suspect if you are deploying in the User context some of that may not work due to the rights the user has on their device (That may be why you were unable to set the machine environment variable) -
I’m not sure if in the user context the Setup ISS file could be generated into that path (user might not have write permissions to
C:\Windows\IMECache\<Intune_Application_GUID>\
- Why don’t you create this static file and bundle it up with the Intunewin file in the Files sub-directory?
That way the file will always exist within the deployment correctly . You can then remove the definition of $setupiss and writing this to a file within yourDeploy-Application.ps1
-
Logging - if you write debug information to a log file, you might be able to determine what is going on - This might be of use:
How to Log built-in PowerShell commands (non-PSADT commands)
Update - Sorry your updated post with the logging overlapped with my post - ignore the logging comment