Created
September 8, 2020 07:29
-
-
Save HainanZhao/953f92e2d706847b270f18351185ac0a to your computer and use it in GitHub Desktop.
Zip sub folders and upload them to Azure File storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ZipAndUpload | |
| { | |
| Param | |
| ( | |
| [Parameter(Mandatory=$true, Position=0)] | |
| [string] $rootFolder | |
| ) | |
| cd $rootFolder | |
| $folders = get-childitem -path $rootFolder | where-object {$_.Psiscontainer -eq "True"} |select-object Name | |
| foreach ($folder in $folders) | |
| { | |
| $path= $folder.Name | |
| $zip= $path + ".zip" | |
| if(!(Test-Path $zip)) | |
| { | |
| Compress-Archive -Path $path"\*" -DestinationPath $zip | |
| } | |
| AzCopy.exe copy $rootFolder "https://yourstorage.file.core.windows.net/foldername?sv=2020-03-28&ss=f&srt=sco&sp=rwdlc&se=2021-06-04T15:07:27Z&st=2019-06-04T07:07:27Z&spr=https&sig=xxxxxxxxxxxxxxxxxxxxxx" --include-path $zip | |
| } | |
| } | |
| ZipAndUpload "C:\Your Folder Path\" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment