Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.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生产线是做什么的?_Powershell - Fatal编程技术网

这条Powershell生产线是做什么的?

这条Powershell生产线是做什么的?,powershell,Powershell,我想了解这个PowerShell行的意思,这样我就可以用C编写它了 $visitor = $roles | ? { ` ($groups | ? { $_.Title -like '*Visitors'} | % {$_.Id}) -Contains ` $_.PrincipalId } | select -ExpandProperty PrincipalId $Visitor是一个变量,此代码的最终结果将存储在其中 $Roles必须已经包含脚本中前面部分的一些信息集 ??{$

我想了解这个PowerShell行的意思,这样我就可以用C编写它了

$visitor = $roles | ? { `
    ($groups | ? { $_.Title -like '*Visitors'} | % {$_.Id}) -Contains `
    $_.PrincipalId } | select -ExpandProperty PrincipalId
$Visitor是一个变量,此代码的最终结果将存储在其中

$Roles必须已经包含脚本中前面部分的一些信息集

??{$groups |?{$\.Title-like'*Visitors'}

?{}是使用Where对象函数的一种方法。因此,这段代码在包含文本访问者的$groups内捕获和获取具有Title属性的对象

|%{$\.Id}-包含$\.PrincipalId}

这部分将获取前面代码的结果,并表示对于返回的每个对象,它将查找PrincipalID属性,并查看它是否存在于Id属性中

|选择-ExpandProperty PrincipalId

如果前面的代码返回对象,它会将它们发送到此代码,该代码将选择属性PrincipalId,这就是存储在$Visitor变量中的内容

如果我的任何想法不正确,请有人告诉我,以便我可以编辑此内容,我尝试使用我所掌握的知识。

请阅读-总结是,这不是向志愿者致辞的理想方式,可能会对获得答案产生反作用。请不要将此添加到您的问题中。