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 Newb-无法转换_Powershell - Fatal编程技术网

PowerShell Newb-无法转换

PowerShell Newb-无法转换,powershell,Powershell,我正在学习Powershell,我正在努力理解为什么它不起作用。我验证了-Identity接受管道,所以我猜测它传递的值的类型,但我不明白为什么这不起作用 获取ADUser-Identity(导入Csv.\GROUP.Csv) GROUP.csv是我桌面上的一个文件,其中包含SID列表。我可以在执行导入Csv时阅读它,没有任何问题。\GROUP.Csv。结果如下 S-1-5-21-583907252-1979792683-725345543-112088 S-1-5-21-583907252-1

我正在学习Powershell,我正在努力理解为什么它不起作用。我验证了-Identity接受管道,所以我猜测它传递的值的类型,但我不明白为什么这不起作用

获取ADUser-Identity(导入Csv.\GROUP.Csv)

GROUP.csv是我桌面上的一个文件,其中包含SID列表。我可以在执行导入Csv时阅读它,没有任何问题。\GROUP.Csv。结果如下

S-1-5-21-583907252-1979792683-725345543-112088 S-1-5-21-583907252-1979792683-725345543-48881
S-1-5-21-583907252-1979792683-725345543-48880
S-1-5-21-583907252-1979792683-725345543-53776
S-1-5-21-583907252-1979792683-725345543-125569
S-1-5-21-583907252-1979792683-725345543-120374
S-1-5-21-583907252-1979792683-725345543-48882
S-1-5-21-583907252-1979792683-725345543-183175
S-1-5-21-583907252-1979792683-725345543-183136
S-1-5-21-583907252-1979792683-725345543-183130
S-1-5-21-583907252-1979792683-725345543-183112
S-1-5-21-583907252-1979792683-725345543-176034
S-1-5-21-583907252-1979792683-725345543-176023
S-1-5-21-583907252-1979792683-725345543-176022
S-1-5-21-583907252-1979792683-725345543-176002
S-1-5-21-583907252-1979792683-725345543-175974
S-1-5-21-583907252-1979792683-725345543-175931
S-1-5-21-583907252-1979792683-725345543-175889
S-1-5-21-583907252-1979792683-725345543-175836
S-1-5-21-583907252-1979792683-725345543-175804
S-1-5-21-583907252-1979792683-725345543-183195
S-1-5-21-583907252-1979792683-725345543-183180
S-1-5-21-583907252-1979792683-725345543-31219
S-1-5-21-583907252-1979792683-725345543-176037
S-1-5-21-583907252-1979792683-725345543-82576
S-1-5-21-583907252-1979792683-725345543-175905
S-1-5-21-583907252-1979792683-725345543-175777
S-1-5-21-583907252-1979792683-725345543-175765

除此之外,我还可以使用Get ADUser-Identity,这很好

为什么在尝试将一个管道连接到另一个管道时会出现以下情况

无法将“System.Object[]”转换为参数“Identity”所需的类型“Microsoft.ActiveDirectory.Management.ADUser”。 不支持指定的方法。 第1行字符:22 +获取ADUser-Identity(获取内容。\group.txt) + ~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:InvalidArgument:(:)[Get ADUser],参数BindingException
+FullyQualifiedErrorId:CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.GetADUser

参数
-identity
不接受
数组作为输入,但它接受
管道
通过
值输入

Import-Csv .\GROUP.csv | Get-ADUser

如果.csv文件中第一列的名称为sid,则也可以尝试此选项

 (Import-CSV .\Group.csv) | foreach-object { get-aduser -Identity $_.sid }