argument transformation error - removed

Disregard my earlier post.

  • Edited by PK__ 16 hours 22 minutes ago
September 10th, 2015 10:11am

The error is pretty explicit: "Cannot convert null to type "

You need to post code using posting control and format so it is readable.  What you posted is an unreadable mess.

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 10:22am

I am trying to write a script that will look at a specific group of users in Office
365 (this is for 10,000 existing users in on premise AD getting email in
hybrid), test their E1 license status, and then create a remote mailbox for each
user by passing the emailaddress object into a foreach loop.  I get the
following error:

Cannot process argument transformation on parameter 'PrimarySmtpAddress'.
Cannot convert null to type "Microsoft.Exchange.Data.SmtpAddress".
    +
CategoryInfo          : InvalidData: (:) [Enable-RemoteMailbox],
ParameterBindin...mationException
    + FullyQualifiedErrorId :
ParameterArgumentTransformationError,Enable-RemoteMailbox
    +
PSComputerName        : exch-cas.com

Here is the script:

$Groupname = 'Office365E1'
  $GroupID = (Get-MsolGroup -All |
Where-Object {$_.DisplayName -eq $Groupname}).ObjectId

  Write-Output "Checking for unlicensed users in group Office365E1 with
ObjectGuid $GroupID... to enable remote mailbox"

  $GroupMembers = (Get-MsolGroupMember -GroupObjectId $GroupID -All |
Where-Object {$_.IsLicensed -eq $false}).emailaddress
                    

            foreach ($User in $GroupMembers) {
               
 
                    Try {
                     
             
{$ParsedUser=$User.Split("@")[0]}

                 Enable-RemoteMailbox  $User -PrimarySmtpAddress $User
-RemoteRoutingAddress $ParsedUser+'@tenant.mail.onmicrosoft.com'
           

                 Set-RemoteMailbox -Identity $User -EmailAddresses
@{add=$ParsedUser+'@tenant.mail.onmicrosoft.com'}

                    Write-Output "Successfully enabled remotemailbox for
$User"

                    } catch {

                    Write-Warning "Error when enabling remotemailbox for
$User"

                    }

                } 

Put in a trace statement to verify that $user is actually set to something.

PS - jrv's statement is correct. Code is much easier to read if you post it pro

September 10th, 2015 10:38am

  If you don't want to provide helpful comments on what is going wrong with my script, then please do waste your time or mine replying to my post or others you consider beneath your level of expertise. The purpose of most of these forums is to get help and not to see comments from people that need to get over themselves.

Wow.... Never mind.

Goodbye.

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 10:47am

  If you don't want to provide helpful comments on what is going wrong with my script, then please do waste your time or mine replying to my post or others you consider beneath your level of expertise. The purpose of most of these forums is to get help and not to see comments from people that need to get over themselves.

I simply asked you to fix the post so that it was readable.  If this is code you have copied from somewhere then it explains why it is so badly broken.  As posted it will not work.

If you just want someone to fix your code for free then you should hire a trained consultant.  This is not really an end user forum.

Throwing your hands up and deleting your post is not a very professional response to a simple request for you to fix your post.

September 10th, 2015 10:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics