Link to home
Start Free TrialLog in
Avatar of McLovin
McLovin

asked on

Need help with powershell to set sendon behalf on mailboxes from a csv

I am needing help with setting send of behalf on a group of users the csv I have has in one column the managers which each on needs send on the behalf of the other column which is named analysts.
here is what I have so far... but not for sure how to format the add statement as to not to remove any existing users that have send aon behalf rights  
$UserList = import-CSV c:\rm\sendas.csv
ForEach ($User in $UserList)
{
Set-Mailbox $user.analyst-GrantSendOnBehalfTo @{add=$user.manager}  
}
Avatar of Jason Crawford
Jason Crawford
Flag of United States of America image

foreach ($user in (Import-Csv c:\rm\sendas.csv)) {
  Set-Mailbox $user.analyst -GrantSendOnBehalfTo @{add=$($user.manager)} -WhatIf
}

Open in new window

Avatar of McLovin
McLovin

ASKER

this is what I get when I run
Cannot process argument transformation on parameter 'GrantSendOnBehalfTo'. Cannot convert value
"System.Collections.Hashtable" to type
"Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]". Error:
"MultiValuedProperty collections cannot contain null values.
Parameter name: item"
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox
    + PSComputerName        :
How did you populate the Manager column of the .csv file?
Avatar of McLovin

ASKER

attached csv
Avatar of McLovin

ASKER

OK I figured out one issue but now when I run it gets to the empty columns under managers and errors out.  any ideas?

cannot process argument transformation on parameter 'GrantSendOnBehalfTo'. Cannot convert value
System.Collections.Hashtable" to type
Microsoft.Exchange.Data.MultiValuedProperty`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]". Error:
Failed to convert  from System.String to Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter. Error:
arameter values of type Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter can't be empty. Specify a value
nd try again.
arameter name: identity"
   + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
ASKER CERTIFIED SOLUTION
Avatar of McLovin
McLovin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of McLovin

ASKER

self closed