我想使用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'
等。
如果我只包括一个选项,即:“发送”或“偷看”,那么它工作正常,但我不能发送根据文件的一系列权利。
谢谢!
更新 - 使用 - 允许 “窥视,发送”:
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....
嗨 - 是的,类似的错误: –
@MichaelEaton枚举分析字符串可能不工作,因为它是一个可为空的枚举,但我公布的明确按位版本应该工作;或者可能会将字符串强制转换为第一个枚举('$ allow = [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]'Peek,Send,Receive')。 – briantist
我已更新我的问题,以使用您的建议显示错误。我将不得不在明天重新执行我的powershell脚本,并提出你的建议。 –