4

I have a script that works remotely with administrator rights,but I want it to work from a domain user who is in the group IIS_USERS , but this user is non-admin user withowt admin rights. UAC disable.

Invoke-Command -ComputerName "test-tp" -ScriptBlock { Stop-WebAppPool -Name "Xml" }
$Path = "\\test-tp\bus\web.txt"
while (!(Test-Path $Path)) { Start-Sleep 10 }
If (Test-Path $Path) {Invoke-Command -ComputerName "test-tp" -ScriptBlock { Start-WebAppPool -Name "Bus" }}

produces such an error

Filename: redirection.config
Error: Cannot read configuration file due to insufficient permissions
    + CategoryInfo          : NotSpecified: (:) [Stop-WebItem], UnauthorizedAc
   cessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.IIs
   .PowerShell.Provider.StopItemCommand
    + PSComputerName        : test-tp

user added to group IIS_USERS + IIS Manager Permission + Remote managment Users + WinRMRemoteWMIUsers. how to manage iis Non admin user with powershell?

  • Possible duplicate of [Run Command as administrator in PowerShell script. UAC](https://stackoverflow.com/questions/2248093/run-command-as-administrator-in-powershell-script-uac) – iRon Oct 11 '17 at 09:12
  • `invoke-command Credential $user ...`, see: https://stackoverflow.com/a/2258134/1701026 – iRon Oct 11 '17 at 09:13
  • + $user = New-Object Management.Automation.PSCredential($UserName, $securePass ord ... + + CategoryInfo : InvalidOperation: (:) [New-Object], MethodExcept ion + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power Shell.Commands.NewObjectCommand – Вадим Авдеев Oct 11 '17 at 10:12
  • To create a PSCredential object, see e.g.: https://stackoverflow.com/a/41548976/1701026 – iRon Oct 11 '17 at 11:59

0 Answers0