mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 New-Mailbox : The argument cannot be null or empty

Author Message
Lana85

  • Total Posts : 35
  • Scores: 0
  • Reward points : 0
  • Joined: 10/8/2009
  • Status: offline
New-Mailbox : The argument cannot be null or empty Monday, October 12, 2009 3:22 AM (permalink)
0
Hi,

I have a csv file like this:
FirstName;LastName;Site;Alias;UPN;DisplayName;Password
Eric;Jens;Paris;E.Jens;Eric.Jens@mahui.com;Eric Jens;Welcome

And I have my Script:
 ## Import data from csv and store it in variable 'data'
 $data = import-csv $args[0]
 
 ## Function to convert password into a secure string
 function New-SecureString([string] $plainText)
 {
    $secureString = new-object System.Security.SecureString
    
    foreach($char in $plainText.ToCharArray())
    {
       $secureString.AppendChar($char)
    }
    $secureString
 }
 
 foreach ($i in $data)
 {
  $ss = new-securestring $i.password
  ## Mailbox Database Path
  $db = "Server_Name\SG01\MDB"
  ## Organization Unit
  $ou = "OU=Users,OU=Administration,DC=Mahui,DC=COM"
  New-Mailbox -Alias $i.Alias -Name $i.DisplayName -OrganizationalUnit $ou -FirstName $i.FirstName -LastName $i.LastName -UserPrincipalName $i.UPN -Database $db -Password $ss -ResetPasswordOnNextLogon $true
  }
 


When I run my script c:\mail.ps1 c:\mail.csv

It returns this error:

New-Mailbox : The argument cannot be null or empty.
At C:\mail.ps1:28 char:20
+  New-Mailbox -Alias  <<<< $i.Alias -Name $i.DisplayName -OrganizationalUnit $
ou -FirstName $i.FirstName -LastName $i.LastName -UserPrincipalName $i.UPN -Dat
abase $db -Password $ss -ResetPasswordOnNextLogon $true

Does anyone have an idea?
Thx

#1
    Lana85

    • Total Posts : 35
    • Scores: 0
    • Reward points : 0
    • Joined: 10/8/2009
    • Status: offline
    Re:New-Mailbox : The argument cannot be null or empty Monday, October 12, 2009 9:38 PM (permalink)
    0
    I found the solution...
    1/ Instead of ";" I use ","
    2/ I change a part of my code
    ## Import data from csv and store it in variable 'data'
     $data = import-csv c:\mail.csv

    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.8
      mbt shoes www.wileywilson.com