如何進(jìn)行PowerShell 腳本域策略管理,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
公司主營(yíng)業(yè)務(wù):成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)建站是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。創(chuàng)新互聯(lián)建站推出玉環(huán)免費(fèi)做網(wǎng)站回饋大家。
大中型企業(yè)中,會(huì)設(shè)置許多組策略進(jìn)行日常運(yùn)維管理 ,畢然里面也存在許多廢棄的策略,需要我們定期清理我們的組策略信息。通常我們導(dǎo)出HTML報(bào)告方式來(lái)幫助我們分析組策略信息:
#1
首先需要加載GroupPolicy模塊:
Import-Module GroupPolicy
將GPO導(dǎo)出為一個(gè)HTML報(bào)告:
Get-GPOReport -All -ReportType html -Path C:\GPOReports\GposReport.html
#2
將每個(gè)GPO導(dǎo)出生成自己的HTML報(bào)告中:
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
查詢沒(méi)有應(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過(guò)濾器:
$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)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。