SHARE
TWEET

Untitled

a guest Jun 20th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cmd /c echo 123 | powershell "C:tempSnap.ps1"
  2.      
  3. Write-Host "Create Snapshots Script" -ForegroundColor Green -BackgroundColor Black
  4. 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
  5.  
  6. $scriptpath = (Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path)
  7. Set-Location -Path $scriptpath
  8.  
  9. #Get CO Number
  10. $CONumber = Read-Host "Enter the CO Number"
  11.  
  12. #Logging
  13. $filename = Get-Date -Format yyyyMMddhhmm
  14. if (-not (Test-Path -Path "$scriptpathLogs$CONumber-Log-$filename.txt")) {
  15.     Start-Transcript -Path "$scriptpathLogs$CONumber-Log-$filename.txt" -NoClobber | Out-Null
  16. } else {
  17.     Start-Transcript -Path "$scriptpathLogs$CONumber-Log-$filename.txt" -Append -NoClobber | Out-Null
  18. }
  19.  
  20. #Get VMs from CSV
  21. Write-Host "Enter the full path to the CSV file with the list of VMs" -ForegroundColor Cyan -BackgroundColor Black
  22. Write-Host "Example: C:SnapshotsListsCO123456.csv" -ForegroundColor Cyan -BackgroundColor Black
  23. $CSV =  Read-Host "Full path to the CSV file"
  24.  
  25. #Validate CSV file
  26. if (!$(Test-Path -Path $CSV)) {
  27.     Write-Host "The path and CSV file is invalid. Please re-enter." -ForegroundColor Red -BackgroundColor Black
  28.     while (!$(Test-Path -Path $CSV)) {
  29.         Write-Host ""
  30.         $CSV = Read-Host "Enter the full path to the CSV file with the list of VMs"
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top