2017-04-24 6 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' 

など:私のような組み合わせの多くを試みたことが正常に動作し、「のぞき見」を「送信」またはを、私は送信できません。ドキュメントごとの権利の配列。

ありがとうございます!

アップデート - -ALLOW使用して "のぞき見を送信":エラーごとに "のPeekMessage、SendMessage関数" に変更

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 

が正確に同じエラーを得られます。

...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

ドキュメントがそうです不足している引用符。それは、ビット単位のorを使用して、(私はテストすることはできませんので、私は私の2016 PS 5.1のボックスにMSMQコマンドレットまたは種類を持っていない)、あなたはこのようにそれを行うと思いますので、最も可能性の高いan enum that supports bitfieldsを期待しています:

$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 

でなければなりません。すべての値を引用符で囲んで(つまり、配列ではなく、コンマで区切られた文字列でも)動作しますが、そのように試してみたところ、動作しませんでした。それは違う誤りを生み出しましたか?

+0

Hi - はい、同様のエラー: –

+0

@MichaelEaton nullの列挙型であるため、列挙型解析の文字列が機能していない可能性があります。または可能であれば、文字列を列挙型に最初にキャストします( '$ allows = [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights] 'Peek、Send、Receive'')。 – briantist

+0

あなたの提案を使用してエラーを表示するように質問を更新しました。私はあなたのビットワイズの提案で明日私のPowerShellスクリプトをやり直さなければならないでしょう。 –

関連する問題