
PowerShellで
・ZIPファイル(パスワード付き)を解凍(展開)
できます!

PowerShellから
・圧縮解凍ソフト「7-Zip」を実行
することで実現できます!
前提
「7-Zip」がインストールされていること。
「7-Zip」のインストールの詳細は、以下の記事の「7-Zipのインストール」をご確認ください。
コード
ここでは例として
・デスクトップ配下のパスワード付きZIPファイル「test.zip」を
・デスクトップ配下のフォルダ「output」配下へ解凍(展開)
します。
※ここではパスワードを「hogehoge」とします。

# 7z.exeのパスを指定
$exe7zip = "C:\Program Files\7-Zip\7z.exe"
# 解凍(展開)するZIPファイルのパスを指定
$zipFilePath = "C:\Users\user\Desktop\test.zip"
# 解凍(展開)先フォルダのパスを指定
$destFolderPath = "C:\Users\user\Desktop\output"
# パスワードを指定
$password = "hogehoge"
# 7z.exeを実行する際の引数を組み立て
$arg=" x -p" + $password + " " + $zipFilePath + " -o" + $destFolderPath + " -aoa"
$ws = New-Object -ComObject Wscript.Shell
try
{
# 7z.exe(解凍(展開))を実行を実行
Start-Process -FilePath $exe7zip -ArgumentList $arg -Wait -WindowStyle Hidden
$ws.popup("解凍(展開)しました。")
}
catch
{
$ws.popup("エラー : " + $PSItem)
}
実行結果
ZIPファイル(パスワード付き)を解凍(展開)できました。


参考①
PowerShellでZIP形式(パスワード付き)で圧縮することもできます。
詳細は以下の記事をご確認ください。
参考②
7-Zipを使用した解凍(展開)コマンドの詳細は、公式サイトをご確認ください。
参考③
上記のコードで使用した以下の詳細は、公式サイトをご確認ください。
●「Start-Process」コマンドレット