Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"System.__ComObject" is not valid for UserPrincipalName

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
I am working on a script that reads an Excel spreadsheet to get data to create user accounts in Exchange 2007. The required elements for doing that include a UserPrincipalName which would be a unique email address.

For some reason the email addresses are not being accepted. I have tried converting the variable to string using:
Code:
$email = $excel.Cells.Item($intRow,5)
$email = [string] $email

My code to create the mailbox is:
Code:
	new-mailbox `
		-UserPrincipalName $email `
		-Password $pass `
		-Database $Database ` 
		-OrganizationalUnit $ou `
		-ResetPasswordOnNextLogon $True

The reason I am using Excel instead of a CSV is because I need to edit the excel file while manipulating the user object. I know that my variable $intRow is processing to increment the row numbers in Excel just fine due to the fact that it is recording the failed attempts to create the users.

Does anyone know if there is anything special I need to do to read an email address from Excel and have it be treated as plain text? If so what changes do I need to make for that?
Thank you.
 
I apparently have to use
$email = $excel.Cells.Item($intRow,5).Text

Got past the first round of errors, now I just have to continue debugging.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I wanted to do that but that does not let you write back to the spreadsheet. That is why I am taking the approach I am.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top