Solved

setting recipient limits on multiple users in Powershell

Posted on 2016-07-15
13
119 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 69

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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 80

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 80

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 69

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 80

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
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…

756 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