Set office address to bulk mailboxes RRS feed

  • Question

  • Hi,

    I have smtp addresses and office address in csv file. Can anyone provide the powershell script to set different office address to different rooms thorught powerhsell script i tried below. but no luck.

    $Roommailboxes = Get-Content "C:\temp\adminpadavalla\conf.csv"
    foreach($Roommailbox in $Roommailboxes){
    $UPN = $Roommailbox.UPN
    $office = $Roommailbox.office
    set-mailbox $Roommailbox -office $office
    Write-Host "$UPN office address changes to $office"


    Naveen Kumar

    Monday, August 26, 2019 6:32 AM

All replies

  • Please format your code as code using the code posting tool provided on the icon bar of the post editor (second to last icon). Thanks.

    If you use a CSV file you should use the proper cmdlets. To import data from a CSV file you use Import-CSV. Please read the complete help including the examples to learn how to use it.

    If you describe your problem you should use something more desciptive than "but no luck." Do you get errors? If yes you should post the complete error message (formatted as code as well please).

    Live long and prosper!


    Monday, August 26, 2019 9:19 AM
  • In addition to using Import-CSV instead of Get-Content as BofH-666 said, your "set-mailbox $Roommailbox -office $office" should probably be "set-mailbox $UPN -office $office".

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Monday, August 26, 2019 2:50 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Friday, September 6, 2019 11:48 AM