ディレクトリ内のフォルダの一覧を取得して最新の.bakファイルを圧縮するpowershellスクリプト別のディレクトリにコピーします。Powershell - ディレクトリ内のすべてのフォルダを一覧表示し、各フォルダ内の最新の.bakファイルを取り出し、圧縮してディレクトリにコピーします。
.bakファイルを検索したくない2つのフォルダがあります。これらのフォルダはどのように除外しますか?私は複数の方法を試しています - 除外ステートメントと私は運がなかった。私は無視したい
フォルダは、「新しいフォルダ」と「新folder1の」
$source = "C:\DigiHDBlah"
$filetype = "bak"
$list=Get-ChildItem -Path $source -ErrorAction SilentlyContinue
foreach ($element in $list) {
$fn = Get-ChildItem "$source\$element\*" -Include "*.$filetype" | sort LastWriteTime | select -last 1
$bn=(Get-Item $fn).Basename
$CompressedFile=$bn + ".zip"
$fn| Compress-Archive -DestinationPath "$source\$element\$bn.zip"
Copy-Item -path "$source\$element\$CompressedFile" -Destination "C:\DigiHDBlah2"
}
はありがとうございます!