Created
November 30, 2011 12:20
-
-
Save rcmorano/1408878 to your computer and use it in GitHub Desktop.
Backup your Active Directory users' logon scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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