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
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 |
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
$Cleanup=Test-Path -Path "C:\HypervisorRestartLogs\*.txt" | |
if ($Cleanup -eq 'True') { | |
Remove-Item -Path C:\HypervisorRestartLogs\*.txt | |
} | |
# Creating Log files | |
New-Item C:\HypervisorRestartLogs -ItemType Directory -ErrorAction SilentlyContinue | |
New-Item C:\HypervisorRestartLogs\Logfiles.txt -ItemType File -ErrorAction SilentlyContinue | |
Get-Date | Out-File -FilePath C:\HypervisorRestartLogs\Logfiles.txt -Append |