Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Powershell para poder buscar setting en Active Directory: https://www.maquinasvirtuales.eu/powershell-buscar-setting-especifica-de-gpo
#################################
## Raúl Unzué - El Blog de Negu
## Script buscar Setting GPO
#################################
## NOMBRE DE LA SETTING
$Setting = "Enable search roaming"
## NOMBRE DEL DOMINIO
$Dominio = "negu.local"
## NOMBRE DEL CONTROLADOR
$NeguDC = (Get-ADDomainController -Discover -NextClosestSite).Name
# OBTENER TODA LA LISTA DE GPOS DEL DIRECTORIO ACTIVO
$GPOs = Get-GPO -All -Domain $Dominio -Server $NeguDC | sort DisplayName
# BUSCAMOS LA SETTING EN LAS GPOS LISTADAS
Foreach ($GPO in $GPOs) {
Write-Host "Revisando GPO - $($GPO.DisplayName)"
# EXTRAEMOS UN REPORT
$CurrentGPOReport = Get-GPOReport -Guid $GPO.Id -ReportType Xml -Domain $Dominio -Server $NeguDC
If ($CurrentGPOReport -match $Setting) {
Write-Host "Setting ""$($Setting)"" detectada. Datos de la setting:" -Foregroundcolor Red
Write-Host "- GPO Nombre: $($GPO.DisplayName)" -Foregroundcolor Green
Write-Host "- GPO Id: $($GPO.Id)" -Foregroundcolor Green
Write-Host "- GPO Estado: $($GPO.GpoStatus)" -Foregroundcolor Green
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment