作为PowerShell的新用户并习惯使用unix中的oneliner,我发现powershell很奇怪。下面的代码给我一个“太多管道”类型的错误。谁能告诉我我做错了什么。我的最后一步是添加添加权限的代码,如果在else块中找不到。
[PS] C:\Windows\system32>(Get-mailbox -identity moh | select alias, distinguishedname) | foreach-object -process { if($_.distinguishedname -match "HK1|VO[1-9]") { $alias = $_.alias; get-mailboxfolderstatistics -identity $alias | Where {$_.FolderType -eq 'Calendar'} | %{ $calpath = $_.folderpath.substring(1); Get-MailboxFolderPermission -Identity $alias":\"$calpath -User iTell | %{ if($_.AccessRights -eq 'Editor') { write-host "Editor!" } else { write-host $_.AccessRights }} } } }
我收到以下错误。
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [], PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
答案 0 :(得分:0)
知道了。不得不用括号封装代码块。但我认为管道块只是某种写锁定。在这里,我只获取数据,因此应该能够从流中读取。