Sign in to follow this  
Followers 0
ronin2040

Interacting with powershell

8 posts in this topic

#1 ·  Posted (edited)

Ive looked through a number of topics trying to get this to work to no avail. Basically, I have some powershell scripts that I want to tie to a GUI, and the commands have to be powershell (theyre active-directory commands that have to be issued through a specific snap-in; doing them straight through AD will fail).

I am able to interact with a normal command prompt using stdinwrite and stdoutread, but using the exact same code for powershell simply doesnt work. I wanted to see if anyone has dealt with / solved this issue. Heres an example of the code Im using:

Global $data, $title, $pid
$pid = Run(@ComSpec, @SystemDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD) ;WORKS

;;$pid = Run("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit", @SystemDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD) ; DOES NOT WORK

If ProcessWait($pid, 5) Then
     _StdIn('help /?')
     _StdIn('ping -w 500 -n 1 8.8.8.8')
     sleep(2000)
     _StdOut()
EndIf
Exit



Func _StdIn($input)
     If Not ProcessExists($pid) Then Return
     StdinWrite($pid, $input & @CRLF)
EndFunc


Func _StdOut()
     If Not ProcessExists($pid) Then Return
     $output = StdOutRead($pid, 65500)
     ConsoleWrite($output)
EndFunc
Edited by ronin2040

Share this post


Link to post
Share on other sites



Bump, anyone have any ideas?

Share this post


Link to post
Share on other sites

(theyre active-directory commands that have to be issued through a specific snap-in; doing them straight through AD will fail).

Why do you think the AD commands will fail? There is (almost) nothing you can't do with my AD UDF.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The organization I work for uses Quest Active Roles to track changes. From a technical level, I believe you get "access is denied" when attempting to use regular powershell AD commands, and from an administrative, we would want any script we use to have the history recorded by ActiveRoles.

Using powershell I can add the quest.activeroles.admanagement pssnapin, which gives access to a whole bunch of cmdlets (see here: http://wiki.powergui.org/index.php/QAD_cmdlets_reference).

If there is a way to issue those particular commands natively through autoit, I would love to do so; but as it is I already have a powershell script written to do a number of different functions, and want a GUI over top of it.

Share this post


Link to post
Share on other sites

I see.

Looks like your problem was described - unfortunately there was no solution.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Looks like the "solution" unfortunately is to build the GUI directly with winforms, like here.

http://bytecookie.wordpress.com/2011/07/17/gui-creation-with-powershell-the-basics/

Probably will work better in the long run anyways, just not as familiar with it.

Share this post


Link to post
Share on other sites

Looks like a lot of fun :unsure:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0