What is Windows PowerShell Direct?
Basically, it is able to create remote sessions and run Windows PowerShell cmdlets on a remote host. For connectivity, its takes use of the WinRM service in Windows and it is called PowerShell remoting. A network is used to perform all connectivities.
Powershell Direct is an option for connecting to virtual machines and running Windows PowerShell cmdlets. A network connection is not a requirement for PowerShell direct to perform Windows PowerShell remoting from the Hyper-V host, on which the virtual machine is running. When you do not have connectivity to a virtual machine and you want to run Windows PowerShell cmdlets in that virtual machine, this thing comes into use. When running on a hyper-V host, it can also provide a way to script modifications to multiple virtual machines.
- Windows 10 or Windows Server 2016 must be must be the host & guest operating systems.
- It is must for Windows PowerShell to run as administrator.
- Credentials must be used to authenticate the virtual machine.
- The configuration of virtual machine must be updated latest version.
For this demo, Infrastructure Requirement:
- 1 NANO Server (NANO-01)
- 1 DC-CLOUD (DC-CLOUD.Sifad.ae)
Open the Hyper-V manager and find and click on NANO SERVER-01=WIN 2016. On the right side, in the action pane Click Start
On DC-CLOUD.Sifad.ae, Run Windows PowerShell as Administrator & type this command:
“Ping request could not find host NANO-01” would be returned as expected.
To enable remote connections, you will need to start WinRM Service on your computer. To perform this action, type
Start WinRM Service
Net start WinRM
To allow it to connect to every server, type
Set-Item WSMan:\localhost\Client\TrustedHosts -Value “*”
Now type this
Enter-PSSession –VMName “NANO SERVER-01=WIN 2016”
Upon receiving the prompt for credentials, Put “Administrator” in username & “asd@123” in password.
Now you are into a PSSession with NANO-01. Type this command, after which NANO-01 will See command