powershell - Powershell 脚本在本地工作,但不能在 solarwinds SAM 组件下工作
问题描述
以下是在 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
解决方案
推荐阅读
- groovy - Jenkins cps groovy does not catch NoSuchMethodError exceptions
- javascript - How do i assign a lazyloaded component to Routes.js in React Router
- sql - 如何使用 nextval() 在字符串中插入包含自己 ID 的行
- r - shift names of list up one level
- python - PyInstaller. Run > pyinstaller myapp.spec from script works diffrent than from command line
- django - Save two model (One contains foreign key) data from a single template
- python - 删除键但保留字典中的值
- c++ - C ++为什么我的第一个数据输入 getline(cin, array[x]) 在同一行并且损坏了,而我的第二个数据输入很好?
- kernel - 我在哪里可以找到 QNX 内核转储?
- azure-devops - azure devop build pipeline not triggering