I'm Trying to make a quick script in powershell that will compress multiple folder (or files doesnt matter for now, in my example its folders) and add to each zip file a random password and export the passwords for each zip file, to csv.
This is what i got so far...
$path = "\\path\of\folders"
$source = Get-ChildItem -Path \\path\of\folders -Filter "*?" -Directory
Add-Type -assembly "system.io.compression.filesystem"
Foreach ($s in $source){
$destination = Join-path -path $path -ChildPath "$($s.name).zip"
If(Test-path $destination) {Remove-item $destination}
[io.compression.zipfile]::CreateFromDirectory($s.fullname, $destination)
}
with this i'm able to compress each folder in the main folder, to zip files each with its name.
where i get complicated to manage, is how to add a random password for each of the zip files... and after that i'll just add | Export-Csv -Path \to\my\path\passwords.csv (unless im wrong about that export)
any ideas on that?
Thanks!