Jump to content

Building AutoIt Exchange/Powershell query tool


Recommended Posts

OK I've been searching around on the forums trying to find a good example of how to get AutoIt and powershell talking in a way that will let me build what I want but am having trouble getting exactly what I need.

In order to simplify some stuff I'm trying to build what is a essentially a multi source person lookup/administration tool that draws data from various sources (databases/ldap/AD/Exchange)

Most of the stuff is easy and works fine and with the AD.au3 I can query and even modify a few things there pretty easily. the problem is for most Exchange tasks I need to use powershell commands.

Since I need the exchange plugins to be loaded I don't want to constantly restart powershell and since this is a one-off type lookup tool writing one script that autoit launches also doesn't work I need it to fire off individual commands to PS and get the results back from the same powershell window or app.

somewhere I found one example that kinda did this and used the clip board to mule data between autoit or to write to a file then read that file but it would be nice to have something more robust than that to get the data back and to catch errors.

for example I have some powershell stuff I wrote that I want to merge into this new tool here is one step in part of a function which hides a contact object from the global address list:

#hide from the GAL
$txt_full2cal_output.lines += "Hiding contact from GAL..."
$form1.refresh()
Set-MailContact -Identity $UsName -HiddenFromAddressListsEnabled $true -DomainController $script:dc
if (!$?)
{
$txt_full2cal_output.lines += "ERROR: Hide " + $UsName + " from GAL failed."

}

In the new app I would handle the interface and logic in autoit and presumably just run the "Set-MailContact -Identity $UsName -HiddenFromAddressListsEnabled $true -DomainController" command from autoit with the variables populated from autoit. I would then need just need a success/fail back so I could then either move to the next step or initiate error handleing.

now another operation i need would be getting data back. for example a user's quota :

$mailboxCheck = Get-Mailbox -Identity $userPID -DomainController $script:dc
$quota = $mailboxCheck.IssueWarningQuota.Value.ToKB()

i'm not sure how to do this one one line but the autoit app would pretty much have a "get quota" button that would query a users quota and return it to the interface. in this case I will need to do a check first to make sure the object exists and has an exchange account then run the get quota code and somehow return that to autoit.

If some kind souls out there can help me get these two use cases going the rest should be pretty easy

EDIT: in a seperate thought has anyone integrated autoit with C# ? apparantly C# has some nice integration with powershell with a runspacefactory http://andrusdevelopment.blogspot.com/2008/02/running-powershell-in-c.html potentially I could make a C# type service that can middleman powershell for me . anyone tried this ?

Edited by SpinningCone
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...