View Single Post
Old 10-09-2008   #7 (permalink)
daystrom


Vista Ultimate 32, Ultimate 64, Server 2008
 
 

Re: Pipe compare-object results into something useable

Quote  Quote: Originally Posted by PaulChavez View Post
In that case the InputObject property of the comparison is the whole line
from the CSV right? I wouldn't think the code as written below would work
correctly, the email address and name would be set to something like "Mickey
Mouse,mmouse@xxxxxx".

To get a different "fields" you can use the split method like this:
new-mailcontact -ExternalEmailAddress "SMTP:$($_.InputObject.split(",")[0])"
-Name "$($_.InputObject.split(",")[1])"
Very nice! I had to change the (",") to (',') however. The shell came back with a "Incomplete $(subexpression) sequence in string." error.

This does exactly what I want now. If the contact is on the left side and not the right it will create a mail contact in Exchange. With a little modification if it exists on the right and not left it will remove the contact.

You are a wizard!

Thanks!

Todd
My System SpecsSystem Spec