Forms, text boxes and get-gpo
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Forms, text boxes and get-gpo
Something a little closer to home that says basically the same thing: https://www.sapien.com/blog/2012/05/16/ ... ive-forms/
Re: Forms, text boxes and get-gpo
Here is how to build your function so it can be easily tested and debugged in a console and then directly used in a form:
Code: Select all
$Console = $true
function logit {
Param (
$msg
)
if($Console){
Write-Host $msg
}else{
$TxtBox.Lines += $msg
$txtbox.Select($TxtBox.Text.Length, 0)
$txtbox.ScrollToCaret()
}
}
function Search-GpoXml{
Param(
[string]$SearchTerm,
[array]$LookupXML
)
$allgpos = Get-GPO -All
foreach ($gpo in $allgpos) {
logit "Checking $($gpo.DisplayName) for $Searchterm"
$path = "\\$($gpo.DomainName)\SYSVOL\$($gpo.DomainName)\Policies\{$($gpo.Id)}\*"
$xmlpaths = Get-ChildItem $path -Include $LookupXML -Recurse -Force | ForEach-Object { $_.fullname }
foreach ($xmlfile in $xmlpaths) {
logit "Parsing $xmlfile for $Searchterm"
Start-Sleep 10
$Searching = Get-Content $xmlfile -OutBuffer 1000
foreach ($line in $Searching) {
if ($line -like "*$Searchterm*") {
logit "Found in $GPODisp"
[PSCustomObject]@{
GPOName = $GPO.DisplayName
TargetPath = $xmlfile
Entry = $line
}
}
}
}
}
}
$aResults = Search-GpoXml -SearchTerm $searchterm -Look_XML $look_Xml
Re: Forms, text boxes and get-gpo
No idea what you are referring to. Your issue is just one of coding and logic. Once you understand my code this will become obvious. The multiline textbox will update in real time using my code. Constantly rewriting the "Text" property will no work as you expect.Tnt48185 wrote: ↑Fri May 10, 2019 10:49 am yeah... so, this pretty much sums up what I am seeing, why I am seeing it and what I need to do to fix it: https://stackoverflow.com/questions/352 ... uting-loop
This has nothing to do with responsive forms. That is a completely different issue.
Adding my changes to your complete form displays all lines output into a scrollable textbox that tracks the last line added.