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%d
New-Item -Path "\\SERVERNAME\D$\ALLBackup\GPO\$CurrtDate" -ItemType Directory -Force
Backup-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-ADServerSettings

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

 

 

posted @ 2017-06-24 14:33  寻香径  阅读(172)  评论(0编辑  收藏  举报