Last active
March 24, 2021 13:30
-
-
Save kourbou/7b4560e70b2b485443def212a2878595 to your computer and use it in GitHub Desktop.
Launch & shut-down scripts for Hyper-V
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $VMName = 'MyVirtualMachine' | |
| Stop-VM -Name $VMName | |
| If (-Not $?) { Pause; Exit } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.