okay, has been bugging me while , have tried many things now.
i'm trying run powershell script - user account regular 1 on domain, local administrator on computer. therefore i've created powershell script prompting me credentials (where type credentials of domain administrator account) used invoke script needs domain administrator elevation. script looks this:
invoke-command -filepath "c:\temp\script.ps1" -computername localhost -credential get-credential here script.ps1 script needs domain administrator elevation.
executing shown script results in prompt credential , following error:
[localhost] connecting remote server localhost failed following error message : access denied. i've tried messing around .bat file looking this:
set thisscriptsdirectory=%~dp0 set powershellscriptpath=%thisscriptsdirectory%script.ps1 powershell -noprofile -executionpolicy bypass -command "& {start-process powershell -argumentlist '-noprofile -executionpolicy bypass -file ""%powershellscriptpath%""' -verb runas}"; aswell, can't make work - not elevating script domain administrator level.
lastly however, need mention script want run domain elevation works if open powershell domain administrator elevation, navigates c:\temp\script.ps1 , executes .\script.ps1.
any suggestions?
if have local administrative rights, run powershell administrator , run invoke-command without -credential flag.
if you're running script locally, don't need invoke-command. you're better off running script , passing arguments it.
Comments
Post a Comment