I wrote a really simple script to enable mailboxes for active AD accounts that were created, (but for whatever reason, the mailbox was not.)
Before: I would log into my exchange server, open Exchange Powershell and run the Enable-mailbox command. Example: Enable-Mailbox -Identity "username" -Database "Database Name"It would return the following:
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
Doe, Jane jdoe servername unlimited
I then wrote the script listed below, as we were getting more requests to create mailboxes for user accounts and I wanted to avoid having to log into the server each time to enable mailboxes.
After: The script I wrote is simple, but it is not returning the information above, but instead returning A LOT more details than needed.
RunspaceId Database UseDatabaseRetentionDefaults RetainDeletedItemsUntilBackup DeliverToMailboxAndForward LitigationHoldEnabled SingleItemRecoveryEnabled RetentionHoldEnabled EndDateForRetentionHold StartDateForRetentionHold RetentionComment RetentionUrl LitigationHoldDate
When I run the script in Windows Powershell ISE, it displays the info correctly, but if I right click on the script and select "Run with Powershell", it displays the information that I do not want.
Is there something I can add to the script or modify to show the results as:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://servername/PowerShell/ -Authentication Kerberos
Write-Host "============ Create mailbox for user ============"
$UserName = Read-Host "Enter username "
$Database = Read-Host "Enter database "
Enable-Mailbox -Identity "$UserName" -Database "$Database"
Write-Host "============ Mailbox created ============"
Read-Host -Prompt "Press Enter to exit"
Thank you and any help is very much appreciated!!!
You can simply pipe Enable-Mailbox to Format-Table or Select-Object and choose only the properties you wish to see. This is most likely due to formatting data not being available, or possibly related to the deserialization of objects when using implicit remoting. All of those properties are properties of a mailbox object, but typically you don't see all of those properties because a default property set is defined in the type definition for a mailbox object. Just like the difference you see in these examples:
Get-Process | Select-Object *