Put your code in a script block and then use that script block in an Invoke-Command. Add the -Credential parameter to the Invoke-Command and provide the user/password for a domain admin user.
Run powershell script with domain admin rights
Tulik23 K
66
Reputation points
Hi
i need to run a powershell script with domain admin user/pass
the script will take own on a folder (as admin) and give a the user rights ( $User = Read-Host -Prompt 'Input the user name')
this is the script :
$User = Read-Host -Prompt 'Input the user name'
write-Host $user
takeown /f i:\$user\videos /r /d y
icacls i:\$user\videos /grant administrators:F /t