Powershell import-csv question

Posted on 2012-08-21
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
    LVL 52

    Expert Comment

    by:Manpreet SIngh Khatra
    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
    Using the Import-Csv Cmdlet

    - Rancy
    LVL 52

    Expert Comment

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

    Author Comment

    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
    Can you try with someone just for testing with a csv for 2 users ?

    Import-csv "C:\filename.csv" | foreach {set-mailbox $_.MaxSendSize $}
    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
    LVL 6

    Accepted Solution

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

    Open in new window


    Author Closing Comment


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    EWS vs OWA 10 30
    Hard drive free space issue 12 29
    Xerox Work Centre 7556 scan to email setup 2 17
    Exchange 2010 DAG Node 2 13
    I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    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 …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    734 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