Solved

setting recipient limits on multiple users in Powershell

Posted on 2016-07-15
13
76 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 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 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. 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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
A brief introduction to what I consider to be the best editor for PowerShell.
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 >>…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

948 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

18 Experts available now in Live!

Get 1:1 Help Now