Este comando extrai o arquivo ao executá-lo diretamente no PowerShell 7.5.0-rc.1:
Expand-Archive -path .\test.zip -DestinationPath .
Mas executando-o por meio de um script Deno:
new Deno.Command("PowerShell", {
args: ["Expand-Archive -path ./test.zip -DestinationPath ."],
}).spawn();
produz este erro:
Expand-Archive : The 'Expand-Archive'
command was found in the module
'Microsoft.PowerShell.Archive', but the
module could not be loaded. For more
information, run 'Import-Module
Microsoft.PowerShell.Archive'.
At line:1 char:1
+ Expand-Archive -path ./test.zip
-DestinationPath .
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound
: (Expand-Archive:String) [], CommandNot
FoundException
+ FullyQualifiedErrorId : CouldNotAutolo
adMatchingModule
Em seguida, executo este script:
new Deno.Command("PowerShell", {
args: ["Import-Module Microsoft.PowerShell.Archive"],
}).spawn();
new Deno.Command("PowerShell", {
args: ["Expand-Archive -path ./test.zip -DestinationPath ."],
}).spawn();
e gera este erro:
Import-Module : File C:\program files\powersh
ell\7-preview\Modules\Microsoft.PowerShell.Ar
chive\Microsoft.PowerShell.Archive.psm1
cannot be loaded because running scripts is
disabled on this system. For more
information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170
.
At line:1 char:1
+ Import-Module Microsoft.PowerShell.Archive
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError:
(:) [Import-Module], PSSecurityExceptio
n
+ FullyQualifiedErrorId : UnauthorizedAc
cess,Microsoft.PowerShell.Commands.Impor
tModuleCommand
Expand-Archive : The 'Expand-Archive'
command was found in the module
'Microsoft.PowerShell.Archive', but the
module could not be loaded. For more
information, run 'Import-Module
Microsoft.PowerShell.Archive'.
At line:1 char:1
+ Expand-Archive -path ./test.zip
-DestinationPath .
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound
: (Expand-Archive:String) [], CommandNot
FoundException
+ FullyQualifiedErrorId : CouldNotAutolo
adMatchingModule
Aqui está a configuração atual das políticas de execução :
Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Unrestricted
CurrentUser Undefined
LocalMachine Unrestricted
Você tem alguma ideia?