Reputation: 1895
Using PowerShell version 6.0.2 on Centos 7, trying to get Session to Windows 2012 Server. Doing the following:
$secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("domain\username", $secpasswd)
Enter-PSSession -ComputerName Some-Host-Name -port 5985 -Credential $mycreds
Getting the Following Error:
Enter-PSSession : MI_RESULT_ACCESS_DENIED At line:1 char:2
+ Enter-PSSession -ComputerName Some-Host-Name -port 5985 -Credential $m ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Some-Host-Name :String) [Enter-PSSession], PSInvalidOperationException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Should get session to the Windows Machine.
Done the following in order the Windows machine will trust the centos machine
Set-Item WSMAN:\Localhost\Client\TrustedHosts -Value * -Force
Any ideas what I need to do?
Upvotes: 0
Views: 2546
Reputation: 16106
You need to use SSH for remoting from Linux to Windows. This is covered on the MS docs site.
PowerShell Remoting Over SSH
Overview
PowerShell remoting normally uses WinRM for connection negotiation and data transport. SSH was chosen for this remoting implementation since it is now available for both Linux and Windows platforms and allows true multiplatform PowerShell remoting. However, WinRM also provides a robust hosting model for PowerShell remote sessions which this implementation does not yet do. And this means that PowerShell remote endpoint configuration and JEA (Just Enough Administration) is not yet supported in this implementation.
Getting Started with PowerShell Core on Windows, Mac, and Linux What do I need?
To get started with PowerShell Core you want to install and configure these three items on your operating system(s) of choice: • PowerShell Core 6 Beta • OpenSSH • Visual Studio Code
I was surprised how quickly I was up-and-running following the installation instructions. Each process involved relatively little tweaking for a beta experience.
If you are a Linux person you might be thinking, “OK. I already have OpenSSH installed.” Please read the OpenSSH link above for the step of editing the sshd_config file for PowerShell remoting support.
Or see also these answers:
Managing Windows Powershell from Linux terminal
https://serverfault.com/questions/638659/managing-windows-powershell-from-linux-terminal
How to Setup Linux to Query Windows WinRM Hosts
http://www.tomsitpro.com/articles/setup-linux-to-query-windows-winrm-hosts,1-3468.html
Upvotes: 1