Say I have a got a virtual machine VM1 with windows server 2008 installed on it. So it probably has PowerShell 2.0 installed on it but I can install PowerShell version 3.0 if needed to solve this problem. Now say my machine is Windows 7 64 bit with SP 1, I want to execute a PowerShell script on my machine that opens the PowerShell (not literally opening the window) on VM1 and executes some commands on the PowerShell of that VM1. And I do have administrative login credentials for that VM1 and my machine (both).
How can something like this be achieved ?
Thanks
It will work the same on version 2 & version 3, but you must have PSRemoting enabled. Once that’s done, you can use
Enter-PSSessionto access the remote system interactively (similar to sshing into a Linux box) orInvoke-Commandto execute individual commands or scriptblocks remotely.