我有一个通过SSIS进程任务调用的PowerShell脚本,用于检查文件是否被锁定 - 我该如何修改它以首先检查文件是否存在。
If it does not exist, then exit with 999
If it does exist but is locked, then exit with 999
If it does exist and is not locked, then exit with 0
$file = "\\xxxxxx\xxxx\xxxxx\xxxxxxxxx\task_status.log" try { [IO.File]::OpenWrite($file).close();exit 0 } catch { exit 999}