Hey everyone! I've created a simple PowerShell script to update O365 profile pictures for our new users. I set up a scheduled task to run this script daily since we have a pretty high churn rate. The command I'm using is: "C:Program FilesPowerShell7pwsh.exe" -executionpolicy bypass -file "c:tempsyncphoto.ps1". The script runs perfectly when the task is executed under the built-in administrators account, but it won't launch the PowerShell console if I try it with any other local admin or domain accounts. Does anyone know why it only works with the built-in admin account?
1 Answer
It might be related to execution policies or permissions. Have you tried moving the script out of the temp folder? Sometimes scripts in that location can have restrictive permissions. Also, check that the scheduled task is correctly configured to allow the script to execute under the specified user accounts. I’ve run into similar issues with lighting and permissions when scheduling tasks, so it’s worth looking into!
I hear you! I have the execution policy set to bypass in my task too. It's odd that it doesn't even open the console for non-admin accounts. When I run mine as an admin, I can see the PowerShell console flash for a moment before it closes. Just like yours.