【发布时间】:2017-11-19 18:28:20
【问题描述】:
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$adsi.Children | where {$_.SchemaClassName -eq 'user'} | Foreach-Object {
$groups = $_.Groups() | Foreach-Object {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
$_ | Select-Object @{n='UserName';e={$_.Name}},@{n='Groups';e={$groups -join ';'}}
}
您好...当我在服务器 2008 中运行上述脚本时,我收到下面提到的错误。
You must provide a value expression on the right-hand side of the '-' operator.
At C:\Temp\Usrgrp.ps1:4 char:73
+ $_ | Select-Object @{n='UserName';e={$_.Name}},@{n='Groups';e={$groups -j <<<< oin ';'}}
您能帮我找出问题所在吗?
【问题讨论】:
-
错误消息中的格式看起来有点奇怪...你是从某个地方复制的吗?看起来里面有一个奇怪的字符...
-
是的,我拿这个来做个例子试试……
-
也刚刚发现该错误仅出现在powershell v1.0中,但在其他版本中它很好...请告诉我您是否可以帮助我...
标签: powershell powershell-2.0 windows-server-2008 powershell-1.0