7zip in powershell script

Multi tool use
I need to unzip several .zip archives using a powershell script.
In the past, I used
Expand-Archive foo.zip -DestinationPath $dest
and it worked. But it takes a while to complete. As 7zip is faster, I added it to the windows path.
I just did 7z.exe x archive.zip
and it worked.
It also work on CMD if I enter it as a single command from terminal.
When I add this command in the script and run the .ps1 script, it give me:
7z.exe : Le terme « 7z.exe » n'est pas reconnu comme nom d'applet de
commande, fonction, fichier de script ou programme exécutable
Translation:
(7z.exe: The Term "7z.exe" Is Not Recognized as Cmdlet Name, Function, Script File, or Executable Program)
powershell 7zip
add a comment |
I need to unzip several .zip archives using a powershell script.
In the past, I used
Expand-Archive foo.zip -DestinationPath $dest
and it worked. But it takes a while to complete. As 7zip is faster, I added it to the windows path.
I just did 7z.exe x archive.zip
and it worked.
It also work on CMD if I enter it as a single command from terminal.
When I add this command in the script and run the .ps1 script, it give me:
7z.exe : Le terme « 7z.exe » n'est pas reconnu comme nom d'applet de
commande, fonction, fichier de script ou programme exécutable
Translation:
(7z.exe: The Term "7z.exe" Is Not Recognized as Cmdlet Name, Function, Script File, or Executable Program)
powershell 7zip
Why not just giving the full-path to 7zip? Instead of doing 7z you just do"C:Program Files7-Zip7z.exe" x archive.zip
?
– maio290
Jan 3 at 9:15
@maio290 Just tryed and :Jeton inattendu « x » dans l’expression ou l’instruction.
(Unexpected token "x" in the expression or statement.)
– xHypnosia
Jan 3 at 9:18
1
Ah, yeah, sorry, in powershell it's&'C:Program Files7-Zip7z.exe' x archive.zip
– maio290
Jan 3 at 9:20
2
The suggestion with the full path is probably missing the call operator:&
, that is& "c:Program Files..." ...
, see ss64.com/ps/call.html.
– Micha Wiedenmann
Jan 3 at 9:20
Worked. Thanks.
– xHypnosia
Jan 3 at 9:23
add a comment |
I need to unzip several .zip archives using a powershell script.
In the past, I used
Expand-Archive foo.zip -DestinationPath $dest
and it worked. But it takes a while to complete. As 7zip is faster, I added it to the windows path.
I just did 7z.exe x archive.zip
and it worked.
It also work on CMD if I enter it as a single command from terminal.
When I add this command in the script and run the .ps1 script, it give me:
7z.exe : Le terme « 7z.exe » n'est pas reconnu comme nom d'applet de
commande, fonction, fichier de script ou programme exécutable
Translation:
(7z.exe: The Term "7z.exe" Is Not Recognized as Cmdlet Name, Function, Script File, or Executable Program)
powershell 7zip
I need to unzip several .zip archives using a powershell script.
In the past, I used
Expand-Archive foo.zip -DestinationPath $dest
and it worked. But it takes a while to complete. As 7zip is faster, I added it to the windows path.
I just did 7z.exe x archive.zip
and it worked.
It also work on CMD if I enter it as a single command from terminal.
When I add this command in the script and run the .ps1 script, it give me:
7z.exe : Le terme « 7z.exe » n'est pas reconnu comme nom d'applet de
commande, fonction, fichier de script ou programme exécutable
Translation:
(7z.exe: The Term "7z.exe" Is Not Recognized as Cmdlet Name, Function, Script File, or Executable Program)
powershell 7zip
powershell 7zip
edited Jan 3 at 20:04


Ansgar Wiechers
145k13132190
145k13132190
asked Jan 3 at 9:11
xHypnosiaxHypnosia
196
196
Why not just giving the full-path to 7zip? Instead of doing 7z you just do"C:Program Files7-Zip7z.exe" x archive.zip
?
– maio290
Jan 3 at 9:15
@maio290 Just tryed and :Jeton inattendu « x » dans l’expression ou l’instruction.
(Unexpected token "x" in the expression or statement.)
– xHypnosia
Jan 3 at 9:18
1
Ah, yeah, sorry, in powershell it's&'C:Program Files7-Zip7z.exe' x archive.zip
– maio290
Jan 3 at 9:20
2
The suggestion with the full path is probably missing the call operator:&
, that is& "c:Program Files..." ...
, see ss64.com/ps/call.html.
– Micha Wiedenmann
Jan 3 at 9:20
Worked. Thanks.
– xHypnosia
Jan 3 at 9:23
add a comment |
Why not just giving the full-path to 7zip? Instead of doing 7z you just do"C:Program Files7-Zip7z.exe" x archive.zip
?
– maio290
Jan 3 at 9:15
@maio290 Just tryed and :Jeton inattendu « x » dans l’expression ou l’instruction.
(Unexpected token "x" in the expression or statement.)
– xHypnosia
Jan 3 at 9:18
1
Ah, yeah, sorry, in powershell it's&'C:Program Files7-Zip7z.exe' x archive.zip
– maio290
Jan 3 at 9:20
2
The suggestion with the full path is probably missing the call operator:&
, that is& "c:Program Files..." ...
, see ss64.com/ps/call.html.
– Micha Wiedenmann
Jan 3 at 9:20
Worked. Thanks.
– xHypnosia
Jan 3 at 9:23
Why not just giving the full-path to 7zip? Instead of doing 7z you just do
"C:Program Files7-Zip7z.exe" x archive.zip
?– maio290
Jan 3 at 9:15
Why not just giving the full-path to 7zip? Instead of doing 7z you just do
"C:Program Files7-Zip7z.exe" x archive.zip
?– maio290
Jan 3 at 9:15
@maio290 Just tryed and :
Jeton inattendu « x » dans l’expression ou l’instruction.
(Unexpected token "x" in the expression or statement.)– xHypnosia
Jan 3 at 9:18
@maio290 Just tryed and :
Jeton inattendu « x » dans l’expression ou l’instruction.
(Unexpected token "x" in the expression or statement.)– xHypnosia
Jan 3 at 9:18
1
1
Ah, yeah, sorry, in powershell it's
&'C:Program Files7-Zip7z.exe' x archive.zip
– maio290
Jan 3 at 9:20
Ah, yeah, sorry, in powershell it's
&'C:Program Files7-Zip7z.exe' x archive.zip
– maio290
Jan 3 at 9:20
2
2
The suggestion with the full path is probably missing the call operator:
&
, that is & "c:Program Files..." ...
, see ss64.com/ps/call.html.– Micha Wiedenmann
Jan 3 at 9:20
The suggestion with the full path is probably missing the call operator:
&
, that is & "c:Program Files..." ...
, see ss64.com/ps/call.html.– Micha Wiedenmann
Jan 3 at 9:20
Worked. Thanks.
– xHypnosia
Jan 3 at 9:23
Worked. Thanks.
– xHypnosia
Jan 3 at 9:23
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019222%2f7zip-in-powershell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019222%2f7zip-in-powershell-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
AcL7R0 6h HwK,01Pqm KCWxL38Zm62,L95 jhvBI2MSm5nNLu73sqqZXDCWB4F4V oZQVj2cIRB6C7vuxNHiRKMZK
Why not just giving the full-path to 7zip? Instead of doing 7z you just do
"C:Program Files7-Zip7z.exe" x archive.zip
?– maio290
Jan 3 at 9:15
@maio290 Just tryed and :
Jeton inattendu « x » dans l’expression ou l’instruction.
(Unexpected token "x" in the expression or statement.)– xHypnosia
Jan 3 at 9:18
1
Ah, yeah, sorry, in powershell it's
&'C:Program Files7-Zip7z.exe' x archive.zip
– maio290
Jan 3 at 9:20
2
The suggestion with the full path is probably missing the call operator:
&
, that is& "c:Program Files..." ...
, see ss64.com/ps/call.html.– Micha Wiedenmann
Jan 3 at 9:20
Worked. Thanks.
– xHypnosia
Jan 3 at 9:23