您好,登錄后才能下訂單哦!
如何進(jìn)行PowerShell 腳本域策略管理,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
大中型企業(yè)中,會設(shè)置許多組策略進(jìn)行日常運(yùn)維管理 ,畢然里面也存在許多廢棄的策略,需要我們定期清理我們的組策略信息。通常我們導(dǎo)出HTML報告方式來幫助我們分析組策略信息:
#1
首先需要加載GroupPolicy模塊:
Import-Module GroupPolicy
將GPO導(dǎo)出為一個HTML報告:
Get-GPOReport -All -ReportType html -Path C:\GPOReports\GposReport.html
#2
將每個GPO導(dǎo)出生成自己的HTML報告中:
Get-GPO -All | %{ Get-GPOReport -name $_.displayname -ReportType html -path ("c:\GPOReports\"+$_.displayname+".html") }
#3
讓我們查詢所有設(shè)置被禁用的GPO策略:
$reportFile = "c:\GPOReports\AllSettingsDisabledGpos.csv" Set-Content -Path $reportFile -Value ("GPO Name,Settings") Get-GPO -All | where{ $_.GpoStatus -eq "AllSettingsDisabled" } | % { add-Content -Path $reportFile -Value ($_.displayName+","+$_.gpoStatus) }
#4
查詢沒有應(yīng)用到任何用戶的Gpo策略
$reportFile = "c:\GPOReports\GPOApplyToPermissions.csv" Set-Content -Path $reportFile -Value ("GPO Name,User/Group,Denied") Get-GPO -All | %{ $gpoName = $_.displayName [int]$counter = 0 $security = $_.GetSecurityInfo() $security | where{ $_.Permission -eq "GpoApply" } | %{ add-Content -Path $reportFile -Value ($gpoName + "," + $_.trustee.name+","+$_.denied) $counter += 1 } if ($counter -eq 0) { add-Content -Path $reportFile -Value ($gpoName + ",NOT APPLIED") } }
#4
獲取GPO,鏈接和WMI過濾器:
$reportFile = "c:\GPOReports\GPOLinksAndWMIFilters.csv" Set-Content -Path $reportFile -Value ("GPO Name,# Links,Link Path,Enabled,No Override,WMI Filter") $gpmc = New-Object -ComObject GPMgmt.GPM $constants = $gpmc.GetConstants() Get-GPO -All | %{ [int]$counter = 0 [xml]$report = $_.GenerateReport($constants.ReportXML) try { $wmiFilterName = $report.gpo.filtername } catch { $wmiFilterName = "none" } $report.GPO.LinksTo | % { if ($_.SOMPath -ne $null) { $counter += 1 add-Content -Path $reportFile -Value ($report.GPO.Name + "," + $report.GPO.linksto.Count + "," + $_.SOMPath + "," + $_.Enabled + "," + $_.NoOverride + "," + $wmiFilterName) } } if ($counter -eq 0) { add-Content -Path $reportFile -Value ($report.GPO.Name + "," + $counter + "," + "NO LINKS" + "," + "NO LINKS" + "," + "NO LINKS") } }
#5
查詢具有阻止GPO繼承的組織單位:
Import-Module ActiveDirectory $reportFile = "c:\GPOReports\OUsWithBlockInharit.csv" set-Content -Path $reportFile -Value ("Block Inharitance OU Path") Get-ADOrganizationalUnit -SearchBase "DC=Your,DC=Domain" -Filter * | Get-GPInheritance | Where-Object { $_.GPOInheritanceBlocked } | %{ add-Content -Path $reportFile -Value ($_.path) }
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。