CaffeinatedAdmin Posted November 13, 2019 Posted November 13, 2019 Hello, I've run into several topics about this but none of them seemed to have done it for me. Long story short, I am creating a GUI that will run my powershell scripts that I use in my every day work. The idea is to have a listbox with selections: Once selected, when the button is clicked, it will run a powershell script that checks the basic AD information on the computer object and return the output to an input box. This is my first time using the listbox so I am not sure what I'm doing wrong. This is the listbox section: ; ============ Scripts=========== Local $ListItem = GUICtrlRead($fList) Select Case $ListItem = "AD: Computer Object" $ADco = Run('powershell.exe -executionpolicy bypass -Command (get-adcomputer -Identity & ' $clctHostname & ' -Properties *)', '' , @SW_HIDE , 0x2) Local $ADcoOutput = StdoutRead($ADco) GUICtrlSetData ($fOutput,$ADcoOutput) Case $ListItem = "item2" MsgBox(0, "", "Text for Item 2") EndSelect ; ============ Scripts End =========== It's probably something silly, but I can't wrap my head around it. A fresh pair of eyes needed. Thanks in advance!
seadoggie01 Posted November 14, 2019 Posted November 14, 2019 Hi and Welcome! What does this output when you run it? Is this your whole script? Can you post the rest of it, or a small-ish section that has the same issues? All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
MattHiggs Posted November 14, 2019 Posted November 14, 2019 @CaffeinatedAdminThe reason the powershell script is failing is because the syntax is wrong. It should look like this: ; ============ Scripts=========== Local $ListItem = GUICtrlRead($fList) Select Case $ListItem = "AD: Computer Object" $ADco = Run('powershell.exe -executionpolicy bypass -Command "get-adcomputer -Identity ' & $clctHostname & ' -Properties *"', '' , @SW_HIDE , 0x2) Local $ADcoOutput = StdoutRead($ADco) GUICtrlSetData ($fOutput,$ADcoOutput) Case $ListItem = "item2" MsgBox(0, "", "Text for Item 2") EndSelect ; ============ Scripts End =========== Try writing the command like this.
Moderators JLogan3o13 Posted November 14, 2019 Moderators Posted November 14, 2019 And, just to play devil's advocate here, why go through all of the trouble of getting AutoIt to call PowerShell to do all of this, when AutoIt can do it natively? You should only mix languages if there is a compelling reason to do so. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MattHiggs Posted November 14, 2019 Posted November 14, 2019 Just now, JLogan3o13 said: And, just to play devil's advocate here, why go through all of the trouble of getting AutoIt to call PowerShell to do all of this, when AutoIt can do it natively? You should only mix languages if there is a compelling reason to do so. @JLogan3o13Because not everyone is as beast a coder as you are. 😁
Moderators JLogan3o13 Posted November 14, 2019 Moderators Posted November 14, 2019 Never claimed that, @MattHiggs. But mixing languages, when it is not an absolute requirement, leads to frustration - a' la what our OP is going through. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
MattHiggs Posted November 14, 2019 Posted November 14, 2019 1 minute ago, JLogan3o13 said: Never claimed that, @MattHiggs. But mixing languages, when it is not an absolute requirement, leads to frustration - a' la what our OP is going through. @JLogan3o13Just screwing with you. Don't be modest. You are absolutely a beast coder
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now