I am trying to automate the creation of MSMQ queues using powershell
I have no problems creating the queue, I just cannot appear to be able to set the permissions correctly
I have been following what is documented here Setting permissions on a MSMQ queue in a script
and here https://learn.microsoft.com/en-us/powershell/module/msmq/set-msmqqueueacl?view=win10-ps
This is my command to create the queue
New-MsmqQueue -Name "ThisIsTestName" -QueueType Private
but when I try to set the permissions, using this command
Get-MsmqQueue -Name "ThisIsATestName" -QueueType Private | Set-MsmqQueueAcl -UserName "Everyone" -Allow Peek,Receive,Send,Delete,GetProperties,GetPermissions
I am getting this error
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:105
+ ... veryone" -Allow Peek,Receive,Send,Delete,GetProperties,GetPermissions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-MsmqQueueACL], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Msmq.PowerShell.Commands.SetMSMQQueueACLComm
So I tried removing all the allow, and just using FullAccess.
This did not give me an error, but it did not set the permissions
looking further, I came across this post:
Set-MsmqQueueACL - Allow - can't use list as per docs?
So I updated to the following
$allows = [Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Peek -bor
[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Receive -bor
[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Send -bor
[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::Delete -bor
[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::GetPermissions -bor
[Microsoft.Msmq.PowerShell.Commands.MessageQueueAccessRights]::GetProperties
Get-MsmqQueue -Name "ThisIsATestName" -QueueType Private | Set-MsmqQueueAcl -UserName "Everyone" -Allow $allows
But I am still getting the same error
I know I have made a stupid mistake somewhere but I cannot see what I have done wrong
Attempting to do this on a windows 10 machine