# 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\"