首页 > 代码库 > Powershell About Active Directory Server

Powershell About Active Directory Server

 

一、获取域控制器服务器清单

(Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ } | select hostname,ipv4address,OperatingSystem | Export-Csv d:\ps\List.csv
$allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }

 

二:备份GPO

Import-Module grouppolicy$CurrtDate = Get-Date -UFormat %Y%m%dNew-Item -Path "\\SERVERNAME\D$\ALLBackup\GPO\$CurrtDate" -ItemType Directory -ForceBackup-GPO -all -Path "\\SERVERNAME\D$\ALLBackup\GPO\$CurrtDate"Get-Childitem "\\SERVERNAME\D$\ALLBackup\GPO" | Where {$_.LastWriteTime -lt (Get-Date).AddDays(-20)} | Foreach { Remove-Item $_.FullName -Recurse -Force}

 

三、查看/设置ADServer环境设定

Set-ADServerSettingsSet-ADServersettings -recipientviewroot "wendy.com/accounts"

 

技术分享

 

Powershell About Active Directory Server