Hey,
I am trying to remotely enable powershell remoting in a powershell script :)
In the past i did it like the following:
$Directory = Split-Path $MyInvocation.MyCommand.path $CompName = "RemoteMachine" $ArgumentList = "\\" + $CompName + ' /accepteula cmd.exe /C "%windir%\system32\winrm.cmd quickconfig -quiet"' Start-Process -Wait -NoNewWindow $Directory\PsExec.exe -ArgumentList $ArgumentList
This worked without problems.
Now we enabled UAC (User Account Control) on the machine.
What I get now is the following error message:
WinRM already is set up to receive requests on this machine. WSManFault Message = Access is denied. Error number: -2147024891 0x80070005Access is denied.
Based on some internet articles I tried the following command lines (unfortunately without success):
$ArgumentList = "\\" + $CompName + ' /accepteula -h cmd.exe /C "%windir%\system32\winrm.cmd quickconfig -quiet"' Start-Process -Wait -NoNewWindow $Directory\PsExec.exe -ArgumentList $ArgumentList
(I added the -h parameter in $Argumentlist) - causes still the 'access denied' error above.
$ArgumentList = "\\" + $CompName + ' /accepteula -h cmd.exe /C "%windir%\system32\winrm.cmd quickconfig -quiet"' Start-Process -Verb runas -Wait -NoNewWindow $Directory\PsExec.exe -ArgumentList $ArgumentList
(I added the -Verb runas parameter in Start-Process) - causes the following error:
Start-Process : Parameter set cannot be resolved using the specified named parameters.
What I am using is powershell 3.0, PsEexec v2.0 and running the powershell with elevated rights on local machine. My user account is administrator on remote machine.
Thank you for help in advance :)