Powershell import-csv question


I have a CSV file with two columns; the first column is a “mailbox” and the second column is a proposed “MaxSendSize”(i.e each row has a different mailbox name and a different “MaxSendSize” number).

I need a powershell script that can read from this CSV file so that it can set the MaxSendSize for every mailbox on exchange as per this CSV file.

For powershell scriptwriters with no exchange cmdlet knowledge, this is how the maxsendsize id usually set:

Get-mailbox “mailbox from the csv file” | Set-Mailbox –MaxSendSize “from the CSV file on the same raw”
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Try with one or 2 and see if that helps
Import-Csv "name".csv | Set-Mailbox

- Rancy
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Using the Import-Csv Cmdlet

- Rancy
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Found something more so though of sharing


## Import data from csv and store it in variable 'data'

$data = import-csv $args[0]

foreach ($i in $data)
 $alias = $i.First[0] + $i.Last

 $custom1 = $i.Custom1

 Set-Mailbox -Identity $alias -CustomAttribute1 $custom1

- Rancy
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

datacomsmtAuthor Commented:
Hi Rancy,

Thanks for your help, but non of this answers my question...
I believe it should be a 3-4 line script to "read" each mailbox namde, | set the value from the same raw..
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Can you try with someone just for testing with a csv for 2 users ?

Import-csv "C:\filename.csv" | foreach {set-mailbox $_.MaxSendSize $_.name}

1. Create a CSV file with all the usernames of all users whom you want to change message size - with heading for that column as UName
2. run the below powershell cmdlets

$users = import-csv "<Location of CSV>"
$users | foreach{set-mailbox -identity $_.UName -MaxReceiveSize <Size> -MaxSendSize <Size> -whatif}

- Rancy
Import-CSV C:\mailboxes.csv | 
ForEach-Object { 
    Set-Mailbox -Identity $_.Mailbox -MaxSendSize $_.MaxSendSize

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
datacomsmtAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.