PowerShell for Windows Admins

Jul 8 2016   8:37AM GMT

PowerShell Direct example

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Hyper-V
Powershell
Virtualization
Windows Server 2016

Last week I mentioned PowerShell and how you can create a PowerShell Remoting session to a Virtual Machine that’s running on Hyper-V

Here’s an example of it in use:

$cred = Get-Credential W16TP5TGT01\Administrator
$s = New-PSSession -VMName W16TP5TGT01 -Credential $cred

Create the credential for the VM and then create the remoting session. I prefer to use the VM name rather than the GUID.

Once you’ve established the session you can use it. In this case I’m using another PowerShell 5.o innovation to copy a file across the remote session:

Copy-Item -Path ‘C:\Source\Windows 2016 TP5\Cumulative Update for Windows Server 2016 Technical Preview 5 (KB3163016)\AMD64-all-windows10.0-kb3163016-x64_83d6e9bca94a64a5d9be3d81cdb182e540285848.msu’ -Destination c:\source -ToSession $s

Clean up as usual:

Remove-PSSession -Session $s

PowerShell Direct is another useful addition to the remoting toolbox. It’ll be especially useful in non-domain remoting situations.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: