Bu powershell scripti ile Active Directory Distinguished Name, AD Snaphot, Group Policy, DNS, GPO Link ve DHCP yedeği/konfigürasyonu export edilebilmektedir. İlgili script bir powershell dosyasına yapıştırılarak, çalıştırılabilir. Çıktılarını script üzerinde belirtilen alan üzerinde oluşacaktır.
<#
Volsys Backup Tool
AD SnapShot, DN, GPO, DNS, GPO link, DHCP
Volkan Demirci
VolsysBackup1 30.1.2019
#>
cd\
if (!(Get-ChildItem(“C:\VolsysBackup”)))
{md VolsysBackup}
cd VolsysBackup
$d = Get-Date -UFormat %d%m%Y
md $d
cd $d
ntdsutil “act inst ntds” snap “delete *” cre q q
Get-ADObject -filter * -Properties * | ft DistinguishedName > DN.txt
md GPOBackup
Backup-gpo -all -path c:\VolsysBackup\$d\GPOBackup
$dns = (Get-ADDomain -Current LocalComputer).dnsroot
export-dnsserverzone -name $dns -filename volsysdns.export
function Get-GPOLink {
<#
.
>
[CmdletBinding()]
param (
[Parameter(Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName)]
[Alias(‘DisplayName’)]
]$Name ) PROCESS { foreach ($n in $Name) { $problem = $false try { Write-Verbose -Message “Attempting to produce XML report for GPO: $n”
$report = Get-GPOReport -Name $n -ReportType Xml -ErrorAction Stop } catch { $problem = $true Write-Warning -Message “An error occured while attempting to query GPO: $n” } if (-not($problem)) { Write-Verbose -Message “Returning results for GPO: $n” [PSCustomObject]@{ ‘GPOName’ = $report.GPO.Name ‘LinksTo’ = $report.GPO.LinksTo.SOMName ‘Enabled’ = $report.GPO.LinksTo.Enabled ‘NoOverride’ = $report.GPO.LinksTo.NoOverride ‘CreatedDate’ = ([datetime]$report.GPO.CreatedTime).ToShortDateString() ‘ModifiedDate’ = ([datetime]$report.GPO.ModifiedTime).ToShortDateString() } } } }
}
get-gpo -all | Get-GPOLink | ft -AutoSize > c:\VolsysBackup\$d\GPOLinks.txt
Export-DhcpServer -ComputerName DC01 -leases -file c:\VolsysBackup\$d\DC01dhcpexport.xml -verbose
Export-DhcpServer -ComputerName DC04 -leases -file c:\VolsysBackup\$d\DC04dhcpexport.xml -verbose
Backup-DhcpServer -ComputerName DC01 -path c:\VolsysBackup\$d\DC01dhcpbackup
Backup-DhcpServer -ComputerName DC04 -path c:\VolsysBackup\$d\DC04dhcpbackup
Get-DhcpServerv4Scope -ComputerName “dc01” | Get-DhcpServerv4Lease -ComputerName “dc01” | Format-Table -Wrap IPAddress, ScopeId, ClientId, HostName, LeaseExpiryTime , Addressstate > C:\volsysbackup\dhcp$d.txt