Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.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导入CSV并获取Aduser_Powershell_Syntax - Fatal编程技术网

Powershell导入CSV并获取Aduser

Powershell导入CSV并获取Aduser,powershell,syntax,Powershell,Syntax,我有一个带有用户列表的CSV文件。文件中有两列:姓氏和姓名。我需要过滤带有姓氏和特定OU的用户。我使用了此命令,但它不起作用: Import-CSV c:\work_sharepoint\output\DoublonsSharepointTest.csv | % { Get-ADUser -f "sn -eq $($_.Surname)" -Searchbase "OU=Portail_User_Sharepoint,OU=OU-SNE_SharePoint,DC=vnf,DC=local"}|

我有一个带有用户列表的CSV文件。文件中有两列:姓氏和姓名。我需要过滤带有姓氏和特定OU的用户。我使用了此命令,但它不起作用:

Import-CSV c:\work_sharepoint\output\DoublonsSharepointTest.csv | % { Get-ADUser -f "sn -eq $($_.Surname)" -Searchbase "OU=Portail_User_Sharepoint,OU=OU-SNE_SharePoint,DC=vnf,DC=local"}| Move-ADObject -TargetPath "ou=Disable Sharepoint Users,dc=vnf,dc=local"

非常感谢您的帮助。

我认为需要引用姓氏,例如:

... -f "sn -eq `"$($_.Surname)`"" ...

(不幸的是,我无法帮助您使用Powershell,但是……)“不工作”是一个模棱两可的描述。实际发生了什么而不是预期的结果?你犯了什么样的错误?该死的,你赢了我。不过,我会使用单引号作为嵌套引号。使它更容易阅读。