Solved

setting recipient limits on multiple users in Powershell

Posted on 2016-07-15
13
153 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 85

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
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.

 
LVL 82

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 82

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 82

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

What, When and Where - Security Threats from Q1

Join Corey Nachreiner, CTO, and Marc Laliberte, Information Security Threat Analyst, on July 26th as they explore their key findings from the first quarter of 2017.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
In this video we show how to create a Shared Mailbox 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 >> Sha…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

623 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