2017-04-24 4 views
1

Powershell v5.1 (Win2k16)을 사용하여 Msmq 대기열에 ACL을 설정하려고합니다. 그러나 설명서를 따르고 있지만 - 오류가 계속 발생합니다.Set-MsmqQueueACL - 허용 - 문서별로 목록을 사용할 수 없습니까?

Get-MsmqQueue -Name "s009_ClientsServiceBus" -QueueType Private | Set-MsmqQueueAcl -UserName "domain.com\WfxServiceBus" -Allow Peek,Write 

오류 :

Set-MsmqQueueACL : Cannot convert 'System.Object[]' to the type 
'System.Nullable`1[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]' required by parameter 'Allow'. Specified method is 
not supported. 
At line:1 char:128 
+ ... t-MsmqQueueAcl -UserName "domain.com\WfxServiceBus" -Allow Peek,Write 
+                ~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Set-MsmqQueueACL], ParameterBindingException 
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Msmq.PowerShell.Commands.SetMSMQQueueACLCommand 

Docs는 다음과 같은 예를 보여

Get-MsmqQueue –Name Order* –QueueType Private | Set-MsmqQueueAcl –UserName “REDMOND\madmax” –Allow Delete,Peek,Receive,Send –Deny TakeOwnership 

는 (일부 매개 변수 내 환경에 대한 잘못된 부여하지만, 동일한 오류) 것을 실행을 .. .

PS C:\Users\user> Get-MsmqQueue -Name Order* -QueueType Private | Set-MsmqQueueAcl -UserName "REDMOND\madmax" -Allow Delete,Peek,Receive,Send -Deny TakeOwnership 
Set-MsmqQueueACL : Cannot convert 'System.Object[]' to the type 
'System.Nullable`1[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]' required by parameter 'Allow'. Specified method is 
not supported. 
At line:1 char:100 
+ ... cl -UserName "REDMOND\madmax" -Allow Delete,Peek,Receive,Send -Deny T ... 
+           ~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Set-MsmqQueueACL], ParameterBindingException 
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Msmq.PowerShell.Commands.SetMSMQQueueACLCommand 

문서가 오래되었거나 뭔가 바뀌 었습니다. 질문은 - 내가 Powershell에서해야 할 일을 어떻게합니까? 그때는 잘 작동 '픽'을 '보내기'또는하지만 난 보낼 수 없습니다 : 등

.... -Allow "Peek,Send" 
.... -Allow "Peek","Send" 
.... -Allow 'Peek,Send' 

..

가 난 단지 하나 개의 옵션 즉 포함 된 경우 : I는 다음과 같은 조합을 많이 시도했습니다 문서별로 권리의 배열.

감사합니다.

업데이트 - -ALLOW 사용 "픽을 보내기"를 변경

PS C:\Users\meaton> Get-MsmqQueue -Name "s009_ClientsServiceBus" -QueueType Private | Set-MsmqQueueAcl -UserName "domain.com\WfxServic 
eBus" -Allow "Peek,Write" 
Set-MsmqQueueACL : Cannot bind parameter 'Allow'. Cannot convert value "Peek,Write" to type 
"Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights". Error: "Unable to match the identifier name Peek,Write to a valid 
enumerator name. Specify one of the following enumerator names and try again: 
DeleteMessage, PeekMessage, ReceiveMessage, WriteMessage, DeleteJournalMessage, ReceiveJournalMessage, SetQueueProperties, 
GetQueueProperties, DeleteQueue, GetQueuePermissions, GenericWrite, GenericRead, ChangeQueuePermissions, TakeQueueOwnership, 
FullControl" 
At line:1 char:128 
+ ... MsmqQueueAcl -UserName "domain.com\WfxServiceBus" -Allow "Peek,Write" 
+                ~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidArgument: (:) [Set-MsmqQueueACL], ParameterBindingException 
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Msmq.PowerShell.Commands.SetMSMQQueueACLCommand 

에 "를 PeekMessage, sendMessage 첨부"동일한 오류 산출 오류에 따라 :

...Set-MsmqQueueACL : Cannot bind parameter 'Allow'. Cannot convert value "PeekMessage,WriteMessage" to type 
"Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights" due to enumeration values that are not valid. Specify one of.... 

답변

0

워드 프로세서는 가능성을 누락 된 따옴표;

$allows = [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Peek -bor 
      [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Send -bor 
      [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Receive 

Set-MsmqQueueAcl -UserName "REDMOND\madmax" -Allow $allows 

: 비트 or를 사용하여, (제가 테스트 할 수 없습니다 그래서 내 2016 PS 5.1 상자에 MSMQ cmdlet에 또는 유형이없는) 그래서 가장 가능성이처럼 할 거라고, an enum that supports bitfields을 기대하고 있어요 그것은 모든 값을 따옴표로 묶어야합니다 (배열, 쉼표가있는 문자열이 아님). 그런 식으로 시도했지만 작동하지 않는다고 말했습니다. 다른 오류가 발생 했습니까?

+0

안녕하세요 - 예, 비슷한 오류 : –

+0

@MichaelEaton 열거 형 구문 분석을위한 문자열이 nullable enum이기 때문에 작동하지 않을 수 있지만 게시 된 명시 적 비트 버전이 작동해야합니다. 또는 문자열을 열거 형으로 먼저 캐스팅 ('$ allows = [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]'Peek, Send, Receive'') 할 수 있습니다. – briantist

+0

제안 사항을 사용하여 오류가 표시되도록 제 질문을 업데이트했습니다. 나는 당신의 bitwise 제안과 함께 my powershell 스크립트를 다시해야 할 것이다. –