Specify a password, then zip files with specific extensions to a folder on your desktop.
New-Item -Force -ItemType directory -Path "$($env:USERPROFILE)\Desktop\Backup-Zips\" New-Item -Force -ItemType directory -Path "$($env:USERPROFILE)\Backup\" $dateTime = (get-date -f yyyy-MM-dd-HHmm) Clear-Host Write-Host "" #$password = Read-Host -Prompt ' Enter Password for File [password] ' # if($password -eq $null){ $password = "password" } # if($password -eq ""){ $password = "password" } #--- NEW METHOD OF GETTING PASSWORD do { $pwd1 = Read-Host "Password" -AsSecureString $pwd2 = Read-Host "Re-enter Password" -AsSecureString $pwd1_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd1)) $pwd2_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd2)) if ($pwd1_text -ceq $pwd2_text) { Write-Host "Passwords matched! Continuing..." Write-Host "" $ok = "Gucci" } else { Write-Host "Passwords are POOPY! Try again..." Write-Host "" } } until ($ok) $hint = Read-Host -Prompt ' Enter Hint for Password [BLANK] ' if($hint -eq $null){ $hint = "NoHint" } if($hint -eq ""){ $hint = "NoHint" } # Robocopy to Backup Folder - Mirror, no retry, no wait, max size 50M, exclude exe,dll,zip,bat robocopy $env:USERPROFILE\Desktop $env:USERPROFILE\Backup\Desktop *.doc* *.rtf *.xfd* *.txt *.xl* *.pp* *.csv *.mdb *.pdf *.htm* *.ps* *.pub *.vs* *.zip *.lic /MIR /R:0 /W:0 /MAX:50000000 /xf *.exe *.dll robocopy $env:USERPROFILE\Documents $env:USERPROFILE\Backup\Documents *.doc* *.rtf *.xfd* *.txt *.xl* *.pp* *.csv *.mdb *.pdf *.htm* *.ps* *.pub *.vs* *.zip *.lic /MIR /R:0 /W:0 /MAX:50000000 /xf *.exe *.dll robocopy $env:USERPROFILE\Downloads $env:USERPROFILE\Backup\Downloads *.doc* *.rtf *.xfd* *.txt *.xl* *.pp* *.csv *.mdb *.pdf *.htm* *.ps* *.pub *.vs* *.zip *.lic /MIR /R:0 /W:0 /MAX:50000000 /xf *.exe *.dll # Zip the folder to Desktop C:\CyberTransport\Applications\7-Zip\7z.exe a -tzip $env:USERPROFILE\Backup-Zips\Backup-$dateTime-$hint.zip $env:USERPROFILE\Backup "-p$pwd1_text" Write-Host "" #Write-Host "Copying files to H Drive..." # Copy to H Drive #Copy-Item $env:USERPROFILE\Backup-Zips\Backup-$dateTime-$hint.zip H:\Backup-$dateTime-$hint.changetozip #--- Open Folders explorer.exe $env:USERPROFILE\Backup-Zips\