I'm trying to export a CSV file that lists all users with OWA enabled, showing their usernames and mailbox sizes. I managed to run the Get-CASMailbox command, but I'm having trouble retrieving the mailbox size. I'm encountering an error that says: 'Cannot bind argument to parameter 'Identity' because it is null.' I would appreciate any help on what I might be doing wrong!
3 Answers
Don't forget to debug your script! It’s always good practice to step through your code line by line. Start by gathering all mailboxes with `Get-CASMailbox` and check if anything comes back before you try further operations. Validate each mailbox item as you go, then pull the mailbox statistics into your report object.
The issue here is that `Get-CASMailbox` doesn’t have the `UserPrincipalName` property. Instead, you'll want to use `PrimarySMTPAddress` or `SamAccountName` to access the usernames. This change should resolve your null error when trying to assign the user variable.
First, try running just `Get-CASMailbox -ResultSize Unlimited | Where-Object { $_.OWAEnabled -eq $true }` by itself. This will help you see if it’s returning any results or just getting null values. That could point to what’s going wrong in your script.
Absolutely! Taking that step-by-step approach can save you a lot of time and help you pinpoint where things might be going wrong. Plus, it'll help you understand your script better!