Eksportowanie virtualek

# skasowanie plików i folderow starszych niz 30 dni
$date = (Get-Date).ToString('dd_MM_yyyy')
# tworzenie folderu - nie wywala bledu nawet jesli istnieje
New-Item -ItemType Directory -Force -Path "E:\BACKUP_VIRTUALKI\"
Get-ChildItem –Path "E:\BACKUP_VIRTUALKI" -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-30))} | Remove-Item -Recurse -Force
New-Item -ItemType Directory -Path "E:\BACKUP_VIRTUALKI\$date"
Export-VM -NAME "SERVER01" -Path "E:\BACKUP_VIRTUALKI\$date\"
Export-VM -NAME "SERVER02" -Path "E:\BACKUP_VIRTUALKI\$date\"
Export-VM -NAME "SERVER03" -Path "E:\BACKUP_VIRTUALKI\$date\"
Export-VM -NAME "SERVER04" -Path "E:\BACKUP_VIRTUALKI\$date\"

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.