必须在' - '运算符的右侧提供值表达式

时间:2017-06-16 21:38:03

标签: powershell powershell-v2.0 windows-server-2008 powershell-v1.0

$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 ';'}}

你能帮助我找出问题吗?

1 个答案:

答案 0 :(得分:0)

这看起来有点像,其他人发布的是什么。如果Powershel 1不支持System.Net.ServicePointManager.DefaultConnectionLimit = 1000; (我真的不知道,但我看起来像),你可以这样做:

-join