change to progress bar for powershell script
This commit is contained in:
@@ -50,7 +50,7 @@ $index_duration = json_decode(file_get_contents('http://172.17.0.1:5000/index_du
|
||||
Since AD has no way to look this up, this makes it challenging to match groups to OUs.<p>
|
||||
This site has all restricted groups indexed by GPO and OU.<br>
|
||||
Search is case insensitive and supports partial match. <br>
|
||||
The OUs liked to the GPOs will show up as a hover tooltip on the GPO name.<br>
|
||||
The OUs linked to the GPOs will show up as a hover tooltip on the GPO name.<br>
|
||||
Clicking on the GPO name will list all linked OUs.<br><p>
|
||||
</div>
|
||||
<div class="container">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ------------------------------------------------------------------
|
||||
# ------------------------------------------------------------------
|
||||
# 0. Load modules (they are usually loaded by default, but be safe)
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@@ -60,8 +60,6 @@ if (-not $gpoLinks.Count) {
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
|
||||
Write-Host "Found $($gpoLinks.Count) distinct GPO(s) linked in the OU tree."
|
||||
Add-Content -Path $OutputFile -Value " gpo_links: $($gpoLinks.Count)"
|
||||
|
||||
@@ -69,9 +67,11 @@ Add-Content -Path $OutputFile -Value " gpo_links: $($gpoLinks.Count)"
|
||||
# 3. For each GPO, get an XML report and pull RestrictedGroup nodes
|
||||
# ----------------------------------------------------
|
||||
|
||||
|
||||
Add-Content -Path $OutputFile -Value " configured_gpos:"
|
||||
$ou_counter = 0
|
||||
$startTime = Get-Date
|
||||
$totalItems = $gpoLinks.Count
|
||||
|
||||
foreach ($gpoGuid in $gpoLinks.Keys) {
|
||||
$ou_counter++
|
||||
|
||||
@@ -82,11 +82,31 @@ foreach ($gpoGuid in $gpoLinks.Keys) {
|
||||
Write-Warning "Unable to retrieve GPO $gpoGuid – skipping."
|
||||
continue
|
||||
}
|
||||
Write-Host "GPO $ou_counter of $($gpoLinks.Count): $($gpo.DisplayName)"
|
||||
|
||||
# Status Display
|
||||
$percentComplete = [int]( ($ou_counter / $gpoLinks.Count) * 100 )
|
||||
|
||||
if ($ou_counter -gt 0) {
|
||||
$elapsed = (Get-Date) - $startTime # Timespan
|
||||
$averagePerItem = $elapsed.TotalSeconds / $ou_counter
|
||||
$remainingItems = $totalItems - $ou_counter
|
||||
$secondsRemaining = [int]($averagePerItem * $remainingItems)
|
||||
} else {
|
||||
$secondsRemaining = -1 # Unknown – PowerShell will not display it
|
||||
}
|
||||
|
||||
Write-Progress `
|
||||
-Activity "Processing GPOs" `
|
||||
-Status $gpo.DisplayName `
|
||||
-PercentComplete $percentComplete `
|
||||
-SecondsRemaining $secondsRemaining `
|
||||
-CurrentOperation "GPO $ou_counter of $totalItems"
|
||||
|
||||
|
||||
# Update YAML
|
||||
Add-Content -Path $OutputFile -Value " $($gpo.DisplayName):"
|
||||
|
||||
# ok, i need to start generating a variable with all links in it
|
||||
|
||||
|
||||
# -------- Linked OUs ----------
|
||||
$linkedOUs = $gpoLinks[$gpoGuid] # <-- the list we built earlier
|
||||
Add-Content -Path $OutputFile -Value " - Linked_OUs:"
|
||||
@@ -94,7 +114,6 @@ foreach ($gpoGuid in $gpoLinks.Keys) {
|
||||
Add-Content -Path $OutputFile -Value " - $ouDn"
|
||||
}
|
||||
|
||||
|
||||
# Pull the XML report
|
||||
try {
|
||||
$xmlString = Get-GPOReport -Guid $gpoGuid -ReportType Xml -ErrorAction Stop
|
||||
@@ -129,3 +148,4 @@ foreach ($gpoGuid in $gpoLinks.Keys) {
|
||||
$Current_Date = (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt')
|
||||
Add-Content -Path $OutputFile -Value " timestamp: $Current_Date"
|
||||
Add-Content -Path $OutputFile -Value "..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user