2011-03-29 77 views
1

是新的powershell和用於unix中的oneliners我覺得powershell奇怪。下面的代碼給了我一個「太多管道」類型的錯誤。任何人都可以告訴我我做錯了什麼。我的最後一步是添加代碼,如果在else塊中找不到它,則會添加權限。PowerShell命令行與管道錯誤使用Exchange 2010

[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

明白了。必須用括號封裝代碼塊。但我認爲管道塊只是某種寫鎖。在這裏,我只是獲取數據,因此應該能夠從流中讀取數據。