![](https://powershell.work/wp-content/themes/cocoon-master/images/b-woman.png)
Power Shellで
・ZIPファイルを解凍(展開)
できます!
※ここで紹介するのは「パスワード無しZIPファイル」の解凍(展開)方法です。
コード
ここでは例として
・デスクトップ配下のZIPファイル「ken_all.zip」を
・デスクトップ配下のフォルダ「output」配下へ解凍(展開)
します。
![ZIPファイル](https://powershell.work/wp-content/uploads/2022/07/ps_zipfile_expand-archive_001.png)
# 解凍(展開)するZIPファイルを指定
$zipFilePath = "C:\Users\user\Desktop\ken_all.zip"
# 解凍(展開)先フォルダを指定
$destFolderPath = "C:\Users\user\Desktop\output"
$ws = New-Object -ComObject Wscript.Shell
try
{
Expand-Archive -Path $zipFilePath -DestinationPath $destFolderPath -Force
$ws.popup("解凍(展開)に成功しました。")
}
catch
{
$ws.popup("エラー : " + $PSItem)
}
実行結果
ZIPファイルを解凍(展開)できました。
![実行結果①](https://powershell.work/wp-content/uploads/2022/07/ps_zipfile_expand-archive_002.png)
![実行結果②](https://powershell.work/wp-content/uploads/2022/07/ps_zipfile_expand-archive_003.png)
![実行結果③](https://powershell.work/wp-content/uploads/2022/07/ps_zipfile_expand-archive_004.png)
参考①
ファイル/フォルダをZIP形式で圧縮することもできます。
詳細は以下の記事をご確認ください。
参考②
上記で使用した以下の詳細は、公式サイトをご確認ください。
●「Expand-Archive」コマンドレット