unable to execute winrm quickconfig - powershell

I am unable to get around the following Powershell remoting error in my Windows 10 Machine.
Firstly I am attempting to execute the following.
PS: >Start-DscConfiguration -Wait -Verbose -Force -Path $outPath
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConf
igurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting
requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the
destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm
quickconfig".
+ CategoryInfo : ConnectionError: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338012
+ PSComputerName : localhost
so I do what it suggests by executing this.
PS: >winrm quickconfig
WinRM service is already running on this machine.
winrm : WSManFault
At line:1 char:1
+ winrm quickconfig
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (WSManFault:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Message
ProviderFault
WSManFault
Message = More data is available.
Error number: -2147024662 0x800700EA
More data is available.
Thanks for the help

Related

powershell restart remote computer ip address with port

i am trying to restart a server with an ip but it fails with the messege:
Restart-Computer :
Failed to restart the computer *.*.*.* with the following error message: The RPC server is unavailable.
At line:1 char:1
+ Restart-Computer -ComputerName *.*.*.* -Credential $Creds -Fo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (*.*.*.*:String) [Restart-Computer], InvalidOperationException
+ FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Commands.RestartComputerCommand
i have changed that computer's RDP port, how do i specify the port in this command? i can't find it in the documentations or the examples over the internet.
any help will be appreciated...

How to remote into a password protected server using PowerShell

I'm trying to remote into a password protected server using powershell, but it keeps throwing errors.
My code:
winrm set winrm/config/client #{TrustedHosts="XX.X.XXX.XX"}
$cred = Get-Credential
New-PSSession XX.X.XXX.XX -Credential $cred
and the output:
PS C:\Users\user.name> winrm set winrm/config/client #{TrustedHosts="XX.X.XXX.XX"}
$cred = Get-Credential
New-PSSession XX.X.XXX.XX -Credential $cred
winrm : Error: Invalid use of command line. Type "winrm -?" for help.
At line:1 char:1
+ winrm set winrm/config/client #{TrustedHosts="XX.X.XXX.XX"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Error: Invalid ...m -?" for help.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
New-PSSession : [XX.X.XXX.XX] Connecting to remote server XX.X.XXX.XX failed with the following error message : The WinRM client cannot process the request. Default authentication may be
used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to
configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help
config. For more information, see the about_Remote_Troubleshooting Help topic.
At line:3 char:1
+ New-PSSession XX.X.XXX.XX-Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotUseIPAddress,PSSessionOpenFailed
My IP address is in the format XX.X.XXX.XX, but I censored it because I have no idea how secure/insecure it is to put that on the internet.

Windows cmdlet over powershell passes but gives access denied over winrm for Cluster aware updating

I am executing Invoke-CACURun for windows cluster aware updating on domain controller as an administrator. While that works on powershell, it is failing over ansible with ntlm transport and same credentials.
The command executed
ansible domain_controller -i ansible_hosts -m win_shell -a 'whoami;Invoke-CauRun -ClusterName "xyzWFC
The error I get is
Invoke-CauRun : Could not open cluster "xyzWFC": (Win32Exception) Access is denied
At line:1 char:72
+ ... .UTF8Encoding $false; whoami;Invoke-CauRun -ClusterName "xyzWFC";
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Invoke-CauRun], CauAccessDeniedException
+ FullyQualifiedErrorId : OpenClusterAccessDenied,Microsoft.ClusterAwareUpdating.Commands.InvokeCauRunCommandnon-zero return code
Any help on this?

Enter-PSSession not working, Firewall port 5985 is open

Error:
Enter-PSSession : Connecting to remote server sadcm0000081 failed with the following error message : WinRM cannot
complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the
network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By
default, the WinRM firewall exception for public profiles limits access to remote computers within the same local
subnet. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName sadcm0000081
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (sadcm0000081:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Test-WSN Output:
Test-Wsman : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859046" Machine="SADCM0000078.adc
.corpintra.net"><f:Message>WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer i
s accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. B
y default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. </f:Messa
ge></f:WSManFault>
At line:1 char:1
+ Test-Wsman -ComputerName sadcm0000081
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (sadcm0000081:String) [Test-WSMan], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManCommand
Try first to running powershell Enable-PSRemoting with an administrator console.
After that look after the Windows Firewall rules of remote administration.

Execute batch file on remote computer

I am on host_computer and attempting to execute batch file on remote_computer (part of WORKGROUP) to enable psremoting and use winrm to add trustedhosts.
Based on http://social.technet.microsoft.com/Forums/scriptcenter/en-US/732495c0-114c-4a1e-bbe1-5a7a3b84012d/execute-a-batch-file-on-a-remote-pc?forum=ITCG
I tried creating a process, i.e.
$server = "remote_computer"
$process = [WMICLASS]"\\$server\ROOT\CIMV2:win32_process"
But I get error
Cannot convert value "\\remote_computer\ROOT\CIMV2:win32_process" to type "System.Management.ManagementClass". Error: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" At line:1 char:1
+ $process = [WMICLASS]"\\$server\ROOT\CIMV2:win32_process"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastToWMIClass
Then I tried using psexec
PsExec.exe \\remote_computer -u username -p password 'C:\share\enable.bat'
And get error
D:\pstools\PsExec.exe : At line:1 char:1
+ D:\pstools\PsExec.exe \\remote_computer -u username -p password 'C:\share\ena ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError PsExec v2.0 - Execute processes remotely Copyright (C) 2001-2013 Mark Russinovich Sysinternals - www.sysinternals.com The handle is invalid. Connecting to remote_computer...Couldn't access remote_computer: Connecting to remote_computer...
And this batch script is to enable psremoting and add trusted hosts using winrm
#echo off
C:\share\remote.ps1
winrm set winrm/config/client/auth #{Basic="true"}
winrm set winrm/config/client #{AllowUnencrypted="true"}
winrm set winrm/config/client #{TrustedHosts="host_computer"}