Search the Community
Showing results for tags 'powershell'.
-
I am adding some functions to my little swiss knife of this post, and because I find very annoying the fact that windows 11 keep me asking to change/set password of my local users, I want to disable this with a button. I posted below an example, where with the same tecnique I launch 2 functions, the first rename the pc and works well, the second one disable psw expiration for my local user but it's not working. The script has to be launched as non admin user and it will ask/require elevated powershell at runtime. I am going crazy😵 figuring out why the function _Set_PswExp4LocalUser() doesn't work, also with no evident errors. If you try this out of AutoIt, on a non admin powershell prompt: PS C:\Users\utente> start-process -verb runas 'powershell.exe' -argumentlist @('-executionpolicy unrestricted',' -command Set-LocalUser -Name utente -PasswordNeverExpires $true') PS C:\Users\utente> LUSRMGR.MSC PS C:\Users\utente> IT's working ! And with LUSRMGR.MSC you can check the user "utente" has now NO expiration... But it's not working from the code... Someone has ideas?😅 _RenamePC("YourPreferredPcName") _Set_PswExp4LocalUsers() Func _Set_PswExp4LocalUsers() ;V.2.83 ;many many tests.... ; Local $StartProcess = "start-process -verb runas 'powershell.exe' " & _ ; "-argumentlist @('-executionpolicy unrestricted',' -command Get-LocalUser | Set-LocalUser -PasswordNeverExpires " & $Enable & "')" ; -Confirm:$false -PassThru')" ;Local $StartProcess = "start-process -verb runas 'powershell.exe' " & _ ;"-argumentlist @('-executionpolicy unrestricted',' -File " & $Fexp & "')" ; -Confirm:$false -PassThru')" ;Gollog($StartProcess) ; ShellExecuteWait("powershell.exe", $StartProcess, "", "", @SW_SHOW) ;Gollog("start-process -verb runas 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' " & _ ; "-argumentlist @('-executionpolicy unrestricted',' -command Set-LocalUser -Name '" & @UserName & "' -PasswordNeverExpires $true')") ;ShellExecuteWait("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe", "start-process -verb runas 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' " & _ ;"-argumentlist @('-executionpolicy unrestricted',' -command Get-LocalUser | Set-LocalUser -PasswordNeverExpires " & $Fexp & "')", '', '', @SW_SHOW) ;ShellExecuteWait("powershell.exe", "start-process -verb runas 'powershell.exe' " & _ ; "-argumentlist @('-executionpolicy unrestricted',' -command Set-LocalUser -Name " & @UserName & " -PasswordNeverExpires $true')", '', '', @SW_SHOW) ;last test: ShellExecuteWait("powershell.exe", "start-process -verb runas 'powershell.exe' " & _ "-argumentlist '-executionpolicy unrestricted -command Set-LocalUser -Name " & @UserName & " -PasswordNeverExpires $true'", "", "", @SW_SHOW) EndFunc ;==>_Set_PswExp4LocalUsers ;EXAMPLE Func _RenamePC($Name) ShellExecuteWait("C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe", "start-process -verb runas 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' " & _ "-argumentlist '$compcname = get-wmiobject win32_computersystem; foreach($comp in $compcname){$oreturn = " & _ "$comp.rename(''" & $Name & "'')}" & _ "'", "", "", @SW_SHOW) EndFunc ;==>_RenamePC
- 2 replies
-
- powershell
- password
-
(and 1 more)
Tagged with:
-
Hello, First of all i'm new and not that good at coding in general, i'm trying to create a simple gui that will achieve a simple goal : * one input (username) * one button (start a powershell with the inputT used) So far I have this going : #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ;Creating GUI GUICreate("search last logon",150,110) GUICtrlCreateLabel("Entrer un Snumber",30,20,200,30) $inputSnumber = GUICtrlCreateInput("",25,35,100,20) $config = GUICtrlCreateButton("Lancer recherche", 25, 60, 100, 20) $snumber = GUICtrlRead($inputSnumber) $sPSCmd = "Get-ADUser -Identity" & $snumber & "-Properties 'LastLogon'| Select-Object Name, @{N='LastLogon'; E {[DateTime]::FromFileTime($_.LastLogon)}}" ;affichage de la fenêtre GUISetState(@SW_SHOW) While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop Case $config RunWait(@comspec & ' /c powershell.exe -nologo -executionpolicy bypass -WindowStyle hidden -noprofile -command "&' & $sPSCmd & '"') ;trying to find why this does not work ;( MsgBox($MB_SYSTEMMODAL,"", GUICtrlRead($inputSnumber)) MsgBox($MB_SYSTEMMODAL,"",$sPSCmd) EndSwitch WEnd I tried this thingy : $sPSCmd = "Get-ADUser -Identity" & $snumber & "-Properties 'LastLogon'| Select-Object Name, @{N='LastLogon'; E {[DateTime]::FromFileTime($_.LastLogon)}}" with & $snumber & or directly GUICtrlRead($inputSnumber) but, when outputting the command ($sPSCmd) the variable does not shows up. Would someone be kind enough to give this a try and guide me ? Thanks again from a baguette technician
- 10 replies
-
- gui
- powershell
-
(and 1 more)
Tagged with:
-
This is a quick start guide to using the AutoIt PowerShell Cmdlets. The best bits of AutoIt directly from PowerShell The files you need are as follows (get them from the zip file or the Program Files folder after installation): AutoItX.psd1AutoItX3.PowerShell.dllAutoItX3.Assembly.dllAutoItX3.dllAutoItX3_x64.dllTo use the Cmdlets open a PowerShell cmd prompt and enter: Import-Module .\AutoItX.psd1 Now you can get a list of available AutoIt Cmdlets by doing Get-Command *AU3*: PS> Get-Command *AU3* Name Category Module ---- -------- ------ Invoke-AU3MouseWheel Cmdlet AutoItX Move-AU3Mouse Cmdlet AutoItX Invoke-AU3MouseClickDrag Cmdlet AutoItX Get-AU3MouseCursor Cmdlet AutoItX Invoke-AU3MouseUp Cmdlet AutoItX Assert-AU3WinActive Cmdlet AutoItX Assert-AU3WinExists Cmdlet AutoItX Assert-AU3IsAdmin Cmdlet AutoItX Invoke-AU3Shutdown Cmdlet AutoItX Send-AU3ControlKey Cmdlet AutoItX Invoke-AU3MouseDown Cmdlet AutoItX Invoke-AU3MouseClick Cmdlet AutoItX Invoke-AU3ControlTreeView Cmdlet AutoItX Invoke-AU3ControlListView Cmdlet AutoItX Invoke-AU3ControlCommand Cmdlet AutoItX Invoke-AU3ControlClick Cmdlet AutoItX Move-AU3Control Cmdlet AutoItX Set-AU3ControlText Cmdlet AutoItX Show-AU3Control Cmdlet AutoItX Hide-AU3Control Cmdlet AutoItX Get-AU3ControlText Cmdlet AutoItX Get-AU3ControlFocus Cmdlet AutoItX Set-AU3ControlFocus Cmdlet AutoItX Disable-AU3Control Cmdlet AutoItX Enable-AU3Control Cmdlet AutoItX Get-AU3StatusbarText Cmdlet AutoItX Invoke-AU3RunAsWait Cmdlet AutoItX Invoke-AU3RunAs Cmdlet AutoItX Invoke-AU3RunWait Cmdlet AutoItX Invoke-AU3Run Cmdlet AutoItX Set-AU3Clip Cmdlet AutoItX Get-AU3Clip Cmdlet AutoItX Set-AU3WinTrans Cmdlet AutoItX Set-AU3WinTitle Cmdlet AutoItX Set-AU3WinState Cmdlet AutoItX Set-AU3WinOnTop Cmdlet AutoItX Move-AU3Win Cmdlet AutoItX Show-AU3WinMinimizeAllUndo Cmdlet AutoItX Show-AU3WinMinimizeAll Cmdlet AutoItX Get-AU3WinState Cmdlet AutoItX Get-AU3WinProcess Cmdlet AutoItX Get-AU3WinClassList Cmdlet AutoItX Get-AU3WinCaretPos Cmdlet AutoItX Get-AU3WinClientSize Cmdlet AutoItX Get-AU3ControlPos Cmdlet AutoItX Get-AU3ControlHandle Cmdlet AutoItX Get-AU3MousePos Cmdlet AutoItX Get-AU3WinPos Cmdlet AutoItX Get-AU3WinHandle Cmdlet AutoItX Get-AU3ErrorCode Cmdlet AutoItX Initialize-AU3 Cmdlet AutoItX Show-AU3WinActivate Cmdlet AutoItX Close-AU3Win Cmdlet AutoItX Wait-AU3WinClose Cmdlet AutoItX Wait-AU3WinNotActive Cmdlet AutoItX Set-AU3Option Cmdlet AutoItX Send-AU3Key Cmdlet AutoItX Wait-AU3Win Cmdlet AutoItX Wait-AU3WinActive Cmdlet AutoItX Get-AU3WinTitle Cmdlet AutoItX Get-AU3WinText Cmdlet AutoItX I’ll show how to use the Cmdlets using a simple example that will open notepad.exe and modify the edit window by setting the text and simulating some keystrokes. First create a blank PowerShell script called notepad_example.ps1 in the same folder as the AutoItX components above and open it for editing. Now we want to import the PowerShell module which is AutoItX.psd1. Enter the following in the script: Import-Module .\AutoItX.psd1 We want to run notepad.exe: Invoke-AU3Run -Program notepad.exe After notepad opens we want to wait for the notepad “Untitled -Notepad” window to appear. You might need to change the title for non-English versions of Windows: $notepadTitle = "Untitled - Notepad" Wait-AU3Win -Title $notepadTitle $winHandle = Get-AU3WinHandle -Title $notepadTitle Get-AU3WinHandle returns a native Win32 handle to the notepad window. We can use this handle in many other AutoIt functions and it uniquely identifies the window which is much more reliable than constantly using a windows title. If you have obtained a window handle using any other Win32 function you can use it with AutoIt. After obtaining the handle to the notepad window we want to ensure that the window is active and then get a handle to the Edit Control. Using the AU3Info.exe tool that comes with AutoIt we can find that the name of the edit control in notepad is Edit1. Show-AU3WinActivate -WinHandle $winHandle $controlHandle = Get-AU3ControlHandle -WinHandle $winhandle -Control "Edit1" Now that we have a handle to the edit control we can set text in two ways: Directly (Set-AU3Controltext) or with simulated keystrokes (Send-AU3ControlKey): Set-AU3ControlText -ControlHandle $controlHandle -NewText "Hello! This is being controlled by AutoIt and PowerShell!" -WinHandle $winHandle Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}simulate key strokes - line 1" -WinHandle $winHandleNow let’s see what the entire script looks like: # Import the AutoIt PowerShell module Import-Module .\AutoItX.psd1 # Run notepad.exe Invoke-AU3Run -Program notepad.exe # Wait for an untitled notepad window and get the handle $notepadTitle = "Untitled - Notepad" Wait-AU3Win -Title $notepadTitle $winHandle = Get-AU3WinHandle -Title $notepadTitle # Activate the window Show-AU3WinActivate -WinHandle $winHandle # Get the handle of the notepad text control for reliable operations $controlHandle = Get-AU3ControlHandle -WinHandle $winhandle -Control "Edit1" # Change the edit control Set-AU3ControlText -ControlHandle $controlHandle -NewText "Hello! This is being controlled by AutoIt and PowerShell!" -WinHandle $winHandle # Send some keystrokes to the edit control Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}simulate key strokes - line 1" -WinHandle $winHandle Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}simulate key strokes - line 2" -WinHandle $winHandle Send-AU3ControlKey -ControlHandle $controlHandle -Key "{ENTER}{ENTER}" -WinHandle $winHandle This is how the notepad window should look if everything is working correctly:
-
$sCommands1 = 'powershell.exe Get-ChildItem' $iPid = run($sCommands1 , @WorkingDir , @SW_SHOW , 0x2) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd ;~ msgbox(0, '' , $sOutput) ConsoleWrite("$sOutput") ConsoleWrite($sOutput) ConsoleWrite(@CRLF) $aOutput = stringsplit($sOutput ,@LF , 2) For $i=0 To UBound($aOutput) - 1 Step 1 ConsoleWrite($aOutput[$i]) Next The script above reads the whole directory into a one dimensional array, but I need to work with the array, so I need to split the array into multiple dimensions. I have already read some forum answers here, and I have already tried these commands: Are there any way to use the $aOutput variable like in PowerShell: PowerShell: $a = Get-ChildItem $a.Mode I imagine this in AutoIt $aOutput ConsoleWrite($aOutput[i].Mode) Or if I split this command into 2 dimension like: For $i To UBound($aOutput)-1 Step 1 ConsoleWrite($aOutput[$i][1]) ConsoleWrite($aOutput[$i][2]) Next
- 6 replies
-
- powershell
- solved
-
(and 1 more)
Tagged with:
-
If I try to run this script with Get-ChildItem which means dir this script works perfectly, but If I try to run this command Get-RDUserSession, my script has the following error message: This command runs perfectly in PowerShell admin and I get back the values Get-RDUserSession -ConnectionBroker broker.local | sort Username Or you can try this command as well Get-Command Get-RDUserSession If I run the above mentioned command this runs perfectly in PowerShell but not with AutoIt. Here is my script you can test the commands: #include<array.au3> $iPid = run('powershell Get-Command Get-RDUserSession' , @WindowsDir , @SW_HIDE , 0x2) ;; This command not works in AutoIT you can test it in PowerShell but it won't work in Autoit ;$iPid = run('powershell Get-RDUserSession -ConnectionBroker broker.local | sort Username' , @WindowsDir , @SW_MAXIMIZE , 0x2) ; This command not works in AutoIT ;$iPid = run('powershell Get-ChildItem | sort Name' , @WindowsDir , @SW_HIDE , 0x2) ; This runs perfectly $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd ;~ msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) _ArrayDisplay($aOutput) That could be the solution of the problem if I could run, directly this PowerShell command window and Write to it and save it's values.
-
I'm trying to run this powershell command from Autoit and can't figure out how to pull it off: Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName } I've been trying to run it many different ways including: $sCMD = 'Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }' RunWait(@comspec & ' /c powershell.exe -nologo -executionpolicy bypass -noprofile -Command "&' & $sCMD & '"') The problem is that it seems I'm missing something in how to escape or double the quotes. I've tried doubling the quotes in many different ways, but the end result always produces a syntax error in powershell. I could just run powershell first, then paste and run the command, then close the powershell window, but that's clunky. I'm trying to do it either via parameter (as above) or in one line like this: RunWait(@comspec & ' /c powershell.exe -nologo -executionpolicy bypass -noprofile -Command "&Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }"')
-
any assistance how to incorporate this powershell command within autoit powershell.exe -nologo -executionpolicy bypass -WindowStyle hidden -noprofile -command "&Set-WinUserLanguageList -LanguageList fr-CA, en-CA -Force"
-
For my next project I would like to send files with "alternate data streams" by email in ZIP format. I can not use any external program like 7-Zip or WinRAR. (They would fit😥) Who knows how to create a ZIP file with "alternate data streams" included with the Powershell command "Compress-Archive"? Here a test script: (save as "ADSTester.cmd") @rem Try to create a zip file with alternate data streams (ADS) included @rem Housekeeping @cls @del ADSTester.zip >nul: @RD /S /Q Extracted >nul: @del ADSTester.txt >nul: @rem End of Housekeeping echo This is the ADSTester.txt file >ADSTester.txt echo This is the ADSTester.txt:Part1 file >ADSTester.txt:Part1 echo This is the ADSTester.txt:Part2 file >ADSTester.txt:Part2 dir /r ADSTester.txt @rem See the 3 files @rem **************************************************************** @rem **************************************************************** @rem Please alter the next lines to include the alternate data streams. powershell Compress-Archive -Path .\ADSTester.txt -Update -DestinationPath ADSTester.zip powershell Expand-Archive -Path ADSTester.zip -DestinationPath .\Extracted\ dir /r Extracted\ADSTester.txt @rem Only one file left :-( pause
- 2 replies
-
- powershell
- zip
-
(and 2 more)
Tagged with:
-
Just for the records: MS provides an easy method to retrieve the methods, properties, events of COM objects by using PowerShell. Open powershell. Create the object. The syntax is: $variable = New-object -ComObject "ProgID" Type the variable name to retrieve the properties of the object Use "Get-Member" to retrieve all properties, methods, collections and events of the object Example: $IE = New-object -ComObject "InternetExplorer.Application" $IE $IE|Get-Member PS> $object = New-Object -COMObject "InternetExplorer.Application" PS> $object Application : System.__ComObject Parent : System.__ComObject Container : Document : TopLevelContainer : True Type : Left : 309 Top : 92 Width : 1383 Height : 870 LocationName : LocationURL : Busy : False Name : Windows Internet Explorer HWND : 2361028 FullName : C:\Program Files\Internet Explorer\iexplore.exe Path : C:\Program Files\Internet Explorer\ Visible : False StatusBar : True StatusText : ToolBar : 1 MenuBar : True FullScreen : False ReadyState : 0 Offline : False Silent : False RegisterAsBrowser : False RegisterAsDropTarget : True TheaterMode : False AddressBar : True Resizable : True PS> $object|Get-Member TypeName: System.__ComObject#{d30c1661-cdaf-11d0-8a3e-00c04fc9e26e} Name MemberType Definition ---- ---------- ---------- ClientToWindow Method void ClientToWindow (int, int) ExecWB Method void ExecWB (OLECMDID, OLECMDEXECOPT, Variant, Variant) GetProperty Method Variant GetProperty (string) GoBack Method void GoBack () GoForward Method void GoForward () GoHome Method void GoHome () GoSearch Method void GoSearch () Navigate Method void Navigate (string, Variant, Variant, Variant, Variant Navigate2 Method void Navigate2 (Variant, Variant, Variant, Variant, Varia PutProperty Method void PutProperty (string, Variant) QueryStatusWB Method OLECMDF QueryStatusWB (OLECMDID) Quit Method void Quit () Refresh Method void Refresh () Refresh2 Method void Refresh2 (Variant) ShowBrowserBar Method void ShowBrowserBar (Variant, Variant, Variant) Stop Method void Stop () AddressBar Property bool AddressBar () {get} {set} Application Property IDispatch Application () {get} Busy Property bool Busy () {get} Container Property IDispatch Container () {get} Document Property IDispatch Document () {get} FullName Property string FullName () {get} FullScreen Property bool FullScreen () {get} {set} Height Property int Height () {get} {set} HWND Property int64 HWND () {get} Left Property int Left () {get} {set} LocationName Property string LocationName () {get} LocationURL Property string LocationURL () {get} MenuBar Property bool MenuBar () {get} {set} Name Property string Name () {get} Offline Property bool Offline () {get} {set} Parent Property IDispatch Parent () {get} Path Property string Path () {get} ReadyState Property tagREADYSTATE ReadyState () {get} RegisterAsBrowser Property bool RegisterAsBrowser () {get} {set} RegisterAsDropTarget Property bool RegisterAsDropTarget () {get} {set} Resizable Property bool Resizable () {get} {set} Silent Property bool Silent () {get} {set} StatusBar Property bool StatusBar () {get} {set} StatusText Property string StatusText () {get} {set} TheaterMode Property bool TheaterMode () {get} {set} ToolBar Property int ToolBar () {get} {set} Top Property int Top () {get} {set} TopLevelContainer Property bool TopLevelContainer () {get} Type Property string Type () {get} Visible Property bool Visible () {get} {set} Width Property int Width () {get} {set}
-
Hi all, I need to read a log file into an array, but the log file is encoded as $FO_UTF16_BE_NOBOM (2048) = Use Unicode UTF16 Big Endian (without BOM) per FileGetEncoding (it returns 2048). I have searched how to convert these log files to UTF-8 and finally found a Powershell command. Since then I have been racking my brain trying to get the function to work. The command itself works from a Powerscript prompt: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content C:\Logs\Myplayer_10-10-17-02-31.log | Set-Content -Encoding utf8 C:\Logs\Myplayer1.log This is my sandbox; #include <array.au3> #include <File.au3> Local $aArrayLogFile Local $sLogDir = "C:\Logs\" Local $sLogFile = "Myplayer_10-10-17-02-31.log" Local $sConvertedLog = "ConvertedLog.log" Local $sLogDirFile = $sLogDir&$sLogFile RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) _FileReadToArray($sLogDirFile, $aArrayLogFile) _ArrayDisplay($aArrayLogFile) Also tried RunWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) and ShellExecuteWait("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"," -Command Get-Content "&$sLogDirFile&" | Set-Content -Encoding utf8 "&$sConvertedLog,$sLogDir) Tried without -Command and a bunch of other parameters that were sprinkled throughout the internet from people trying to get this to work. Thanks Jibs
- 2 replies
-
- powershell
- encoding
-
(and 1 more)
Tagged with:
-
Which Powershell command in the PowerCLI module for VMware ESX used to interact with UI apps? When I launch any exe/any exeutable using powercli on guest VM using powercli command. Invoke-VMScript, I am able to run them in the background but not in the foreground. i.e., UI apps are not launching but showing the background as running in the task manager. We need our UI Automation scripts to execute in the VM, but it is not working. We are able to do in virtualbox and hyper-v but not in vmware esx using powercli. Please suggest.
-
Hello and Good Day to All! I am trying to install .NET 3.5 on Windows 10 x64bit via autoit (via ShellExecuteWait + PowerShell). If I run this line, it will runs without issues: ShellExecuteWait('PowerShell.exe', '-executionpolicy Bypass -File "' & @ScriptDir & '\OJP83BU523.ps1' & '"') "OJP83BU523.ps1" contains: DISM /Online /Enable-Feature /FeatureName:NetFX3 /All /Source:D:\Sources\sxs /LimitAccess However, since I won't know in advance the drive letter of the "sources" folder, I created a script to generate a PowerShell Script to give a correct path for it. With the modified script below, PowerShell only blinks and nothing happens ShellExecuteWait('PowerShell.exe', '-executionpolicy Bypass -File "' & @ScriptDir & '\' & $filename & '"') or ShellExecuteWait('PowerShell.exe', '-executionpolicy Bypass -File "' & $filename & '"') I wish I know the difference with "$filename" and "\OJP83BU523.ps1" usage, as for me, it should be the same. Attached is my entire autoit script. any help is appreciated!, many thanks in advance! test.au3
- 5 replies
-
- shellexecute
- shellexecutewait
-
(and 2 more)
Tagged with:
-
There are a number of posts on the forum regarding use of Selenium in AutoIt. I recently had a go at using the PowerShell Selenium module, and was amazed at how easy it is. Thought I would post an example here; if anyone is interested this could probably be incorporated into AutoIt code pretty easily. Pre-Req - The true star of this script is the ChroPath extension, available for Edge, Chrome and FireFox. With it installed, you just click on the element, select Inspect, and then ChroPath generates the XPath to the element for you. Here is an example based on a simple form I created on one of my sites. $myForm = Start-SeChrome -StartURL "http://logancomputerser.com/Appointment.html" -Maximized $firstName = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_First']" $lastName = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_Last']" $address = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_Street1']" $city = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_City']" $zip = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_Zip']" $state = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//select[@id='formElement_State']" $phoneDay = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_DaytimePhone']" $phoneNight = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_EveningPhone']" $email = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_liamE']" $user = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_48564']" $pw = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='formElement_f403c']" $submit = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='wstForm_Contact_Submit']" $reset = Find-SeElement -Driver $myForm -Timeout 30 -XPath "//input[@id='wstForm_Contact_Reset']" Send-SeKeys -Element $firstName -Keys "Joe" Send-SeKeys -Element $lastName -Keys "Blow" Send-SeKeys -Element $address -Keys "111 S. Main St." Send-SeKeys -Element $city -Keys "AnyCity" Send-SeKeys -Element $zip -Keys "90210" Send-SeKeys -Element $state -Keys "CA" Send-SeKeys -Element $phoneDay -Keys "555.867.5309" Send-SeKeys -Element $phoneNight -Keys "555.888.1212" Send-SeKeys -Element $email -Keys "1Adam12@gmail.com" Send-SeKeys -Element $user -Keys "JBlow" Send-SeKeys -Element $pw -Keys "MyPassword" Start-Sleep 1 Invoke-SeClick -Element $submit Stop-SeDriver -Driver $myForm As mentioned, this is just another way to skin the cat, but I found it a pretty fast way to initiate some easy testing in Selenium, and have used it a couple of times in projects now, both straight through PowerShell and wrapped in AutoIt.
-
Hi guys, I need a little help here I have this simple Powershell script, that is able to set "sig.htm" as signature in OWA for the mail account specified. First part of the script just loads the Exchange snapin, since this is needed for the Get-Mailbox command. #Add Exchange 2010/2013 snapin if not already loaded in the PowerShell session if (!(Get-PSSnapin | where {$_.Name -eq "Microsoft.Exchange.Management.PowerShell.E2010"})) { try { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction STOP } catch { #Snapin was not loaded Write-Warning $_.Exception.Message EXIT } . $env:ExchangeInstallPath\bin\RemoteExchange.ps1 Connect-ExchangeServer -auto -AllowClobber } $mailboxes = Get-Mailbox -Identity user@domain.com $mailboxes| foreach {$file= "sig.htm"; Set-MailboxMessageConfiguration -identity $_.alias -SignatureHtml "$(Get-Content -Path $file -ReadCount 0)"} What I want is for AutoIt to use Powershell.exe to run the script somehow. This way I would be able to use AutoIt variables and arrays together with the PS script. I guess the solution would be to run Powershell.exe with command line arguments? If that is not possible, maybe have the script stored as a "ps1" file, and interact with it that way? (not preferred)
-
I need some help with the powershell code below #include <AutoItConstants.au3> #include <Array.au3> #RequireAdmin $PS='Get-NetConnectionProfile | Where-Object { $_.NetworkCategory -match "$Public" } | Set-NetConnectionProfile -NetworkCategory Private' $sCommands = "powershell -Command " & $PS &"" $iPID = Run(@ComSpec & " /k " & $sCommands, "", @SW_SHOW , $stdout_child)
-
Has anyone had success managing LAPS with AutoIT? (LAPS is Microsoft's Local Admin Password Solution.) I am running v3.3.14.2 and Powershell 5.1.17134.858 on Windows 10 1803 build 17134.885. I have read the entire AutoIT Help file, all of the AD UDF scripts and supporting HTML files, and a large part of the Internet and have researched myself into paralysis. My company has more than one domain with two-way trusts and use LAPS on each domain. At present, we remote in to a jump box in each domain when we need to manage a device there. I want to build a multiple-domain console that works just like the LAPS UI, but allows the user to select a domain via pull-down. At this point, I can't even get the crazy thing to work on the current domain. If I feed it $sComputername = 'T4211BLC1' $sComputerName = GUICtrlRead($idComputerName) $iPID = Run('powershell.exe -executionpolicy bypass Get-AdmPwdPassword "' & $sComputerName & '"', "c:\", @SW_Show, $STDOUT_CHILD) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. While 1 $sOutput = StdoutRead($iPID) if @error then ExitLoop if $sOutput <> "" Then $sStdout = $sStdout & @CRLF & $sOutput WEnd sends this to the console: Get-AdmPwdPassword : The term 'Get-AdmPwdPassword' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-AdmPwdPassword T4211BLC1 + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-AdmPwdPassword:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException But if I put this on the Windows command line: powershell.exe -executionpolicy bypass Get-AdmPwdPassword "T4211BLC1" ...it runs perfectly. ComputerName DistinguishedName Password Expiration Timestamp ------------ ----------------- -------- ---------- T4211BLC1 CN=T4211BLC1,OU=GPO Computers Testing OU,O... YQc7Cl39wFrIF5 6/10/20... So (if you're still awake), Why can't Powershell find 'Get-AdmPwdPassword' when called from within AutoIT? Why can't I read STDOUT? FYI - I've tried ShellExecute, and calling a .ps1 from the script, even Run('cmd /k ...) and I get the same result - Powershell doesn't recognize the cmdlet. Thanks in advance!!
-
I send a string Sun is shining, the weather is sweet to my Powershell script for converting text to JSON request and then to speech. This snippet works as intended: $CMD = "powershell " & $powershellScript & " -Text '" & $sText & "' -Path " & $outputFile[1] & ".wav" $execCommand = Run($CMD, '' , @SW_HIDE, 0x2) This one differs only by single quotes: $CMD = 'powershell ' & $powershellScript & ' -Text "' & $sText & '" -Path ' & $outputFile[1] & '.wav' $execCommand = Run($CMD, '' , @SW_HIDE, 0x2) And only the first word Sun is voiced for some reason. I wonder why is it so and is it on Autoit side or PS/JSON?
- 1 reply
-
- powershell
- doublequote
-
(and 1 more)
Tagged with:
-
Using the PowerShell Group Policy Module with AutoIt
AdamUL posted a topic in AutoIt Example Scripts
Below are some functions that I created when I needed to get some Group Policy information via script. The quickest way I found to get this information was using the Group Policy Module for PowerShell. This is not a full UDF for the Group Policy Module. There are a lot more options available with the cmdlets, and this only touches on a few. To use the functions below, for a Windows client, you will need to install Remote Server Administration Tools (RSAT). For Windows Server 2012 or later, you will need to install the Group Policy Management Console. Remote Server Administration Tools (RSAT) Installing the Group Policy Management Console via PowerShell for Windows Server 2012 or later. Run in an Admin PowerShell prompt. Install-WindowsFeature –Name GPMC PowerShell Group Policy Module Documentation For the example below, the AD UDF is only required to query GPO names, but is not required to use the functions. #include <AD.au3> #include <WinAPIFiles.au3> Global $sLDAPFilter = "(name=*)" Global $sExcludeFilter = "" Global $sIncludeFilter = "" Global $sBaseDN = "DC=ad,DC=university,DC=edu" Global $sDataToRetrieve = "sAMAccountName" $sIncludeFilter = "(&(displayName=LIBS-*))" ;GPO Names. $sLDAPFilter = "(&(objectClass=groupPolicyContainer)" & $sExcludeFilter & $sIncludeFilter & ")" $sDataToRetrieve = "displayName,name" _AD_Open() Global $aGPONames = _AD_GetObjectsInOU($sBaseDN, $sLDAPFilter, 2, $sDataToRetrieve) If @error Then MsgBox(64, "Active Directory Functions", "No objects found") Exit _AD_Close() EndIf _AD_Close() ;Add column headers to the output array. Global $aDataToRetrieve = StringSplit($sDataToRetrieve, ",", 2) For $i = 0 To UBound($aGPONames, 2) - 1 Step 1 $aGPONames[0][$i] = $aDataToRetrieve[$i] Next _ArraySort($aGPONames) _ArrayDisplay($aGPONames, "LIBS GPOs") ;For Testing. Global $aGPOPermissions = _AD_GetGPOPermissionsPS($aGPONames[1][0]) If @error Then Exit 1 _ArrayDisplay($aGPOPermissions, $aGPONames[1][0]) Global $sOU = "OU=libs,OU=active,DC=ad,DC=university,DC=edu" Global $aGPOLinks = _AD_GetGPOLinksPS($sOU) If @error Then Exit 2 _ArrayDisplay($aGPOLinks, $sOU) Global $aGPOInheritedLinks = _AD_GetGPOInheritedLinksPS($sOU) If @error Then Exit 2 _ArrayDisplay($aGPOInheritedLinks, $sOU) Global $aGPOs = _AD_GetAllGPOsPS() If @error Then Exit 3 _ArraySort($aGPOs) _ArrayDisplay($aGPOs, "GPOs") Global $aGPOName = _AD_GetGPOByNamePS($aGPONames[1][0]) If @error Then Exit 4 _ArrayDisplay($aGPOName, $aGPONames[1][0]) Global $aGPOGuid = _AD_GetGPOByGuidPS($aGPONames[1][1]) If @error Then Exit 5 _ArrayDisplay($aGPOGuid, $aGPONames[1][1]) Global $sReportName = "C:\Users\adamul\Desktop\Group Policy Object (GPO) PowerShell\Reports\" & $aGPONames[1][0] & ".html" _AD_GetGPOReportByNamePS($aGPONames[1][0], $sReportName) If @error Then Exit 6 Global $sReportGUID = "C:\Users\adamul\Desktop\Group Policy Object (GPO) PowerShell\Reports\" & $aGPONames[1][1] & ".html" _AD_GetGPOReportByGuidPS($aGPONames[1][1], $sReportGUID) If @error Then Exit 6 Func _AD_GetGPOPermissionsPS($sGPOName) ;An array of permission level for one or more security principals on a specified GPO. Local $sGPOCmd = 'powershell "Import-Module GroupPolicy; Get-GPPermissions -Name ''' & $sGPOName & ''' -All"' ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. Local $iGPOCmdOutputSS = StringInStr($sGPOCmdOutput, @CRLF & @CRLF) If $iGPOCmdOutputSS = 0 Then Return SetError(1, 0, 0) Local $sGPOCmdOutputSS = StringMid($sGPOCmdOutput, 1, $iGPOCmdOutputSS) ;~ ConsoleWrite(@CRLF & @CRLF & $sGPOCmdOutputSS & @CRLF) Local $sRegEx = "([^:\r\n]*):.*" Local $aProperties = StringRegExp($sGPOCmdOutputSS, $sRegEx, 3) ;~ _ArrayDisplay($aProperties) ;For testing. If StringInStr($sGPOCmdOutput, "ArgumentException") Then Return SetError(2, 0, 0) ;Get data on multiple lines to a single line. $sGPOCmdOutput = StringRegExpReplace($sGPOCmdOutput, "(\r\n\h{2,})", "") Local $aGPOCmdOutput = StringSplit($sGPOCmdOutput, @CRLF & @CRLF, 1) ;~ _ArrayDisplay($aGPOCmdOutput) ;For testing. ;Convert from a list output to a 2D array. Local $aGPOCmdOutput2D[$aGPOCmdOutput[0]][UBound($aProperties)] Local $aTemp For $i = 1 To $aGPOCmdOutput[0] Step 1 $aTemp = StringSplit($aGPOCmdOutput[$i], @CRLF, 1) For $j = 1 To $aTemp[0] Step 1 For $k = 0 To UBound($aProperties) - 1 Step 1 If StringInStr($aTemp[$j], $aProperties[$k]) Then $aGPOCmdOutput2D[$i - 1][$k] = StringStripWS(StringReplace($aTemp[$j], $aProperties[$k] & ":", ""), 3) EndIf Next Next Next ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. For $i = 0 To UBound($aProperties) - 1 Step 1 $aProperties[$i] = StringStripWS($aProperties[$i], 3) Next _ArrayTranspose($aProperties) _ArrayConcatenate($aProperties, $aGPOCmdOutput2D) Return $aProperties EndFunc ;==>_AD_GetGPOPermissionsPS Func _AD_GetGPOLinksPS($sOUName) ;An array of GPOs that are linked directly to the location. Local $sGPOCmd = 'powershell "Import-Module GroupPolicy; (Get-GPInheritance -Target ''' & $sOUName & "').GpoLinks" ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. Local $iGPOCmdOutputSS = StringInStr($sGPOCmdOutput, @CRLF & @CRLF) If $iGPOCmdOutputSS = 0 Then Return SetError(1, 0, 0) Local $sGPOCmdOutputSS = StringMid($sGPOCmdOutput, 1, $iGPOCmdOutputSS) ;~ ConsoleWrite(@CRLF & @CRLF & $sGPOCmdOutputSS & @CRLF) ;For testing. Local $sRegEx = "([^:\r\n]*):.*" Local $aProperties = StringRegExp($sGPOCmdOutputSS, $sRegEx, 3) ;~ _ArrayDisplay($aProperties) ;For testing. If StringInStr($sGPOCmdOutput, "ArgumentException") Then Return SetError(1, 0, 0) ;Get data on multiple lines to a single line. $sGPOCmdOutput = StringRegExpReplace($sGPOCmdOutput, "(\r\n\h{2,})", "") Local $aGPOCmdOutput = StringSplit($sGPOCmdOutput, @CRLF & @CRLF, 1) ;~ _ArrayDisplay($aGPOCmdOutput) ;For testing. ;Convert from a list output to a 2D array. Local $aGPOCmdOutput2D[$aGPOCmdOutput[0]][UBound($aProperties)] Local $aTemp For $i = 1 To $aGPOCmdOutput[0] Step 1 $aTemp = StringSplit($aGPOCmdOutput[$i], @CRLF, 1) For $j = 1 To $aTemp[0] Step 1 For $k = 0 To UBound($aProperties) - 1 Step 1 If StringInStr($aTemp[$j], $aProperties[$k]) Then $aGPOCmdOutput2D[$i - 1][$k] = StringStripWS(StringReplace($aTemp[$j], $aProperties[$k] & ":", ""), 3) EndIf Next Next Next ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. For $i = 0 To UBound($aProperties) - 1 Step 1 $aProperties[$i] = StringStripWS($aProperties[$i], 3) Next _ArrayTranspose($aProperties) _ArrayConcatenate($aProperties, $aGPOCmdOutput2D) Return $aProperties EndFunc ;==>_AD_GetGPOLinksPS Func _AD_GetGPOInheritedLinksPS($sOUName) ;An array of GPOs that are applied to the location when Group Policy is processed on a client. Local $sGPOCmd = 'powershell "Import-Module GroupPolicy; (Get-GPInheritance -Target ''' & $sOUName & "').InheritedGpoLinks" ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. Local $iGPOCmdOutputSS = StringInStr($sGPOCmdOutput, @CRLF & @CRLF) If $iGPOCmdOutputSS = 0 Then Return SetError(1, 0, 0) Local $sGPOCmdOutputSS = StringMid($sGPOCmdOutput, 1, $iGPOCmdOutputSS) ;~ ConsoleWrite(@CRLF & @CRLF & $sGPOCmdOutputSS & @CRLF) ;For testing. Local $sRegEx = "([^:\r\n]*):.*" Local $aProperties = StringRegExp($sGPOCmdOutputSS, $sRegEx, 3) ;~ _ArrayDisplay($aProperties) ;For testing. If StringInStr($sGPOCmdOutput, "ArgumentException") Then Return SetError(1, 0, 0) ;Get data on multiple lines to a single line. $sGPOCmdOutput = StringRegExpReplace($sGPOCmdOutput, "(\r\n\h{2,})", "") Local $aGPOCmdOutput = StringSplit($sGPOCmdOutput, @CRLF & @CRLF, 1) ;~ _ArrayDisplay($aGPOCmdOutput) ;For testing. ;Convert from a list output to a 2D array. Local $aGPOCmdOutput2D[$aGPOCmdOutput[0]][UBound($aProperties)] Local $aTemp For $i = 1 To $aGPOCmdOutput[0] Step 1 $aTemp = StringSplit($aGPOCmdOutput[$i], @CRLF, 1) For $j = 1 To $aTemp[0] Step 1 For $k = 0 To UBound($aProperties) - 1 Step 1 If StringInStr($aTemp[$j], $aProperties[$k]) Then $aGPOCmdOutput2D[$i - 1][$k] = StringStripWS(StringReplace($aTemp[$j], $aProperties[$k] & ":", ""), 3) EndIf Next Next Next ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. For $i = 0 To UBound($aProperties) - 1 Step 1 $aProperties[$i] = StringStripWS($aProperties[$i], 3) Next _ArrayTranspose($aProperties) _ArrayConcatenate($aProperties, $aGPOCmdOutput2D) Return $aProperties EndFunc ;==>_AD_GetGPOInheritedLinksPS Func _AD_GetAllGPOsPS() ;An array of information on all the GPOs in a domain. Local $sGPOCmd = 'powershell "Import-Module GroupPolicy; Get-GPO -All"' ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. Local $iGPOCmdOutputSS = StringInStr($sGPOCmdOutput, @CRLF & @CRLF) If $iGPOCmdOutputSS = 0 Then Return SetError(1, 0, 0) Local $sGPOCmdOutputSS = StringMid($sGPOCmdOutput, 1, $iGPOCmdOutputSS) ;~ ConsoleWrite(@CRLF & @CRLF & $sGPOCmdOutputSS & @CRLF) ;For testing. Local $sRegEx = "([^:\r\n]*):.*" Local $aProperties = StringRegExp($sGPOCmdOutputSS, $sRegEx, 3) ;~ _ArrayDisplay($aProperties) If StringInStr($sGPOCmdOutput, "ArgumentException") Then Return SetError(1, 0, 0) ;Get data on multiple lines to a single line. $sGPOCmdOutput = StringRegExpReplace($sGPOCmdOutput, "(\r\n\h{2,})", "") Local $aGPOCmdOutput = StringSplit($sGPOCmdOutput, @CRLF & @CRLF, 1) ;~ _ArrayDisplay($aGPOCmdOutput) ;For testing. ;Convert from a list output to a 2D array. Local $aGPOCmdOutput2D[$aGPOCmdOutput[0]][UBound($aProperties)] Local $aTemp For $i = 1 To $aGPOCmdOutput[0] Step 1 $aTemp = StringSplit($aGPOCmdOutput[$i], @CRLF, 1) For $j = 1 To $aTemp[0] Step 1 For $k = 0 To UBound($aProperties) - 1 Step 1 If StringInStr($aTemp[$j], $aProperties[$k]) Then $aGPOCmdOutput2D[$i - 1][$k] = StringStripWS(StringReplace($aTemp[$j], $aProperties[$k] & ":", ""), 3) EndIf Next Next Next ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. For $i = 0 To UBound($aProperties) - 1 Step 1 $aProperties[$i] = StringStripWS($aProperties[$i], 3) Next _ArrayTranspose($aProperties) _ArrayConcatenate($aProperties, $aGPOCmdOutput2D) Return $aProperties EndFunc ;==>_AD_GetAllGPOsPS Func _AD_GetGPOByNamePS($sGPOName) ;An array of information on one Group Policy Object (GPO) in a domain by Display Name. Local $sGPOCmd = 'powershell "Import-Module GroupPolicy; Get-GPO -Name ''' & $sGPOName & '''"' ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. ;Add end of line characters for single return group to be processed. $sGPOCmdOutput = $sGPOCmdOutput & @CRLF & @CRLF Local $iGPOCmdOutputSS = StringInStr($sGPOCmdOutput, @CRLF & @CRLF) If $iGPOCmdOutputSS = 0 Then Return SetError(1, 0, 0) Local $sGPOCmdOutputSS = StringMid($sGPOCmdOutput, 1, $iGPOCmdOutputSS) ConsoleWrite(@CRLF & @CRLF & $sGPOCmdOutputSS & @CRLF) Local $sRegEx = "([^:\r\n]*):.*" Local $aProperties = StringRegExp($sGPOCmdOutputSS, $sRegEx, 3) ;~ _ArrayDisplay($aProperties) ;For testing. If StringInStr($sGPOCmdOutput, "ArgumentException") Then Return SetError(1, 0, 0) ;Get data on multiple lines to a single line. $sGPOCmdOutput = StringRegExpReplace($sGPOCmdOutput, "(\r\n\h{2,})", "") ;Remove last @CRLF to prevent blank row in return array. $sGPOCmdOutput = StringTrimRight($sGPOCmdOutput, 2) Local $aGPOCmdOutput = StringSplit($sGPOCmdOutput, @CRLF & @CRLF, 1) ;~ _ArrayDisplay($aGPOCmdOutput) ;For testing. ;Convert from a list output to a 2D array. Local $aGPOCmdOutput2D[$aGPOCmdOutput[0]][UBound($aProperties)] ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. Local $aTemp For $i = 1 To $aGPOCmdOutput[0] Step 1 $aTemp = StringSplit($aGPOCmdOutput[$i], @CRLF, 1) For $j = 1 To $aTemp[0] Step 1 For $k = 0 To UBound($aProperties) - 1 Step 1 If StringInStr($aTemp[$j], $aProperties[$k]) Then $aGPOCmdOutput2D[$i - 1][$k] = StringStripWS(StringReplace($aTemp[$j], $aProperties[$k] & ":", ""), 3) EndIf Next Next Next ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. For $i = 0 To UBound($aProperties) - 1 Step 1 $aProperties[$i] = StringStripWS($aProperties[$i], 3) Next _ArrayTranspose($aProperties) _ArrayConcatenate($aProperties, $aGPOCmdOutput2D) Return $aProperties EndFunc ;==>_AD_GetGPOByNamePS Func _AD_GetGPOByGuidPS($sGPOGuid) ;An array of information on one Group Policy Object (GPO) in a domain by GUID. Local $sGPOCmd = 'powershell "Import-Module GroupPolicy; Get-GPO -Guid ''' & $sGPOGuid & '''"' ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. ;Add end of line characters for single return group to be processed. $sGPOCmdOutput = $sGPOCmdOutput & @CRLF & @CRLF Local $iGPOCmdOutputSS = StringInStr($sGPOCmdOutput, @CRLF & @CRLF) If $iGPOCmdOutputSS = 0 Then Return SetError(1, 0, 0) Local $sGPOCmdOutputSS = StringMid($sGPOCmdOutput, 1, $iGPOCmdOutputSS) ;~ ConsoleWrite(@CRLF & @CRLF & $sGPOCmdOutputSS & @CRLF) ;For testing. Local $sRegEx = "([^:\r\n]*):.*" Local $aProperties = StringRegExp($sGPOCmdOutputSS, $sRegEx, 3) ;~ _ArrayDisplay($aProperties) ;For testing. If StringInStr($sGPOCmdOutput, "ArgumentException") Then Return SetError(1, 0, 0) ;Get data on multiple lines to a single line. $sGPOCmdOutput = StringRegExpReplace($sGPOCmdOutput, "(\r\n\h{2,})", "") ;Remove last @CRLF to prevent blank row in return array. $sGPOCmdOutput = StringTrimRight($sGPOCmdOutput, 2) Local $aGPOCmdOutput = StringSplit($sGPOCmdOutput, @CRLF & @CRLF, 1) ;~ _ArrayDisplay($aGPOCmdOutput) ;For testing. ;Convert from a list output to a 2D array. Local $aGPOCmdOutput2D[$aGPOCmdOutput[0]][UBound($aProperties)] ;~ _ArrayDisplay($aGPOCmdOutput2D) Local $aTemp For $i = 1 To $aGPOCmdOutput[0] Step 1 $aTemp = StringSplit($aGPOCmdOutput[$i], @CRLF, 1) For $j = 1 To $aTemp[0] Step 1 For $k = 0 To UBound($aProperties) - 1 Step 1 If StringInStr($aTemp[$j], $aProperties[$k]) Then $aGPOCmdOutput2D[$i - 1][$k] = StringStripWS(StringReplace($aTemp[$j], $aProperties[$k] & ":", ""), 3) EndIf Next Next Next ;~ _ArrayDisplay($aGPOCmdOutput2D) ;For testing. For $i = 0 To UBound($aProperties) - 1 Step 1 $aProperties[$i] = StringStripWS($aProperties[$i], 3) Next _ArrayTranspose($aProperties) _ArrayConcatenate($aProperties, $aGPOCmdOutput2D) Return $aProperties EndFunc ;==>_AD_GetGPOByGuidPS Func _AD_GetGPOReportByNamePS($sGPOName, $sReportFullPath, $sReportType = "HTML") ;Generates a report either in XML or HTML format for a specified GPO by name in a domain. Switch $sReportType Case "HTML", "XML" Case Else Return SetError(1, 0, False) EndSwitch Local $sPath = StringRegExpReplace($sReportFullPath, "(^.*\\)(.*)", "$1") ;~ ConsoleWrite($sPath & @CRLF) ;For testing. ;~ If Not FileExists($sPath) Then Return SetError(2, 0, False) Local $sGPOCmd = 'powershell "Get-GPOReport -Name ''' & $sGPOName & ''' -ReportType ' & $sReportType & ' -Path ''' & $sReportFullPath & '''"' ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. If $sGPOCmdOutput <> "" Then SetError(3, 0, False) Return True EndFunc ;==>_AD_GetGPOReportByNamePS Func _AD_GetGPOReportByGuidPS($sGPOGuid, $sReportFullPath, $sReportType = "HTML") ;Generates a report either in XML or HTML format for a specified GPO by GUID in a domain. Switch $sReportType Case "HTML", "XML" Case Else Return SetError(1, 0, False) EndSwitch Local $sPath = StringRegExpReplace($sReportFullPath, "(^.*\\)(.*)", "$1") ;~ ConsoleWrite($sPath & @CRLF) ;For testing. ;~ If Not FileExists($sPath) Then Return SetError(2, 0, False) Local $sGPOCmd = 'powershell "Get-GPOReport -GUID ''' & $sGPOGuid & ''' -ReportType ' & $sReportType & ' -Path ''' & $sReportFullPath & '''"' ConsoleWrite($sGPOCmd & @CRLF) ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False) Local $iPIDGPOCmd = Run($sGPOCmd, @SystemDir, @SW_HIDE, $STDERR_MERGED) ProcessWaitClose($iPIDGPOCmd) ;Turn on redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(True) Local $sGPOCmdOutput = StringStripWS(StdoutRead($iPIDGPOCmd), 3) ;~ ConsoleWrite($sGPOCmdOutput & @CRLF & @CRLF) ;For testing. If $sGPOCmdOutput <> "" Then SetError(3, 0, False) Return True EndFunc ;==>_AD_GetGPOReportByGuidPS Adam-
- powershell
- group policy module
-
(and 3 more)
Tagged with:
-
Not sure if this is possible or if someone has already tackled this. Is it possible to embed PowerShell into a GUI? Autoit is great for quick function but sometime I need to run a command thru PowerShell. It be great to have PowerShell console embedded into the gui.
- 6 replies
-
- gui powershell
- gui
-
(and 1 more)
Tagged with:
-
After much searching I finally found a method to get eMails from an Exchange eMail account inbox. I was hoping for AutoIT or vbscript but I couldn't find any that would read the inbox messages without using Outlook. I needed this because I'm testing a web-form that generates an eMail sent to a shared mailbox "not what my current outlook is configured for". so, I needed to connect to a different account, then get the inbox messages, and see if the auto-generated eMail message body contains what I submitted in the form. I found a PowerShell script that was close and modified it to do just what I want, but I'd still like it to run in AutoIT but I'm not sure how to use the Microsoft.Exchange.WebServices.dll Anybody have some ideas? #To Launch! # C:\Windows\System32> powershell -ExecutionPolicy ByPass #This launches PowerShell and allows execution of .ps1 files # PS C:\Windows\System32> . "C:\Temp\eMail\getInbox.ps1" #The period . in front of the .ps1 file forces PS to display results on-screen # Where is the EWS .DLL file that you are using # Get the installer from https://www.microsoft.com/en-us/download/details.aspx?id=42022 # We only need 2 dll's from the install and they can be stored anywhere: "Microsoft.Exchange.WebServices.Auth.dll" & "Microsoft.Exchange.WebServices.dll" $EWSdll = "C:\Temp\eMail\Microsoft.Exchange.WebServices.dll" # Where do you want the output text file to be saved $Output = "C:\Temp\eMails.txt" # replace with your email address $email = "MyemailAddress@work.net" # only need to populate these if you're impersonating... $username = "myemail" $password = "Sup3rS3cre+" $domain = "ad.work.net" # load the assembly : point to the dll in the location you have the .dll file [void] [Reflection.Assembly]::LoadFile($EWSdll) # set ref to exchange, first references 2007, 2nd is 2010 (default) #$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1) $s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService # use first option if you want to impersonate, otherwise, grab your own credentials with the 3rd one. not sure what the 2nd one is for $s.Credentials = New-Object Net.NetworkCredential($username, $password, $domain) ##$s.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials #$s.UseDefaultCredentials = $true # discover the url from your email address $s.AutodiscoverUrl($email) # get a handle to the inbox $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($s,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox) #create a property set (to let us access the body & other details not available from the FindItems call) $psPropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $psPropertySet.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text; # If you have a set number of items you want to get, use this and insert the # in the () # $items = $inbox.FindItems(5) # If you want to retrieve all items (Server limit is usually at 1000) then use this line # Details on the max returned by server: https://blogs.msdn.microsoft.com/exchangedev/2010/03/12/throttling-policies-and-the-ewsfindcountlimit/ $items = $inbox.FindItems($inbox.TotalCount) # Put some counts at the top of the output Write-host "Total Inbox count: $($inbox.TotalCount)" Write-host "Unread count: $($inbox.UnreadCount)" #These two lines, write the output to the specified text file Add-Content $Output "Total Inbox count: $($inbox.TotalCount)" Add-Content $Output "Unread count: $($inbox.UnreadCount)" foreach ($item in $items.Items) { # load the property set to allow us to get to the body $item.load($psPropertySet) # Get the Body text as-is $bod = $item.Body.Text #if you only want a short summary of the Body, then comment the above line and un-comment these 4 lines # $bod = $item.Body.Text -replace '\s+', ' ' # $bodCutOff = (100,$bod.Length | Measure-Object -Minimum).Minimum # $bod = $bod.Substring(0,$bodCutOff) # $bod = "$bod..." # output the results - first of all the From, Subject, References and Message ID write-host "====================================================================" Write-host "From: $($item.From.Name)" Write-host "Subject: $($item.Subject)" Write-host "Body: $($bod)" write-host "====================================================================" "" # Output the results to the specified Text file Add-Content $Output "" Add-Content $Output "====================================================================" Add-Content $Output "From: $($item.From.Name)" Add-Content $Output "Subject: $($item.Subject)" Add-Content $Output "Body:",$($bod) Add-Content $Output "====================================================================" Add-Content $Output "" } #see these URLs for more info # EWS Stuff # folder members: https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.folder_members%28v=exchg.80%29.aspx # exporting headers: https://www.allabout365.com/2010/10/export-email-headers-exchange-powershell/ # read emails with EWS: https://social.technet.microsoft.com/Forums/en-US/3fbf8348-2945-43aa-a0bc-f3b1d34da27c/read-emails-with-ews?forum=exchangesvrdevelopment Thanks, Mike
- 4 replies
-
- powershell
- conversion
-
(and 2 more)
Tagged with:
-
I am maintaining all the reusable code in a separate file as library.au3. In that file I have referenced some dependent files using fileinstall, so that they will be extracted when necessary. Problem is, if I use a function in the library.au3 in another script which doesn't require this dependent file, as I am including the whole file using include tag, it is embedding that file also. Is there any way to exclude that.
-
Powershell - COM Many Windows Business Application are now only supporting Powershell, as a scripting environment. Like MS Exchange / SharePoint / Active Directory / MS SQL / etc. This makes Au3 a handicapped scripting environment for administrators to work with. But hold on ! Since 2008 Sapien Technologies has released a Powershell COM component named ActiveXPoSH, that makes the bridge between all Download here http://www.sapien.com/blog/2008/06/25/activexposh-is-now-a-free-download/ First register an account before getting the download access http://www.sapien.com/auth Why would you need Au3 to join PS1 ? Well it is a hell lot easier to create GUI's in AU3 than it is in PS1, so let's marry the 2. Here's an example script translated from there help file to AU3 ;************************************************************************** ; Copyright (c) SAPIEN Technologies, Inc. All rights reserved ; This file is part of the PrimalScript 2007 Code Samples. ; ; File: ActiveXposh.vbs ; ; Comments: ; ; Disclaimer: This source code is intended only as a supplement to ; SAPIEN Development Tools and/or on-line documentation. ; See these other materials for detailed information ; regarding SAPIEN code samples. ; ; THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY ; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A ; PARTICULAR PURPOSE. ;************************************************************************** #AutoIt3Wrapper_UseX64=N Dim $ActiveXPosh Const $OUTPUT_CONSOLE = 0 Const $OUTPUT_WINDOW = 1 Const $OUTPUT_BUFFER = 2 Func CreateActiveXPosh() Dim $success ; Create the PowerShell connector object $ActiveXPosh = ObjCreate("SAPIEN.ActiveXPoSH") $success = $ActiveXPosh.Init(False) ;Do not load profiles If $success <> 0 then Consolewrite( "Init failed" & @CR) endif If $ActiveXPosh.IsPowerShellInstalled Then Consolewrite( "Ready to run PowerShell commands" & @CR) Else Consolewrite( "PowerShell not installed" & @CR) EndIf ; Set the output mode $ActiveXPosh.OutputMode = $OUTPUT_CONSOLE EndFunc Func DownloadFile($URL,$Destination) Local $Return Dim $Command Dim $FSO ;Download a file with PowerShell $ActiveXPosh.Execute("$Client = new-object System.Net.WebClient") ;Note that variables are preserved between calls ; Construct a $Command $Command = "$Client.DownloadFile('" & $URL & "','" & $Destination & "')" ConsoleWrite ("Downloading ..." & @CR) $ActiveXPosh.Execute($Command) $FSO = ObjCreate("Scripting.FileSystemObject") If $FSO.FileExists($Destination) Then ConsoleWrite ("File transfer complete" & @CR) Else ConsoleWrite ("File Transfer failed" & @CR) EndIf Return $Return EndFunc Func ListServices() Dim $outtext ; Set the $OUTPUT mode to $BUFFER $ActiveXPosh.OutputMode = $OUTPUT_BUFFER $ActiveXPosh.Execute("Get-WmiObject -class Win32_Service | Format-Table -property Name, State") ; Get the $OUTPUT line by line and add it to a variable For $str In $ActiveXPosh.OUTPUT() $outtext = $outtext & $str $outtext = $outtext & @CRLF Next ; Alternatively you can get the $OUTPUT as a single String ; $outtext = $ActiveXPosh.OutputString ConsoleWrite ($outtext & @CR) $ActiveXPosh.ClearOutput() ; Empty the $OUTPUT $BUFFER EndFunc ; Create the actual Object CreateActiveXPosh() $Status = $ActiveXPosh.GetValue("(Get-Service UPS).Status") if($Status = "Stopped") then ConsoleWrite ("UPS Service is stopped" & @CR) else ConsoleWrite ("UPS Service is " & $Status & @CR) EndIf ; List all running processes using PowerShell $ActiveXPosh.Execute("Get-Process") ; Check if WinWord is running using PowerShell if $ActiveXPosh.Eval("get-process winword") = 1 Then ConsoleWrite ("Microsoft Word is running" & @CR) Else ConsoleWrite ("Microsoft Word is not running" & @CR) EndIf DownloadFile ("[url="http://izzy.org/scripts/PowerShell/activexposh.pdf","C:\Temp\activexposh.pdf"]http://izzy.org/scripts/PowerShell/activexposh.pdf","C:\Temp\activexposh.pdf[/url]") ; Use ListServices to show all services in this machine using PowerShell() ListServices() ConsoleWrite ("Version " & $ActiveXPosh.GetValue("$PSHOME") & @CR) $ActiveXPosh = "" Example how to load a PS1 command file #AutoIt3Wrapper_UseX64=N Dim $ActiveXPosh Const $OUTPUT_CONSOLE = 0 Const $OUTPUT_WINDOW = 1 Const $OUTPUT_BUFFER = 2 Func CreateActiveXPosh() Local $success ; Create the PowerShell connector object $ActiveXPosh = ObjCreate("SAPIEN.ActiveXPoSH") $success = $ActiveXPosh.Init(False) ;Do not load profiles If $success <> 0 then Consolewrite( "Init failed" & @CR) endif If $ActiveXPosh.IsPowerShellInstalled Then Consolewrite( "Ready to run PowerShell commands" & @CR & @CR) Else Consolewrite( "PowerShell not installed" & @CR & @CR) EndIf ; Set the output mode $ActiveXPosh.OutputMode = $OUTPUT_CONSOLE $ActiveXPosh.OutputWidth = 250 EndFunc ; Create the actual Object CreateActiveXPosh() $PS1 = FileOpenDialog("Open PS1 Script", @ScriptDir & "\", "PS Scripts (*.ps1)") PowerShell_Script($PS1) Func PowerShell_Script($hPSFile) $file = FileOpen($hPSFile, 0) ; Open read only If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Local $sCmd While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $sCmd &= $line & @CRLF Wend ; ConsoleWrite("Line read: " & @CRLF & $sCmd & @CRLF) FileClose($file) ExecuteCMD($sCmd) EndFunc Func ExecuteCMD($sPSCmd) Dim $outtext ; Set the $OUTPUT mode to $BUFFER $ActiveXPosh.OutputMode = $OUTPUT_BUFFER $ActiveXPosh.Execute($sPSCmd) ; Get the $OUTPUT line by line and add it to a variable For $str In $ActiveXPosh.OUTPUT() $outtext = $outtext & $str $outtext = $outtext & @CRLF Next ; Alternatively you can get the $OUTPUT as a single String ; $outtext = $ActiveXPosh.OutputString ConsoleWrite ($outtext & @CR) $ActiveXPosh.ClearOutput() ; Empty the $OUTPUT $BUFFER EndFunc I am running this from component from my Windows 7 x64 bit Powershell 3.0 version, and it still is working fine. Enjoy ! ptrex
-
Hi experts. I'm trying to get this to work: https://www.autoitscript.com/forum/topic/173949-using-the-autoit-powershell-cmdlets/ but I get an error: error: syntax error (illegal character) "Import-Module .\" Can anyone help me?
-
I'm having a heck of a time trying to figure out how to call/invoke a WMI method through Autoit. I have a Powershell script that checks if a reboot is required using multiple checks including a WMI method related to ConfigMgr/SCCM but I want to do this in Autoit because I have a script that does other things and prompts the user to reboot if needed. I've given up on trying to make Autoit run the Powershell script and capture the true/false return value so since I know how to do everything the Powershell script does in Autoit, minus this WMI method call, I figured I'd take a stab at doing all of it in Autoit. The WMI method involved is called DetermineIfRebootPending in the root\ccm\ClientSDK namespace in the CCM_ClientUtilities class. I've done some searching on the forums here and saw many references to the Scriptomatic so I downloaded that and when I run it, since (I'm guessing) there are no properties in the CCM_ClientUtilities class, it doesn't show up as an available option in the class dropdown (see attached image), so it doesn't seem like Scriptomatic is going to help me here unless I'm missing something. Here is the Powershell part that I'd like to convert to Autoit. $CCMClientSDK = $null $CCMSplat = @{ NameSpace='ROOT\ccm\ClientSDK' Class='CCM_ClientUtilities' Name='DetermineIfRebootPending' ComputerName=$ComputerName ErrorAction='SilentlyContinue' } $CCMClientSDK = Invoke-WmiMethod @CCMSplat If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending) { $SCCMReboot = $true } So as you can see, its invoking the DetermineIfRebootPending method and then checking the IsHardRebootPending and RebootPending properties to see if they are True or False. If either are true, it sets the $SCCMReboot to true and later on down the script, it returns that value to the pipeline after checking some other registry locations to determine if reboot is required. If anyone could help me either 1) convert the above code to Autoit or 2) figure out how to run the powershell script from within Autoit and capture the return value, I'd be forever grateful. Thanks!
- 2 replies
-
- wmi
- powershell
-
(and 3 more)
Tagged with:
-
Hello, Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
- 3 replies
-
- powershell
- autoit
-
(and 1 more)
Tagged with: