Jump to content

Interacting with powershell


 Share

Recommended Posts

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
Share on other sites

Looks like a lot of fun :unsure:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 3 weeks later...

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...