Im trying to create a script where a domain user would be able to run IIS service on windows as a local admin using stored credentials.
$adminerpath = 'c:programdataadminer'
Function StoreCreds(){
$credential = Get-Credential
$credential | Export-CliXml -Path $adminerpathdata.dat
}
if (Test-Path $adminerpath){
$credential = Import-CliXml -Path $adminerpathdata.dat
Start-Process C:windowsSystem32inetsrvInetMgr.exe -Credential ($credentials)
}
else {
New-Item -Path $adminerpath -ItemType "directory"
attrib +h c:programdataadminer | Out-Null
StoreCreds
}
very simple, should see if the credential is stored and then run process with -credential.
it works with anything else (like note.exe or pwoershell.exe), but when i try running this with InetMgr.exe im getting:
start-process : This command cannot be run due to the error: The requested operation requires elevation.
any help would be much appriciated
question from:
https://stackoverflow.com/questions/65882218/powershell-start-process-as-admin-am-i-misssing-something 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…