Custom automation script based on empty attribute

Custom automation script based on empty attribute

Hello All,

I have been fighting for days to figure out how to get a custom automation PowerShell script to run for users with an empty attribute. The empty attribute report works great and finds the users needed, but then I am not able to get my custom automation script to run successfully. I really think the issue is that I am trying to append the %username% attribute to, so ADManager is literally trying to find a user called, which isn't a valid username. 

I am hoping that someone has done something similar and can help figure out where I am going wrong. 

The operation couldn't be performed because object couldn't be

Automation Script: Powershell.exe -File EnableRemoteMailbox.ps1  %username%

PowerShell Script: EnableRemoteMailbox.ps1

# Start logging
Start-transcript C:\Temp\EnableRemoteMailbox_Log.txt

# Load the snap-in for the Exchange commands
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;

# Enable Remote Mailbox routing needed for O365
Enable-RemoteMailbox -Identity -RemoteRoutingAddress

# Stop logging