Script Center > Scripting Forums > The Official Scripting Guys Forum! > Can Powershell send the completion of an enabledmailbox command to an active HTA window that launched this .ps1 file
Ask a questionAsk a question
 

Proposed AnswerCan Powershell send the completion of an enabledmailbox command to an active HTA window that launched this .ps1 file

  • Wednesday, November 04, 2009 10:14 AMDutch Liam Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I’m trying to write a HTA script for creating user in AD and the script language is vbscript.

    In the code I create a ps1 file which creates a mailbox in exchange 2007.

    So far so good, but is there a way for powershell to connect to my active HTA window and write the text that powershell printed on screen into the data area, saying mailbox enabled or couldn’t create the mailbox?

All Replies

  • Wednesday, November 04, 2009 6:54 PMAbqBillModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    One way to do this is to redirect the output of the PowerShell command or script to a temporary file and read the temporary file's contents into your HTA's form.

    Bill
  • Wednesday, November 04, 2009 7:02 PMTom Lavedas Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, but why use the external PS1 script?  Though I don't work with Exchange and Outlook at all, since our company uses Domino and Lotus Notes, I would assume the PS1 script is making use of scriptable objects.  If that's true, why not access these same objects directly from the HTA in VBS?  Then there would be no inter application communications problems. Or am I missing something?

    Tom Lavedas
  • Wednesday, November 04, 2009 7:30 PMAbqBillModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I think the idea would be not to reinvent the wheel, since Exchange 2007 uses PowerShell to perform management tasks.

    Bill
  • Wednesday, November 04, 2009 7:46 PMTom Lavedas Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Fair enough.  I said I might be missing something, but now my question is why not write the whole application in PS1?  Why the mixed mode - which seems to me to cause more problems than it solves.

    Just my $0.02.

    Tom Lavedas
  • Wednesday, November 04, 2009 7:49 PMAbqBillModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You're right, that's probably the best idea in the long run.

    Bill
  • Monday, November 09, 2009 4:31 PMchswin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    The best way to do this; Assuming the HTA is a custom adminastrative GUI would be to use the COM based powershell wrapper called ActivePOSH (From sapien the makers of PrimalScript) It is completely free, Iuse it alot. This way you can call the powershell script directly from VBScript in your HTA and grab the output directly. You can get it here:  http://www.primaltools.com/downloads/communitytools/
    • Proposed As Answer bychswin Monday, November 09, 2009 4:32 PM
    •