Solved

setting recipient limits on multiple users in Powershell

Posted on 2016-07-15
13
131 Views
Last Modified: 2016-09-07
Hello,

I have the basic command

 Set-Mailbox -Identity "John.Smith@doe.com" -RecipientLimits 100

However I have 300 of these to set and I am getting errors trying to give the command a list of PrimarySMTPAddress to set.

I have tried by importing a csv file and having it import a txt with a list of address but I keep getting an "Identity" error

[PS] C:\temp\Mark\move>Set-Mailbox $_recip -RecipientLimits 25
Cannot process argument transformation on parameter 'Identity'. Cannot convert the "System.Collections.ArrayList" value
 of type "System.Collections.ArrayList" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter".
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox

[PS] C:\temp\Mark\move>Set-Mailbox (Get-Content C:\temp\mark\move\recip.txt) -RecipientLimits 25
Cannot process argument transformation on parameter 'Identity'. Cannot convert the "System.Collections.ArrayList" value
 of type "System.Collections.ArrayList" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter".
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox


Any thoughts out there??
0
Comment
Question by:mwjones75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
13 Comments
 
LVL 84

Assisted Solution

by:oBdA
oBdA earned 250 total points
ID: 41713444
Can't test it, but it seems like Set-Mailbox doesn't accept an array as input, so you'll just have to loop through the list:
Get-Content C:\temp\mark\move\recip.txt | % {Set-Mailbox -Identity $_ -RecipientLimits 25}

Open in new window

1
 
LVL 7

Expert Comment

by:Thomas Wheeler
ID: 41713445
have you tried piping it to the set-mailbox like this
get-mailbox | Set-Mailbox -RecipientLimits 100

Open in new window

1
 
LVL 70

Accepted Solution

by:
Qlemo earned 250 total points
ID: 41713447
As you didn't post everything, it is difficult to tell why the first one didn't work.
But you need to provide a single identity value to the cmdlet at all times. E.g.
Get-Content C:\temp\mark\move\recip.txt | % { Set-Mailbox $_ -RecipientLimits 25 }

Open in new window

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 41713475
restrict.csv
user,limit
john,50
jane,100
andy,100

Open in new window


Get-Content C:\temp\restrict.csv | foreach { Set-Mailbox $_.user -RecipientLimits $_.limit }

Open in new window

1
 

Author Comment

by:mwjones75
ID: 41714830
Thank you all again!!
0
 

Author Comment

by:mwjones75
ID: 41714831
Sorry didnt save my last comment...

Thank you all for your help it was very much appreciated!!   I am new to this site and this was very helpful.
0
 

Author Comment

by:mwjones75
ID: 41717557
Thank you..  this is only my second question and I am savvy with the proper edict.


I first tried the solution of
David Johnson, CD, MVP and I am not sure why it didnt work  as it looked as if it should...  I did however get this error

Cannot process argument transformation on parameter 'RecipientLimits'. Cannot convert null to type "Microsoft.Exchange.
Data.Unlimited`1[System.Int32]".
0
 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 41717809
that would imply that the csv doesn't have a column named limit
user,limit
john,50
jane,100
andy,100

Open in new window

$users= Get-Content C:\temp\restrict.csv 
 foreach ($user in $users) 
    { 
    try {
        Set-Mailbox $user.user -RecipientLimits $user.limit 
        }
    catch {
        write-warning('User: '+$user.user+' Limit: '+$user.limit)
        }
 }

Open in new window

0
 
LVL 70

Expert Comment

by:Qlemo
ID: 41717912
David: Get-Content and a CSV file? You certainly wanted to use Import-CSV. Then it should work.
0
 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 41718098
face-palm
0
 

Author Comment

by:mwjones75
ID: 41719344
thank you all again...  hopefully I give everyone proper credit
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question