我有一个Powershell脚本,可以调用Get-ADComputer
,这时出现此错误:
Get-ADComputer:无法验证参数“ Identity”上的参数。的 参数上的Identity属性为null或为空。
这是脚本:
$computers = Get-Content -Path C:\Users\computersforscript.txt
foreach($line in $computers)
{
Get-ADComputer -Identity $line -Properties * | FT Name, LastLogonDate, MemberOf -Autosize
}
$computers |
Select-Object Name,LastLogonDate,MemberOf |
Export-CSV -Path C:\Users\output.txt -NoTypeInformation
The script does iterate through each workstation on "computersforscript.txt
" but it does not export it and it errors out.
非常感谢您能帮助我解决此问题。
答案 0 :(得分:0)
文件中似乎有空行。
您可以检查array:1 [▼
0 => array:3 [▼
"query" => "select * from `users` left join `website_user` on `users`.`id` = `website_user`.`user_id` left join `region_user` on `users`.`id` = `region_user`.`user_id` left ▶"
"bindings" => array:5 [▶]
"time" => 3.79
]
]
并修剪空白。
NullOrEmpty