0 votes

I'm attempting to build a custom PS command that will return the number of mailboxes per database in our Exchange 2010 environment. This is the script I'm using which works through Powershell

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
(Get-MailboxDatabase) | ForEach-Object {Write-Host $_.Name (Get-Mailbox -Database $_.Name).Count}

How can I make this work through Adaxes Custom Command?

by (350 points)

1 Answer

0 votes
by (215k points)

Michael,

The Write-Host function is not supported in Adaxes actions, however if you want to output some information, you can add a record to the Execution Log of the operation using the $Context.LogMessage method. For more information, see ExecuteScriptContext.

Here's a modified version of your script that can be used with Custom Commands, Business Rules and Scheduled Tasks using the Run a program or PowerShell script action:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
(Get-MailboxDatabase) | ForEach-Object {
    $message = $_.Name + ": " + (Get-Mailbox -Database $_.Name).Count
    $Context.LogMessage($message, "Information")
}
0

Is there anyway the output could be generated to the web interface, such as a results page or something similar?

0

Michael,

The Execution Log of the operation is displayed in the Web Interface once the operation is complete.

0

I tested and the it brought me back to Home screen with "Operation successull" displayed at the top.

What object type would my Custom Command need to be run against?

0

You should also be able to see the Execution Log below. It should look like this:

Can you post a screenshot of your Custom Command?

What object type would my Custom Command need to be run against?

It doesn't matter as the above script does not read any properties of the target object on which the Custom Command is executed.

0

I'm using the script you provided in this post as Powershell command and attempting to run in web interface

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
(Get-MailboxDatabase) | ForEach-Object {
$message = $_.Name + ": " + (Get-Mailbox -Database $_.Name).Count
$Context.LogMessage($message, "Information")
}

0

My appologies! It is working. Ijust needed to expand the Details next to "Operation successull". Thank you very much for your assistance!

Related questions

0 votes
1 answer

I'm working on user deprovision and need to re-assign a user's home directory to the manager's home directory after disabling. I found a PowerShell script on this site to ... retrieve the same for the Manager? I'm a PowerShell novice, so excuse my ignorance.

asked Feb 26, 2021 by mkvidera (60 points)
0 votes
1 answer

This article states that managment of shared mailboxes is added. https://www.adaxes.com/info_whats-new_2019.1.htm#exchange Where is the details on implementation? It seems like ... mismatch on what you say and what the software does and lack of instructions.

asked Aug 18, 2020 by ComputerHabit (790 points)
0 votes
1 answer

I need to insert this condition: # The condition is met if $Context.ConditionIsMet is set to $True. # $Context.ConditionIsMet = $False $day = Get-Date -UFormat %V $Context. ... I need to get week number of month in gregorian calendar. Thanks in advance, Simone

asked Jan 17 by Simone.Vailati (230 points)
0 votes
0 answers

Good Afternoon, I'm looking for some clarification on what security settings I would need to apply to the Self-Service Users to allow them to update both their own ... accounts they have full access to. Please let me know if this requires more clarification.

asked Jul 22, 2021 by jtop (680 points)
0 votes
1 answer

We would like to auto enroll our entire company into Adaxes for self service but do not want to use the question/answer format but instead their phone numbers (provided by HR department). Is this possible? Best, Evangelos

asked Oct 1, 2021 by evangelos (60 points)
2,640 questions
2,375 answers
6,305 comments
986,008 users