My code creates the scheduled task and shows it was successfully executed. However, the script doesnt seem to actually run as the printers are not actually removed for the logged in user unless they are ad admin.
Then the full script just ends with this logging and the script doesnt continue to execute my next line of code under “installation”. Any idea what Im doing wrong? Am I missing someting to get the script to actually continue?
As a follow up, the powershell scipt that is supposed to be execute with the scheduled task is just a simple get-printer task to find the printer that are installed under the users context and simply remove those printers so that the driver can be removed under the system context by the next part of the script. I noticed the scheduled task script seems to actually execute if the logged in user is a local admin, if its a standard user, it doesnt excute. This is being deployed via Intune in the system context.
If I execute deploy-application.exe just locally on the computer, even if the user is a standard user account, the user context printers do get removed.
Hi, you are referring to a script in $dirFiles. That location can’t be read by a standard user so that is probably why it’s not run. The examples for the function Execute-ProcessAsUser are all using a specific folder. You should probably copy the script to a folder that the current user have Read and Execute rights in and run it from there.
Note that there are several optional parameters to this function that you could use but unfortunately the documentation of these are not that good.
Hi, I thought the script in the $dirFiles folder got copied to a temp folder by the main script and thrn used to create the scheduled task. So I thought it would use a folder that is readable by a standard user… Is that not accurate?
It’s a complex function to troubleshoot, do you have any more information in the log file? According to the log info you provided the function only executes the Finally statement correctly so it probably breaks early.