Powershell SQL和get-childitem不起作用

问题描述 投票:0回答:1

我的脚本中有一个非常奇怪的行为。我从SQL数据库查询AD帐户列表。然后我为每个用户生成主文件夹的路径。这工作正常

$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
}

例如路径:\\服务器\共享\用户名

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

$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
}

现在输出为路径:\\服务器\共享\用户名将不再添加到字符串中,我绝对不知道为什么

如果有人可以帮助我,那会很好。

非常感谢Gernot

sql powershell foreach get-childitem
1个回答
0
投票

感谢您的评论。问题出在我正在运行脚本的服务器上。在另一台服务器上,它工作正常。很奇怪..

© www.soinside.com 2019 - 2024. All rights reserved.