Created
October 6, 2022 19:16
-
-
Save Vibhu2/18ce914d63bbbd06c65c1b512160ef0d to your computer and use it in GitHub Desktop.
This file contains 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
Checking for auto start on VMS | |
$AutostartStatus= Get-VM | Select-Object VMname,AutomaticStartAction,AutomaticStartDelay,AutomaticStopAction | |
#$AutostartStatus | where-Object { ($_.AutomaticStartAction -ine 'Start') -or ($_.AutomaticStartAction -ine 'StartIfRunning')} | |
$vmstostart= $AutostartStatus | where-Object { ($_.AutomaticStartAction -eq 'Nothing')} | |
# starting Back Virtul Machines | |
Write-verbose "Getting status of VM's from the log file" | |
$InetiallyRunningMachines= Get-Content -Path C:\HypervisorRestartLogs\RunningMachines.txt | |
Get-Date | Out-File -FilePath C:\HypervisorRestartLogs\Logfiles.txt -Append | |
#$InetiallyRunningMachines| Where-Object { $_.State -eq 'Saved' } | Start-VM | |
$InetiallyRunningMachines | Select-Object VMname,AutomaticStartAction,AutomaticStartDelay,AutomaticStopAction | |
$vmstostart= $AutostartStatus | where-Object { ($_.AutomaticStartAction -eq 'Nothing')} | |
$vmstostart.VMname | Start-VM | |
# $InetiallyRunningMachines | Start-VM | |
# Logging Virtual Machines State | |
$MachinesState = Get-VM | |
$MachinesState | Out-File -FilePath C:\HypervisorRestartLogs\Logfiles.txt -Append |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment