I have a script called CreateClass.ps1 and has 3 parameters -Name , -Grade and -Count . It's automated script to run, so it runs as Administrator( local account), How can that script be run under the credential of the domain account for example SchDomain\Student with password Password123?
You'd either need to use Start-Process to start a new PowerShell.exe process using the alternate credential, or schedule the script using Task Scheduler to run under the alternate credential. Or, use RunAs.exe to launch the script using an alternate credential. But there's no way to do it from within the same PowerShell session.
Thanks for the ideas and options, do you have any sample how to do it for the start-process with arguments and domain credential. I tried this but I have the problem with the parameters to include them. Thanks again.