remote connection using powershell from linux to windows - powershell

I am able to connect to a remote windows machine from my windows local machine using Powershell session created by New-PSSession command.
New-PSSession -ComputerName $computerName -Credential $cred
Now, I need to create similar remote session to a remote windows machine from my local LINUX machine. So, I installed powershell 6.0.2 on my red hat 7 linux box. When trying to create a remote session using New-PSSession command, I am getting following error:
New-PSSession : MI_Result_Access_Denied
I need to use only WinRM based approach and not SSH based as I cannot install any extra utility on remote windows machines.

kerberos auth is not supported in cross domain in its vanilla flavour. and Basic auth over HTTP is not supported from Linux. Installing OpenSSH on windows looks to be only way.

Related

How do I enable nested virtualization on a Windows Server 2012

I am trying to setup Configuration Management using Ansible, I'm running Windows Server 2012 and I need to setup a VM instance of Linux or Ubuntu and install virtual box again within the Ubuntu VM. for this to work I need to enable nested virtualization on the Windows Server 2012
you can enable this feature, by using the following command in an administrative PowerShell terminal,the VMName in the command is the name of your VM Instance.
Set-VMProcessor -VMName VMName -ExposeVirtualizationExtensions $true

Remotely connecting to Hyper-V machine from VM

I'm new to the concept of Hyper-V and how it works, so I'm not sure if this is a good question.
I have a server that contains the Hyper-V, and from the Hyper-V I connect to a VM (VM1). The VM1 contains Orchestrator that will be used to automate some jobs related to the machines in the Hyper-V sever. So I need to run some PowerShell commands, in VM1, to check the Snapshots of all the machines in the Hyper-V server.
I already installed the Hyper-V PowerShell module in VM1.
My question is, in order to get information about the machines in Hyper-V through VM1:
Do I need to install the Hyper-V Management Tools in VM1 and make a connection to the main Hyper-V server in order to get information about the other VMs in Hyper-V?
Can I do this by using a remote PowerShell session and then run the commands that I need against the Hyper-V server, remotely. Can I do this when VM1 is accessible through Hyper-V?
It's a bit difficult to explain, like I said I'm new to this topic. But I'm available to answer any question if my explanation was a bit confusing.
From VM1, you should be able to connect to the Hyper-V host using -computername and -name to reference the name of the VM:
$Host = "HypervHostServer"
$VM = "virtualmachine1"
Get-VM -ComputerName $Host -Name $VM
To see all virtual machines:
$Host = "HypervHostServer"
Get-VM -ComputerName $Host

Run exe on remote server under different account

I need to run an exe on a remote server. I'm using Invoke-Command -UseSSL to initiate the exe on the remote server. The exe does some work but when it needs to connect to the SQL Server, it fails to authenticate. Looking in the server log, it looks like exe are connecting to SQL Server using NT/AUTHORITY account. The security team are not allowing CredssP on the network. Is there any means I can run the exe with an explicitly defined account. An account other than the account that is used to created the remote session with.
Invoke-Command -UseSSL -ComputerName $AppServer -ScriptBlock {&"C:\Program Files\my.exe" "Params"}

Do I have any way to connect to a Hyper-V Server using a PowerShell command?

To connect to a Hyper-V host from Hyper-V Manager, right-click Hyper-V Manager in the left pane, and then click Connect to Server.
Do I have any way to connect to a Hyper-V Server using a PowerShell command?
If so please include code (example my VM name is VM_1), thanks so much!
Install Hyper-V Powershell module from Windows Features.
Get-VM -ComputerName <servernames>
You will get list of VMs running under Hyper-V hosts.

Why would a get-process -computername return a couldn't connect to remote machine error?

I can execute the following command on a specific machine and it can return a list of processes on several target computers but returns a "Couldn't connect to remote machine" error on one machine.
get-process -ComputerName 192.168.1.101
None of the target machines have powershell installed.
The machine I am executing the powershell script on has 2.0 installed.
I have admin privileges on all machines.
The target machines that are able to return a list of processes remotely are server 2003 Standard Edition with SP 1.
The target machine that does not return a list of processes remotely is server 2003 R2 Standard Edition SP2.
What would prevent me from getting a list of processes from a remote machine using powershell?
It turns out the machine that was returning the error did not have the Remote Registry service started. Once I started this service the "Couldn't connect to remote machine" error went away. This blog post helped me find the solution http://sebastienlachance.com/post/ProcessGetProcesses-common-errors.aspx
I think it uses WMI, so if the service isn't running, that would do it. Can you execute Get-WMIObject queries against those PCs at all?