Solved

setting recipient limits on multiple users in Powershell

Posted on 2016-07-15
13
65 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
  • 4
  • 3
  • 2
  • +2
13 Comments
 
LVL 83

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 6

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 68

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
 
LVL 78

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
Are end users causing IT problems again?

You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

 

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 78

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 68

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 78

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this video we show how to create a Distribution Group 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 Recipients >>…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now