Advertisement
Guest User

231

a guest
Jun 8th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     # The script should be shceudled on a domain controller and run using the (system) account.
  2.     Import-Module ServerManager
  3.  
  4.     [string]$date = get-date -f 'yyyy-MM-dd'
  5.  
  6.     # \\FileServer\ADBackup$  represent your remote hidden share. Ignore the "AD-$date" part as the script will create it for you
  7.     $TargetUNC = "\\FileServer\ADBackup$\AD-$date"
  8.  
  9.  
  10.     If ( Test-Path $TargetUNC) { Remove-Item -Path $TargetUNC -Recurse -Force }
  11.  
  12.     # (Domain Controllers) built in AD group should have full NTFS and share rights on the remote hidden share \\FileServer\ADBackup$
  13.     New-Item -ItemType Directory -Force -Path $TargetUNC
  14.  
  15.     #Make sure you create a user in your domain (myuser) that have write share and NTFS permission on the hidden share folder
  16.     $WBadmin_cmd = "wbadmin.exe START BACKUP -backupTarget:$TargetUNC -systemState -noverify -vssCopy -quiet -user:Myuser -password:MyPassword "
  17.  
  18.     Invoke-Expression $WBadmin_cmd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement