0 votes

I wrote a small script to get Mail Queue stats on all my Exch 2010 Hub Tansport servers. It works in EMS but when I configure as a Custom Command it returns an error; "Cannot invoke this function because the current host does not implement it. " Can you assist in getting this fixed?

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$HubServer = Get-TransportServer |sort-object -property Name
foreach ($server in $HubServer) {
get-Queue -server $server -EA inquire -SortOrder -messagecount
write-output ""
}

by (350 points)

1 Answer

0 votes
by (216k points)

Michael,

The Get-Queue cmdlet prompts for user confirmation. Unfortunately, this is not supported by Adaxes. You will not be able to use the Get-Queue cmdlet in Custom Commands.

0

Do you have any recommendation for how I might achieve a similar outcome?

0

In the context of the script I posted the variable $HubServer is passed through so there is no prompt. It is not possible to replicate this or something similar with a Custom Command?

0

Hello Michael,

Sorry, we got the prompt in our environment because of the issues with our testing Exchange Servers that prevented the cmdlet from getting the necessary data. If your Exchange Servers are OK, there should be no prompt. Try the following script for your task:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$HubServer = Get-TransportServer | sort-object -property Name
foreach ($server in $HubServer) 
{ 
   $queueInfos = Get-Queue -server $server -EA inquire -SortOrder -messagecount 
   foreach ($queueInfo in  $queueInfos)
   {
       $message = "Identity: " + $queueInfo.Identity + "; DeliveryType: " + $queueInfo.DeliveryType 
       $Context.LogMessage($message, "Information")
   }
}

For more information on the ExtensibleQueueInfo class object, a collection of which the Get-Queue cmdlet returns, see the description of the ExtensibleQueueInfo Class on MSDN.

0

This returns the following error"

Cannot invoke this function because the current host does not implement it. Cannot find an overload for "LogMessage" and the argument count: "0". Cannot find an overload for "LogMessage" and the argument count: "0". Cannot find an overload for "LogMessage" and the argument count: "0". Cannot find an overload for "LogMessage" and the argument count: "0". Cannot find an overload for "LogMessage" and the argument count: "0".

0

Michael,

Sorry, my fault. Didn't copy the entire thing. I've updated the script in the post above.

0

Still returning this message

Run PowerShell script 'Check Mail Delivery Queue Status' for the user

Identity: ; DeliveryType:
Identity: S1CAS1\Submission; DeliveryType: Undefined
Identity: S1CAS2\Submission; DeliveryType: Undefined
Identity: S2CAS1\Submission; DeliveryType: Undefined
Identity: S2CAS2\Submission; DeliveryType: Undefined
Cannot invoke this function because the current host does not implement it.

HEre is a copy of the script im putting in to the Poweshell Command for my Custom Command, which i copied from your post

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$HubServer = Get-TransportServer | sort-object -property Name
foreach ($server in $HubServer)
{
$queueInfos = Get-Queue -server $server -EA inquire -SortOrder -messagecount
foreach ($queueInfo in $queueInfos)
{
$message = "Identity: " + $queueInfo.Identity + "; DeliveryType: " + $queueInfo.DeliveryType
$Context.LogMessage($message, "Information")
}
}

0

Hello Michael,

The 'Cannot invoke this function because the current host does not implement it' error message means that the Get-Queue cmdlet nevertheless tries to write some warnings/prompts to the PowerShell console. Try to run your initial script from the PowerShell console and take look if it writes any warnings messages to the console or prompts for user imput.

Unfortunately, currently Adaxes does not support functions similar to Write-Host and prompting for user input, so, probably, it will be impossible to use the Get-Queue cmdlet with the Run a Program or PowerShell script action if you do not eliminate all warning messages and prompts.

0

I do not receive any warning/error messages or prompts when running my original script from EMS located on the Adaxes Server.
This is exactly what the output from the original scripts looks like.

[PS] C:\scripts>.\Get-MailQueue.ps1

Identity DeliveryType Status MessageCount NextHopDomain
-------- ---------------- -------- ---- -------------
S1CAS1\Submission Undefined Ready 0 Submission
S1CAS2\Submission Undefined Ready 0 Submission
S2CAS1\Submission Undefined Ready 0 Submission
S2CAS2\Submission Undefined Ready 0 Submission

0

This is the message received when attempting to run the script you provided directly from the Adaxes Powershell

PS C:\scripts> .\Get-MailQueueAD.ps1

Confirm
The queue viewer client can't process the results received from the server. The
data may be corrupted.
[Y] Yes [A] Yes to All [H] Halt Command Suspend [?] Help
(default is "Y"):

0

Hello Michael,

Try this version of the script, it works successfully in our testing environment:

$exchangeServer = "exchangeserver.domain.com" # TODO: Modify me

$session = new-pssession -connectionURI "http://$exchangeServer/powershell?serializationLevel=Full" -ConfigurationName Microsoft.Exchange
Import-PSSession -session $session

$HubServer = Get-TransportServer | sort-object -property Name
foreach ($server in $HubServer)
{
    $queueInfos = Get-Queue -server $server -EA inquire -SortOrder -messagecount
    foreach ($queueInfo in $queueInfos)
    {
       $message = "Identity: " + $queueInfo.Identity + "; DeliveryType: " + $queueInfo.DeliveryType
       $Context.LogMessage($message, "Information")
    }
}
Remove-PSSession -Session $session
0

Now recieving this error:

Run PowerShell script 'Check Mail Delivery Queue Status' for the user

Identity: ; DeliveryType:
Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: The network path was not found. Possible causes are: -The user name or password specified are invalid. -Kerberos is used when no authentication method and no user name are specified. -Kerberos accepts domain user names, but not local user names. -The Service Principal Name (SPN) for the remote computer name and port does not exist. -The client and remote computers are in different domains and there is no trust between the two domains. After checking for the above issues, try the following: -Check the Event Viewer for events related to authentication. -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport. Note that computers in the TrustedHosts list might not be authenticated. -For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic. <output truncated>

0

Michael,

This error means that Adaxes cannot establish a remote PowerShell session with the computer where your Exchange Server is installed. The possible errors are specified in the error message that you posted.

The most probable reason is that you specified a DNS alias for this computer in $exchangeServer. Try specifying the Fully Qualified Domain Name (FQDN) or the Flat Name of the computer where your Exchange Server is installed.

0

Inserting the FQDN seems to have worked. Thank you for your assistance!

Related questions

0 votes
1 answer

I found these codes: http://www.adaxes.com/sdk/SampleScripts ... lFlow.html I created custom command(action is "run powershell script") with the following codes and added ... host does not implement it. Can anyone help me look into this ? Really appreciate!

asked Jul 7, 2015 by tony (50 points)
0 votes
1 answer

Hey guys, First time Adaxes user, and let me say, we absolutely love the product! Quick question though.... As a part of our account de-provisioning process, we ... exact same code in a regular powershell window with no problem. Any thoughts? Any alternatives?

asked Sep 6, 2012 by sco.robinso (20 points)
0 votes
1 answer

Hi there ! I wan to implement a custom command that will remove a user from all disitribution groups : Import-Module Adaxes Get-AdmGroup -Filter { mail -like "*" } | Where { ( ... host does not implement it. I can't see what i'm doing wrong... Thanks Stephen

asked Sep 27, 2011 by sroux (800 points)
0 votes
1 answer

hello, I have somethings like this : #Start the process on the remote machine $Context.LogMessage("Get statistivcs on %cn%", "Information") $Server = New-PSSession -ComputerName ... main script so I can see $a in $Context.LogMessage. is that possible? Thanks.

asked Feb 13, 2018 by tentaal (1.1k points)
0 votes
0 answers

Seeing an error when trying to Register Microsoft 365 Tenant, Application Account Cannot update the manifest file 'C:\Users.....\Appdata\local\Temp.....ppv\tmpEXO.....psd1 ... and try again. 'The member 'FormatsToProcess' in the module manifest is not valid:

asked Jul 11, 2023 by KevC (60 points)
3,326 questions
3,025 answers
7,724 comments
544,678 users