以下是在 powershell ISE 下本地运行的脚本。但在 SAM 组件下相同,即 Windows powershell 监视器不工作
脚本检查 path1 下的 doc 文件是否存在。它从 path1 获取文件的副本,并通过重命名时间戳移动到 Path2。
$directory = 'path1'
$filter = '*.doc'
$msg = ' '
$com = ","
$count = 0
$stamp = Get-Date -F yyyy-MM-dd_HH-mm
Get-ChildItem -Path $directory -Filter $filter | Foreach-Object {
$msg = $msg + $com + $_.FullName
$dest = "path1" + $_.Name
$newName = "path1" + "$($_.BaseName)_$stamp$($_.Extension)"
Copy-Item -Path $_.FullName -Destination $newName
$count = $count + 1
}
if($count -gt 0)
{
write-host 'Statistic.FileMonitor:' $count;
write-host "Message.FileMonitor: $count file found and moved, Filenames- $msg"
exit 0
}
else
{
write-host 'Statistic.FileMonitor:' $count;
write-host "Message.FileMonitor: $count files found, Filenames- $msg"
exit 0
}
当执行模式设置为本地主机时。它执行。但它说没有找到文件。即使文件存在于path1下
当执行模式被视为远程时。我得到的结果是 Down