Nichtsdestotrotz würde mich mal interessieren warum mit meinem Powershellansatz die txt datei nicht in das Temp verzeichnis geschrieben wird, die temp PS Datei alleine funktioniert jedenfalls:
AutoIt
Case $AllActivePCButton
$FileName = "AllActivPC.txt"
$sScript = _
'$Computers = Get-ADComputer -Filter {Name -like ''A*'' -or Name -like ''N*''}' & @CRLF & _
'$Jobs = @()' & @CRLF & _
'foreach ($Computer in $Computers) {' & @CRLF & _
' if ($Computer.Name -ne $null -and $Computer.Name -ne '''') {' & @CRLF & _
' $Jobs += Start-Job -ScriptBlock {' & @CRLF & _
' param($Computer)' & @CRLF & _
' if (Test-Connection -ComputerName $Computer.Name -Count 1 -Quiet) {' & @CRLF & _
' $Computer.Name' & @CRLF & _
' }' & @CRLF & _
' } -ArgumentList $Computer' & @CRLF & _
' }' & @CRLF & _
'}' & @CRLF & _
'$Results = $Jobs | ForEach-Object {$_ | Wait-Job | Receive-Job}' & @CRLF & _
'$OnlineComputers = $Results | Where-Object { $_ -ne $null }' & @CRLF & _
'$OutputFilePath = "' & @TempDir & '\computers.txt"' & @CRLF & _
'if ($OnlineComputers) {$OnlineComputers | Out-File -FilePath $OutputFilePath -Force} else {}'
ExecutePowerShellScript($sScript, $FileName)
.
.
Func ShowDomPCsActive($script, $FileName)
; Splash-Screen anzeigen
SplashTextOn("Splash", "Liste wird geholt !!", 300, 50, -1, -1, 33, "", 12)
WinMove("Splash", "", (@DesktopWidth-300)/2, (@DesktopHeight-50)/2)
; Define the path for the PowerShell script
Local $PsScriptPath = @TempDir & "\getcomputers.ps1"
Local $OutputFilePath = @ScriptDir & "\lists\" & $FileName
; Write the script content to the file
Local $fH = FileOpen($PsScriptPath, $FO_OVERWRITE)
If $fH = -1 Then
MsgBox(16, "Error", "Failed to open the file for writing: " & $PsScriptPath)
SplashOff() ; Splash-Screen schließen
Return
EndIf
FileWrite($fH, $script)
FileClose($fH)
; Run the PowerShell script and save the output to the specified file
;RunWait(@ComSpec & " /c powershell -ExecutionPolicy Bypass -File """ & $PsScriptPath & """ > """ & $OutputFilePath & """", @SystemDir, @SW_show)
Local $command = 'powershell -ExecutionPolicy Bypass -File "' & @TempDir & '\getcomputers.ps1"'
ConsoleWrite("Generated Command: " & $command & @CRLF)
RunWait($command, @TempDir, @SW_SHOW)
; Splash-Screen schließen
SplashOff()
; Check if the output file was created
If Not FileExists($OutputFilePath) Then
MsgBox(16, "Error", "Failed to create the output file: " & $OutputFilePath)
Return
EndIf
; Read the content of the new file
Local $ComputerList = FileRead($OutputFilePath)
; Sort the list
Local $ComputerArray = StringSplit(StringStripWS($ComputerList, 3), @CRLF, 1)
_ArraySort($ComputerArray, 0, 0, 0, 1) ; Sort the list
; Set the host file path to the new file
$hostFilePath = $OutputFilePath
; Update the GUI with the sorted list
GUICtrlSetData($Edit1, "")
For $i = 1 To $ComputerArray[0]
If $ComputerArray[$i] <> "" Then
GUICtrlSetData($Edit1, $ComputerArray[$i] & @CRLF, 1)
EndIf
Next
EndFunc
Alles anzeigen
denke fehlt wieder nur ein '' oder so, vielleicht siehts ja jemand, denke das wär erst mal ok für mich
lg und schönen Sonntag