zip - Unzipping a .7z file in Azure Automation -


i can unzip .7z in powershell ise (workflow), when use same code in azure runbook, nothing happens:

workflow unzip-file {     param([parameter(mandatory=$true)][string]$zipfilesource,           [parameter(mandatory=$true)][string]$destinationfolder,           [parameter(mandatory=$true)][string]$password,           [parameter(mandatory=$true)][string]$pathto7zipexe)      inlinescript     {         write-output "${using:zipfilesource} exists? - $(test-path ${using:zipfilesource})"         write-output "${using:destinationfolder} exists? - $(test-path ${using:destinationfolder})"         write-output "${using:pathto7zipexe} exists? - $(test-path ${using:pathto7zipexe})"         $passwordswitch = "-p" #this needed because otherwise password literally $password rather string stored in variable.         $destinationdirswitch = "-o"         & ${using:pathto7zipexe} x ${using:zipfilesource}$destinationdirswitch${using:destinationfolder}$passwordswitch${using:password} -y #-y means if prompted yes/no, choose yes automatically.          $filename = "test.txt"         $destinationpath = [system.io.path]::combine(${using:destinationfolder}, $filename)         write-output "$destinationpath exists? - $(test-path $destinationpath)"     } } 

calling runbook:

unzip-file `         -destinationfolder c:\temp `         -password "thepassword" `         -pathto7zipexe 'c:\temp\7za.exe' `         -zipfilesource 'c:\temp\test.7z' 

output:

c:\temp\test.7z exists? - true c:\temp exists? - true c:\temp\7za.exe exists? - true c:\temp\test.txt exists? - false 

as can see file contained within .7z (test.txt) not being extracted.

the files on automation host's c:\temp folder (i downloaded them there blob storage). have double checked password same 1 used zip .7z file. test.7z file contains 1 file called test.txt. 7za.exe portable exe 7zip , worked fine when run in powershell ise.

so turns out can't run .exe files on automation host. downloaded sevenzipsharp , downloaded .dll files blob storage automation host's c:\temp, used add-type import assembly, , ran code there.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -