none
Cannot invoke this function because the current host does not implement it RRS feed

  • Question

  • Not sure this is the right forum. Our service is a .NET 3.5 WCF service running on Exch 2010 CAS server under Local System account. It launches a helper process, also .NET 3.5 Windows Forms application, using another local administrator credential who has the Export Import and Recipient Management role(s). The New-MailboxImportRequest cmdlet fails with the "Cannot invoke this function because the current host does not implement it" error. Here is the cmdlet executed:

    New-MailboxImportRequest -Mailbox 'edsp.landon.k.carrion' -FilePath '\\cas1\c$\temp\carrionlandonkssgusaforscom\carrion, landon k ssg usa fors.pst' -Name 'edsp' -DomainController 'dc1.alpha.local' -MRSServer 'cas1.alpha.local' -Confirm:$False -Verbose:$True -Debug:$True | Select-Object status

    However if we give this local administrator credential Organization Management role instead of Recipient Management role, it works fine. Anyone has an explanation? We do not want to assign this limited domain user account anything more than local admin + recipient management & import export role. The service is running directly on the CAS server itself. Here is the fun part: If I login using this credential and fire up Exchange Management Shell and execute the above cmdlet, it works fine again. So, launching this helper exe as that user from a WCF service running under local service account, behaves differently merely based on Organization Management versus Recipient Management roles. Any insights will be greatly appreciated.

    TIA.

    Thursday, November 18, 2010 9:27 PM

Answers

  • Hi systinte5,

    From your description, I understanding that you are using some powershell script cmdlet to perform some exchange managment tasks. And the application that uses script is launched by a WCF service application. Now you find it works if you manually launch the application via logon user, but fails when launch it from WCF service programmtically, correct?

    According to the error message you provided, it indicate that the certain "New-MailboxImportRequest" cmdlet cannot be found. And since this exchange server specific management cmdlet should be installed with exchange server related sdk or admin package, and be loaded as an additional script in profile script, I think it is possible that the problem is caused by the exchange admin related script (cmdlets and other powershell components) are not loaded when being executed from WCF service programmtically.

    Not quite familar with the exchange admin package, for general troubleshooting, you can try using processmonitor to watch the file acess behavior between the manual execution and programmtic execution cases to see whether there is some certain difference on the external powershell script resources it loads.

    #Process Monitor
    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Mog Liang Monday, November 29, 2010 10:22 AM
    Monday, November 22, 2010 2:52 AM
    Moderator

All replies

  • Hi systinte5,

    From your description, I understanding that you are using some powershell script cmdlet to perform some exchange managment tasks. And the application that uses script is launched by a WCF service application. Now you find it works if you manually launch the application via logon user, but fails when launch it from WCF service programmtically, correct?

    According to the error message you provided, it indicate that the certain "New-MailboxImportRequest" cmdlet cannot be found. And since this exchange server specific management cmdlet should be installed with exchange server related sdk or admin package, and be loaded as an additional script in profile script, I think it is possible that the problem is caused by the exchange admin related script (cmdlets and other powershell components) are not loaded when being executed from WCF service programmtically.

    Not quite familar with the exchange admin package, for general troubleshooting, you can try using processmonitor to watch the file acess behavior between the manual execution and programmtic execution cases to see whether there is some certain difference on the external powershell script resources it loads.

    #Process Monitor
    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Mog Liang Monday, November 29, 2010 10:22 AM
    Monday, November 22, 2010 2:52 AM
    Moderator
  • I have ssen this error when using Powershell from C# using a runspace, but due to a different source. If I comment out Out-Host or Write-Host methods it solves it. I am just posting here for others who might run into this error too.

    Thanks,


    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Tuesday, July 19, 2011 3:09 AM
  • Thanks Ben, that indeed helped
    Monday, March 26, 2012 8:22 PM
  • Mallu, to get diagnostic information back from a runspace script I use $Error.Add or a custom object and just return it at the bottom of the script to send the information back to the host. For some reason the Write-Host and Out-Host commands just caused issues in the runspace.

    Thanks,


    If this answers your question, please use the "Answer" button to say so | Ben Cline

    Tuesday, March 27, 2012 5:47 AM
  • Thank Ben

    You helped me today :D

    I changed : 

    $NICs = Get-WmiObject "Win32_NetworkAdapterConfiguration" | Where {$_.IPEnabled -eq "TRUE"}
    foreach ($NIC in $NICs)
    {
    Write-Host "Current configure for"$NIC.Description ":" | Format-Custom 
    Write-Host "Current IP address: " $NIC.IpAddress | Format-Table -AutoSize
    Write-Host "Current Subnet mask: " $NIC.IpSubnet | Format-Table -AutoSize
    Write-Host "Default gateway: " $NIC.DefaultIPGateway |Format-Table -AutoSize 
    Write-Host "" 
    Write-Host "DNS Domain: "$NIC.DNSDomain |Format-Table -AutoSize 
    Write-Host "DNS Server: "$NIC.DNSServerSearchOrder |Format-Table -AutoSize
    Write-Host "-------------------------------------------------------" 

    into 


    $NICs = Get-WmiObject "Win32_NetworkAdapterConfiguration" | Where {$_.IPEnabled -eq "TRUE"}
    foreach ($NIC in $NICs)
    {
    "Current configure for $($NIC.Description) :" 
    "Current IP address: $($NIC.IpAddress)" 
    "Current Subnet mask: $($NIC.IpSubnet)" 
    "Default gateway: $($NIC.DefaultIPGateway)"
    "" 
    "DNS Domain: $($NIC.DNSDomain)"
    "DNS Server: $($NIC.DNSServerSearchOrder)"
    "-------------------------------------------------------" 
    }

    Share what you know, it can be useful one day :)

    Wednesday, June 13, 2012 2:42 PM
  • Thats right Ben, Thanks for info...

    When Host is open, it causes issue to runspce.

    I am calling different functions in my Powershell script and one of the functions had Write-host opened te host. Well it was worth the pain to fix it.

    Just remove host [commands] when you are getting into runspace.

    -Rahul Tarambale

    Friday, September 7, 2012 9:44 PM