Skip to content

Instantly share code, notes, and snippets.

@rcmorano
Created November 30, 2011 12:20
Show Gist options
  • Save rcmorano/1408878 to your computer and use it in GitHub Desktop.
Save rcmorano/1408878 to your computer and use it in GitHub Desktop.
Backup your Active Directory users' logon scripts
@echo off
rd c:\users-logon-dump /q /s
md c:\users-logon-dump
setlocal ENABLEDELAYEDEXPANSION
set qry=dsquery * -filter "(scriptPath=*)" -attr cn,scriptPath -limit 0
for /f "Skip=1 Tokens=*" %%a in ('%qry%') do (
set rawline=%%a
for /f "tokens=1,2" %%a in ('echo !rawline!') do (
set user=%%a
set script=%%b
)
md c:\users-logon-dump\!user!
copy !script! c:\users-logon-dump\!user!\
)
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment