这是我第一次使用Powershell,请原谅我的无知。
我有一个SQL查询,返回一堆订单号。我想检查另一个文件,以查看该文件中是否存在与SQL查询返回的订单号同名的PDF。
我的代码中的所有内容都可以正常运行,直到ForEach循环不返回任何内容。根据我的Google搜索,我认为我已经很接近了,但是我不确定自己在做什么错。任何帮助,将不胜感激。
出于明显的原因,我已经删除了实际的文件名,并且我知道该文件是正确的,并且其他命令也可以访问它,所以我知道目前这不是我的问题。我还从SQL查询中删除了敏感信息。
$statement = "SELECT A, Date FROM XXXX
WHERE STAT = 1 AND Date >= trunc(sysdate)"
$con = New-Object System.Data.OracleClient.OracleConnection($connection_string)
$con.Open()
$cmd = $con.CreateCommand()
$cmd.CommandText = $statement
$result = $cmd.ExecuteReader()
$list = while ($result.Read()) { $result["A"]}
Write-Output $list
#########Loop through the list above here to check for matching PDF
ForEach ($Order in $list){
Get-ChildItem "\\xxxxxx\" -Filter $Order -File
#########If FALSE - notify that PDF is missing
}
$con.close()
我还尝试了以下代码,这使我更接近并实际上找到了我要查找的文件,但出现了错误
“ Get-ChildItem:找不到接受参数
的位置参数
ForEach ($Order in $list){
if((Get-ChildItem "\\xxxxx\" + $Order)){
Write-Output
} else { Write-Host "Does not exist."}
答案 0 :(得分:0)
我从您的评论中得知,ansible-playbook async.yml -T 20 --extra-var "secondsTaskLong=9 timeoutSeconds=3"; watch -n 1 -d "ls -l testFile"
ansible-playbook async.yml -T 20 --extra-var "secondsTaskLong=10 timeoutSeconds=3"; watch -n 1 -d "ls -l testFile"
是订单号的数组。
接下来,您要检查文件夹中是否存在具有该名称的文件,对吗?
那么我建议您使用function test(parameter) {
$(parameter).trigger("click");
};
$("#buttonOne").on("click",function() {
test('"#correctParameter"');
});
而不是$list
:
Test-Path