Skip to content

Instantly share code, notes, and snippets.

@kourbou
Last active March 24, 2021 13:30
Show Gist options
  • Select an option

  • Save kourbou/7b4560e70b2b485443def212a2878595 to your computer and use it in GitHub Desktop.

Select an option

Save kourbou/7b4560e70b2b485443def212a2878595 to your computer and use it in GitHub Desktop.
Launch & shut-down scripts for Hyper-V
$VMName = 'MyVirtualMachine'
$IPAddress = '172.16.0.0'
Start-VM -Name $VMName
If (-Not $?) { Pause ; Exit }
Write-Host "Waiting for VM to reply to ping request. This window will close when VM is up."
Do { $Ping = Test-Connection $IPAddress -Count 1 -Quiet } Until ( $Ping )
$VMName = 'MyVirtualMachine'
Stop-VM -Name $VMName
If (-Not $?) { Pause; Exit }
@kourbou
Copy link
Author

kourbou commented Mar 24, 2021

Create shortcuts to the scripts and set "Run as administrator" under the shortcut properties.

Note: You can also create a shortcut to connect by pointing it to ssh.exe user@ip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment