Quantcast
Channel: Exchange Server 2013 - Setup, Deployment, Updates, and Migration forum
Viewing all articles
Browse latest Browse all 7129

Powershell script to set custom attribute on mailuser returns WARNING: The command completed successfully but no settings of have been modified.

$
0
0

I am trying to write a script to enable a mailuser (I do know the difference between mailuser and mailbox) and set a custom attribute for that mailuser.  Every time I run the script I get "WARNING: The command completed successfully but no settings of <User DN> have been modified."  Both commands being invoked work when typed manually into the exchange management shell on the exchange server itself.  I am using the same administrator account in the script, and when I login to the exchange server to manually run the commands, so it shouldn't be a permission issue.  Here is my script so far.  If anyone can shed some light on what I'm doing wrong, I'd appreciate it.



$excel = new-object -com excel.application

$wb = $excel.workbooks.open("c:\temp\testmail8.xlsx")

$ws = $wb.Worksheets.Item(1)

$row = 1

$s = New-PSSession -ConfigurationName microsoft.exchange -ConnectionUri http://<Exchange Server Name>/powershell -Credential administrator@domain.com

Do {

$Email = $ws.Cells.Item($row, 1).Value()
$Cat = $ws.Cells.Item($row, 2).Value()

invoke-command -Session $s -ScriptBlock {Enable-MailUser -ExternalEmailAddress $($args[0][0] + "@domain.com") -Identity $($args[0][0])} -ArgumentList (,$Email, $Cat)

invoke-command -Session $s -ScriptBlock {Set-MailUser -Identity $($args[0][0]) -CustomAttribute1 $($args[0][1])} -ArgumentList (,$Email, $Cat)

$row++

     } While ($ws.Cells.Item($row,1).Value() -ne $null)

$excel.quit    

Exit-PSSession



Viewing all articles
Browse latest Browse all 7129

Trending Articles