How can I run a mixed user/admin remediation script in PowerShell?
Asked by
dry-erase-marker
I'm facing a dilemma with a remediation script I want to create for users. The goal is to automate common issues I've been getting ticket requests for. However, some tasks in the script need to run in the user context while others require admin privileges. I'm considering having users execute the script, but I'm concerned about the prompts for admin consent. Is there a method to maintain an elevated PowerShell session throughout the script execution, or should I compile a list of admin-required actions and run them using 'run as'? Any suggestions?
Answers
You can use `Enter-PSSession` with your admin credentials, which avoids those annoying prompts if everything is set correctly. Just ensure that PowerShell remoting is enabled on the devices. Check the Microsoft docs for guidelines on that.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions