0
我編寫了一個腳本,用於檢測W:\SUS Test2
子文件夾中名爲Post
的文件夾,並移動文件名中包含「EMMain」的CSV文件。但我的問題是CSV文件不會複製到目標文件夾W:\SUS Test3
它將其複製到W:\SUS Test2
文件夾。使用特定文件名移動文件
$path = "W:\SUS Test2\"
$destination = "W:\SUS Test3\"
$fsw = New-Object System.IO.FileSystemWatcher $path -Property @{
IncludeSubdirectories = $true
NotifyFilter = [IO.NotifyFilters]'DirectoryName
}
$createdLTC = Register-ObjectEvent $fsw -EventName Created -Action {
$item = Get-Item $eventArgs.FullPath
if ($item.Name -like "Post") {
Get-ChildItem $item -filter "*EMMain*" | Copy-Item -dest $destination
}
}