caramen Posted December 14, 2016 Posted December 14, 2016 (edited) Hello guys. I whould like to do that with autoit : ShellExecute ("c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe") Sleep (500) Send ("Get-ADUser sdr**x -Properties OfficePhone | Select -Expand OfficePhone") Send("{ENTER}") Is there way to do that with autoit without exit of my script I whould like to get the return value of the executed command in a autoit variable something like : $A = ShellExecute ("c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe") Sleep (500) Send ("Get-ADUser sdr**x -Properties OfficePhone | Select -Expand OfficePhone") Send("{ENTER}") I am introducing myself in powershell things so.. i ve not got much skills in it. (So any idea is welcome ) Edited January 2, 2017 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Moderators JLogan3o13 Posted December 14, 2016 Moderators Posted December 14, 2016 Just a question, since you can get all of that information and return it through AutoIt, why the need to mix languages? Either stick solely with PS and output to a grid-view, or use the A.D. UDF in AutoIt and output as you see fit. "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!
caramen Posted December 15, 2016 Author Posted December 15, 2016 Because it s my first script that gonna tuch the active directory directly. i am not familiar with that so i had no idea. Ty i am gonna look today. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
iamtheky Posted December 15, 2016 Posted December 15, 2016 I cant let you run powershell commands like that, try something like this: #include<array.au3> $iPid = run('powershell Get-ADUser sdr**x -Properties OfficePhone | Select -Expand OfficePhone' , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd ;~ msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) _ArrayDisplay($aOutput) Reveal hidden contents ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
caramen Posted December 15, 2016 Author Posted December 15, 2016 The two solutions provided are perfect for me. Work like a charm. Thx to both of you. :). My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
caramen Posted December 26, 2016 Author Posted December 26, 2016 Hello guys I was coding my script using the IamTheKy technique because it s the best technique for what i need. But i have a problem If i change the powershell command i dont get anymore the wanthed return value i show you the code* $Username = InputBox("Atol", "Entrer un LOGIN svp", "LOGIN", "") ShellExecute ("c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe") Sleep (500) Send ("Get-ADUser " &$Username &" | select -Expand Name") Send("{ENTER}") $iPid = run("Get-ADUser " &$Username &" | select -Expand Name" , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) ;~ _ArrayDisplay($aOutput) ;~ msgbox(0, '' , $sOutput) WinClose ("Windows PowerShell") * This one work perfectly $Username = InputBox("Atol", "Entrer un LOGIN svp", "LOGIN", "") ShellExecute ("c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe") Sleep (500) Send ("Get-ADUser "&$Username&" -Properties OfficePhone | Select -Expand OfficePhone") Send("{ENTER}") $iPid = run('powershell Get-ADUser '&$Username&' -Properties OfficePhone | Select -Expand OfficePhone' , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) ;~ _ArrayDisplay($aOutput) ;~ msgbox(0, '' , $sOutput) WinClose ("Windows PowerShell") If i change to $Username = InputBox("Atol", "Entrer un LOGIN svp", "LOGIN", "") ShellExecute ("c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe") Sleep (500) Send ("Get-ADUser " &$Username &" | select -Expand Name") Send("{ENTER}") $iPid = run("Get-ADUser " &$Username &" | select -Expand Name" , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) ;~ _ArrayDisplay($aOutput) ;~ msgbox(0, '' , $sOutput) WinClose ("Windows PowerShell") The returned valu is now empty Can i got explanation so i dont come here to ask why at each commands i whould like to understand and not only copy past what i have as an help. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
careca Posted December 26, 2016 Posted December 26, 2016 With as many posts as you have, it shouldn't be hard for you to see each cmd you don't know in the help file. I don't know powershell, but It seems to me that you have a extra '|' in Send ("Get-ADUser " &$Username &" | select -Expand Name") But i may be wrong, it just looks out of place Reveal hidden contents Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
caramen Posted December 26, 2016 Author Posted December 26, 2016 (edited) You are rigth lol. But for myself it s false^^. I always look the helpfile before post anything here and also Search for similar post before ask. Second thing i post my code with a $VARIABLE But for testing i use the command without a variable Exemple for me : * Send ("Get-ADUser jpersonal | select -Expand Name") and it's working in powershell i have the return value : Jordane Personal I just want to store it in a autoit variable as $Username Everything is fine wwith the first code but it s not working anymore if i change the powershelle command EDIT : Btw the extra '|' in my command is for filtering information in AD without it the command does not work at all. It s the same as doing ipconfig /all without the / Edited December 26, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
careca Posted December 26, 2016 Posted December 26, 2016 Im confused $Username = InputBox("Atol", "Entrer un LOGIN svp", "LOGIN", "") ShellExecute ("c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe") ;Start powershell Sleep (500) Send ("Get-ADUser " &$Username &" | select -Expand Name") ;Write your command with the profile from the inputbox Send("{ENTER}") $iPid = run("Get-ADUser " &$Username &" | select -Expand Name" , @WindowsDir , @SW_HIDE , 0x2) ;Run... a command without any exe. :| $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) ;Read console output If @error Then ExitLoop EndIf WEnd msgbox(0, '' , $sOutput) ;show output $aOutput = stringsplit($sOutput , @LF , 2) ;split result in all @LF but don't use the splitted result for anything ;~ _ArrayDisplay($aOutput) ;~ msgbox(0, '' , $sOutput) WinClose ("Windows PowerShell") Reveal hidden contents Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
caramen Posted December 26, 2016 Author Posted December 26, 2016 (edited) hahahah you just gifted me the solution i am explaining : I had the purpose of getting multiple informations with powershell command for automatig a loooooot of thing in a software developed with autoit. I dont want to split language in the same script so i find the solution i am using perfect for me. So you are confused about the code becose the guy just showed to me how to use multiple way the command he provided to me. that was so nice from him. Now with your comment : $iPid = run("Get-ADUser " &$Username &" | select -Expand Name" , @WindowsDir , @SW_HIDE , 0x2) ;Run... a command without any exe. :| you made me understand i was sending a command in "nothing" haha i iam stupid. But like that : $iPid = run("powershell Get-ADUser jpersonal | select -Expand Name" , @WindowsDir , @SW_HIDE , 0x2) It s working.... damn i am so stupid. Thank bro you saved my time today have a good day. Edited December 26, 2016 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
careca Posted December 26, 2016 Posted December 26, 2016 Ok, i ended up condensing it a bit, but seeing as you solved it, it's all good XD #include <Array.au3> $Username = InputBox("Atol", "Entrer un LOGIN svp", "LOGIN", "") $iPid = run("powershell Get-ADUser " &$Username &" | select -Expand Name" , @WindowsDir , @SW_HIDE , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop Else $aOutput = stringsplit($sOutput , @LF , 2) _ArrayDisplay($aOutput) ProcessClose($iPid) EndIf WEnd Reveal hidden contents Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
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