Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell SQL和get childitem不工作_Sql_Powershell_Foreach_Get Childitem - Fatal编程技术网

Powershell SQL和get childitem不工作

Powershell SQL和get childitem不工作,sql,powershell,foreach,get-childitem,Sql,Powershell,Foreach,Get Childitem,我的剧本中有一种非常奇怪的行为。我从SQL数据库查询广告帐户列表。然后为每个用户生成主文件夹的路径。这很好用 $rawdata = SQLSelect "SELECT Vorname,Nachname,AdAccount FROM IT.SapMitarbeiter ORDER BY adAccount"#OrgEinheitKurz" foreach ($data in $rawdata.Tables[0]) { $temppath = ($rootfolder + $($data.A

我的剧本中有一种非常奇怪的行为。我从SQL数据库查询广告帐户列表。然后为每个用户生成主文件夹的路径。这很好用

$rawdata = SQLSelect "SELECT Vorname,Nachname,AdAccount FROM IT.SapMitarbeiter ORDER BY adAccount"#OrgEinheitKurz"
foreach ($data in $rawdata.Tables[0])
{
    $temppath = ($rootfolder + $($data.AdAccount)).ToString()
    write-host "Path: " $temppath
}
例如,输出路径:\\server\share\username

现在我将收到每个文件夹的文件夹内容

$rawdata = SQLSelect "SELECT Vorname,Nachname,AdAccount FROM IT.SapMitarbeiter ORDER BY adAccount"#OrgEinheitKurz"
foreach ($data in $rawdata.Tables[0])
{
    $temppath = ($rootfolder + $($data.AdAccount)).ToString()
    write-host "Path: " $temppath
    Get-ChildItem -path $temppath
}
现在输出路径为:\\server\share\ 用户名将不再添加到字符串中,我完全不知道为什么

如果有人能帮我,那就太好了

非常感谢
格诺特

谢谢你的评论。问题是我正在运行脚本的服务器。在另一台服务器上,它工作正常。 非常奇怪。

能否尝试在$rawdata.Tables[0]中使用foreach$data?行?请尝试在写入主机路径:$temppath之前添加写入主机AdAccount:“$$data.AdAccount”,以确保行不是$null或其他内容。