Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Powershell import-csv question

Posted on 2012-08-21
Medium Priority
Last Modified: 2012-08-21

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”
Question by:datacomsmt
  • 4
  • 2
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38315724
Try with one or 2 and see if that helps
Import-Csv "name".csv | Set-Mailbox

- Rancy
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38315727
Using the Import-Csv Cmdlet

- Rancy
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38315745
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
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!


Author Comment

ID: 38315894
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..
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38315931
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

Accepted Solution

slidingfox earned 2000 total points
ID: 38316067
Import-CSV C:\mailboxes.csv | 
ForEach-Object { 
    Set-Mailbox -Identity $_.Mailbox -MaxSendSize $_.MaxSendSize

Open in new window


Author Closing Comment

ID: 38316294

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

Question has a verified solution.

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

Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
You finally migrated Public Folders to Office 365, decommissioned the Public Folder mailbox database and since then, when you send an email from on-premise to mail-enabled Public Folders, you get the following error: "Misconfigured public folder mai…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses

571 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