Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cmd /c echo 123 | powershell "C:tempSnap.ps1"
- Write-Host "Create Snapshots Script" -ForegroundColor Green -BackgroundColor Black
- Write-Host "Please ensure a .CSV file was properly created in the correct location with the list of VM shortnames for snapshot" -ForegroundColor Cyan -BackgroundColor Black
- $scriptpath = (Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path)
- Set-Location -Path $scriptpath
- #Get CO Number
- $CONumber = Read-Host "Enter the CO Number"
- #Logging
- $filename = Get-Date -Format yyyyMMddhhmm
- if (-not (Test-Path -Path "$scriptpathLogs$CONumber-Log-$filename.txt")) {
- Start-Transcript -Path "$scriptpathLogs$CONumber-Log-$filename.txt" -NoClobber | Out-Null
- } else {
- Start-Transcript -Path "$scriptpathLogs$CONumber-Log-$filename.txt" -Append -NoClobber | Out-Null
- }
- #Get VMs from CSV
- Write-Host "Enter the full path to the CSV file with the list of VMs" -ForegroundColor Cyan -BackgroundColor Black
- Write-Host "Example: C:SnapshotsListsCO123456.csv" -ForegroundColor Cyan -BackgroundColor Black
- $CSV = Read-Host "Full path to the CSV file"
- #Validate CSV file
- if (!$(Test-Path -Path $CSV)) {
- Write-Host "The path and CSV file is invalid. Please re-enter." -ForegroundColor Red -BackgroundColor Black
- while (!$(Test-Path -Path $CSV)) {
- Write-Host ""
- $CSV = Read-Host "Enter the full path to the CSV file with the list of VMs"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement