Execute process as user not working

Okay. Im trying to run a PS script that creates a task scheduler for the user that will run everytime the user is login in.

So in the config.xml is set to admin true.

I create a folder and copy the script to program files in that folder.

i cant figure out what is missing here.

The errors from the logs are here:

]LOG]!><time="16:02:57.08260" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The following users are logged on to the system: [AZUREAD\intunetest].]LOG]!><time="16:02:57.08260" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Current process is running with user account [AzureAD\Admin] under logged in user session for [AZUREAD\intunetest].]LOG]!><time="16:02:57.09860" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The following user is the console user [AZUREAD\intunetest] (user with control of physical monitor, keyboard, and mouse).]LOG]!><time="16:02:57.12060" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The active logged on user is [AZUREAD\intunetest].]LOG]!><time="16:02:57.15160" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The active logged on user [AZUREAD\intunetest] has a primary UI language of [DA].]LOG]!><time="16:02:57.16760" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The following UI messages were imported from the config XML file: [UI_Messages_DA].]LOG]!><time="16:02:57.18360" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: The active logged on user [AZUREAD\intunetest] has a DPI scale factor of [100] with DPI pixels [96].]LOG]!><time="16:02:57.18360" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Unable to load COM Object [Microsoft.SMS.TSEnvironment]. Therefore, script is not currently running from a SCCM Task Sequence.]LOG]!><time="16:02:57.20560" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Skipping attempt to check for and make the task scheduler services healthy, because the App Deployment Toolkit is not running under the [NT AUTHORITY\SYSTEM] account.]LOG]!><time="16:02:57.20560" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Session 0 not detected.]LOG]!><time="16:02:57.22160" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Installation is running in [Silent] mode.]LOG]!><time="16:02:57.23660" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Initialization] :: Deployment type is [Installation].]LOG]!><time="16:02:57.23660" date="02-10-2023" component="PSAppDeployToolkit" context="AzureAD\Admin" type="1" thread="9120" file="AppDeployToolkitMain.ps1">
<![LOG[[Pre-Installation] :: Bypassing Show-InstallationProgress [Mode: Silent]. Status message:Installation i gang. Vent venligst...]LOG]!><time="16:02:57.35260" date="02-10-2023" component="Show-InstallationProgress" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Previous [C:\Users\Admin\AppData\Local\Temp\PSAppDeployToolkit\ExecuteAsUser] found. Attempting removal.]LOG]!><time="16:02:57.50860" date="02-10-2023" component="Execute-ProcessAsUser" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Deleting folder [C:\Users\Admin\AppData\Local\Temp\PSAppDeployToolkit\ExecuteAsUser] recursively...]LOG]!><time="16:02:57.54260" date="02-10-2023" component="Remove-Folder" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Creating [C:\Users\Admin\AppData\Local\Temp\PSAppDeployToolkit\ExecuteAsUser].]LOG]!><time="16:02:57.57360" date="02-10-2023" component="Execute-ProcessAsUser" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Preparing a VBScript that will start [C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command & {"C:\Program Files (x86)\Sotea_Scripts\ConfigTaskRegaddTimerAutoMountSharePoint.ps1"; Exit $LastExitCode }] as the logged-on user [AZUREAD\intunetest] and suppress the console window...]LOG]!><time="16:02:57.58960" date="02-10-2023" component="Execute-ProcessAsUser" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Failed to set read permissions on path [C:\Users\Admin\AppData\Local\Temp\PSAppDeployToolkit\ExecuteAsUser\PSAppDeployToolkit-ExecuteAsUser.vbs]. The function might not be able to work correctly.]LOG]!><time="16:02:57.78960" date="02-10-2023" component="Execute-ProcessAsUser" context="AzureAD\Admin" type="2" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Installation] :: Failed to export the scheduled task XML file [C:\Users\Admin\AppData\Local\Temp\PSAppDeployToolkit\PSAppDeployToolkit-ExecuteAsUser.xml]. 
Error Record:
-------------

Message        : A positional parameter cannot be found that accepts argument 'System.Security.Acc
                 essControl.FileSystemAccessRule'.
InnerException : 

FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
ScriptStackTrace      : at Set-ItemPermission<Process>, C:\Intune\ConfigTask\Toolkit\AppDeployTool
                        kit\AppDeployToolkitMain.ps1: line 15574
                        at Execute-ProcessAsUser<Process>, C:\Intune\ConfigTask\Toolkit\AppDeployT
                        oolkit\AppDeployToolkitMain.ps1: line 7558
                        at <ScriptBlock>, C:\Intune\ConfigTask\Toolkit\Deploy-Application.ps1: lin
                        e 211
                        at <ScriptBlock>, <No file>: line 1
                        at <ScriptBlock>, <No file>: line 1

PositionMessage : At C:\Intune\ConfigTask\Toolkit\AppDeployToolkit\AppDeployToolkitMain.ps1:15574 
                  char:21
                  + ...     $Rule = New-Object TypeName 'System.Security.AccessControl.FileSy ...
                  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



]LOG]!><time="16:02:57.95960" date="02-10-2023" component="Execute-ProcessAsUser" context="AzureAD\Admin" type="3" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Bypassing Show-InstallationPrompt [Mode: Silent]. Message:You can customize text to appear at the end of an install or remove it completely for unattended installations.]LOG]!><time="16:02:58.02860" date="02-10-2023" component="Show-InstallationPrompt" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Bypassing Close-InstallationProgress [Mode: Silent]]LOG]!><time="16:02:58.09060" date="02-10-2023" component="Close-InstallationProgress" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: Sotea_ScheduleTaskRegaddAutoMountTimer_EN_01 Installation completed with exit code [0].]LOG]!><time="16:02:58.18160" date="02-10-2023" component="Exit-Script" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">
<![LOG[[Post-Installation] :: -------------------------------------------------------------------------------]LOG]!><time="16:02:58.21160" date="02-10-2023" component="Exit-Script" context="AzureAD\Admin" type="1" thread="9120" file="Deploy-Application.ps1">

type or paste code here

Known issue: ExcecuteAsUser not working on 3.9.2 · Issue #749 · PSAppDeployToolkit/PSAppDeployToolkit (github.com)

Thanks man :slight_smile: then it makes sense.

im using the 3.9.2 version now, but now i get the literalpath error instead. What can this be?

“cannot bind argument to parameter ‘literalpath’ because it is an empty string”

This is also mentioned in ExcecuteAsUser not working on 3.9.2 · Issue #749 · PSAppDeployToolkit/PSAppDeployToolkit (github.com)

1 Like

PSAppDeployToolkit/CHANGELOG.txt at master · PSAppDeployToolkit/PSAppDeployToolkit (github.com)

Update: PSADT version 3.9.3 seems to have fixed this issue