Jump to content

Bertv

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by Bertv

  1. Good one sjatkn I found that a lot of people have hard time to differentiate between ownership and file access rights. This is why I found 177,000 file and folders owned by the administrator in my user folders. I will try to run your script on my test server. Thanks for the reply
  2. Why don't you make a ghost image of the server, remove the original drive and try to install your image on the new 1Tb drive. I believe that you will be presented with the option to resize the partition(s) to use the maximum of available space. If this doesn't work, you just have to plug the old drive back in the server. Enterprise Support - Symantec Corp. - Cloning a Windows NT or Windows 2000/2003 Server Enterprise Support - Symantec Corp. - How to use Symantec Ghost 11.x to image or restore data to a RAID array
  3. Does it replace the ownership of files and folders or does it replace only permissions? Their is a difference between ownership and permissions. A user can be granted full access to a file that he doesn't own. Disk quotas are based on ownership.
  4. When the previous network administrator migrated the user accounts from Novell to win 2003, he copied all the user's data into their new home drives (win 2003). The problem is that he became the owner of the data and the user's disk quota works only with new files and folders. Each user home drive is name as the username. I needed a quick way to reassign proper ownership without manually scanning all the folders (1,600 users). I had a couple of options like subinacl or chown. I opted for chown (Download Free Chown for Windows, Chown for Windows 1.0 Download). It works well at the exception that it will give ownership of the root home drive to the student . Not a problem as you can run it again and take ownership as an administrator. Here are the 2 command lines to restore ownership of all the files and subfolders to a specific user: chown -r student1 "D:\hwhs_users\students\student1\*" chown administrator "D:\hwhs_users\students\student1\" Quick and dirty solution: Scan the students folder, save the home drive name in an array then run Chown with these values: Here is a small vbscript doing the job. enjoy. By the way, I use a nice free utility to find file and folders owned by a specific user: http://www.grimadmin.com/staticpages/index.php/file-owner Bert Set objShell = Wscript.CreateObject("Wscript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") userPath = "D:\hwhs_users\students\" ShowSubfolders FSO.GetFolder(userPath) Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders aSplit = Split (Subfolder.path, "\") UBound(aSplit) If UBound(aSplit) > 1 Then user = aSplit(Ubound(aSplit)) Home_drive = Subfolder.path & "\" cmd1 = "chown -r " & user & " " & chr(34) & home_drive & "*" &chr(34) cmd2 = "chown administrator " & chr(34) & home_drive &chr(34) objShell.exec (cmd1) objShell.exec (cmd2) End If Next End Sub
  5. Just check this page:The Daily Admin: VBScript to Update Active Directory User Information
  6. Talking about accounts creation and users rights, here is what I am working on..... I worked the whole summer creating a script (vbs) to automatically create students accounts on our 2003 and 2008 servers. I am successfully running a test version on 15 servers (about 15,00 students), and since the beginning of the year, I have not manually created a single account . Next year it will run on all our servers (approximately 50,000 students in 137 schools). How does it work? Twice a day, I get an export of the main student Information System database (SIS). The CSV file contains the information about students enrolled in each school. The format of the export is: First Name, Last Name, Student #, Grade, Homeroom The software exports the students already created on the server and compares it to the latest export from the SIS. It then generates the list of accounts to be created. If a student doesn't exist on the server, it is automatically created and I am receiving a confirmation Email. If a student exists on the server and is not anymore enrolled in the school, his account will be disabled (If he enrolls again, his account will be automatically re-enabled) A log of students user names and passwords is automatically updated in the school admin share drive. As a result, if a secretary enters a new student between 8 and 11:30am, the account is created at 12. If the new student is entered in the database after 11:30, the account is created at 8pm. This ensure that a student will have a server's account no more than 1/2 day after he register to a school. This is only the beginning of a suite of applications. The next addition will be to generate Email accounts. The next phase (already started) is for the end of the year, to delete all the student accounts. The software is searching shared drives to delete files owned by students (This is to avoid having 1,000s of orphan files, delete the quota entries, user accounts and users home drives). We only keep a backup of the student home drives, and re-create new accounts every years. The program runs on a scheduled task. The user's creation script is running from August 1st to July 30, and the script to delete the 'old' accounts will run on July 30. The whole suite should be ready around Xmas. The goal is to have an auto management of student accounts. This will leave me more time to work on other projects. Here is a link for a full view of the screen to generate the INI file for the software (It is flexible and have multiples options): http://hrsbstaff.ednet.ns.ca/bvogel/student-setup.jpg
  7. When I do something like this, I put a flag on the client computer..... How? When you copy your config file, copy another small text file named after the version # (ie ver-1-1.txt). You will be able to use IF EXIST ver-1-1.txt in your batch file. If you push a never version (if not exist), first delete the old flag (DEL ver-*.txt) to avoid having multiple versions on the client. Easy and simple. Here is a good one for everybody. To push new files (or install software), I am using a small batch file to create a scheduled task on the WorkStations. Nobody has to be logged on the computers, they just have to be turned ON (advantage of using wakeup on LAN) You need a text file containing the name of the workstations (one name per line) where the software has to be installed (export the names from your AD). To push the scheduled task on the workstations, use the 'system' user (System is an administrator on all computers attached to the AD). The way that it works, you create a scheduled task to run in one hour. When the scheduled task is installed, you tell the WS to run it now. Here is an example: rem @echo off set program=D:\apps\xxx.exe set runtime=09:54 rem +++++++++++++++++++++++++++++++ rem + Do not modify anything under this line + rem +++++++++++++++++++++++++++++++ set program1=%program% rem cd %0\.. for /f %%i in (ws.txt) do ( echo %program% was deployed at%TIME% on workstation %%i >> %program%.log copy %program% \\%%i\D$ ) rem ************************************************ rem * now that the installation software is copied on the WS * rem * we create a schedule task for each WS and run it right away * rem * The switch /ST (start time) has to be set to a time greater * rem * than the actual time. Otherwise the task will never run. * rem *********************************************** for /f %%i in (ws.txt) do ( SCHTASKS /Create /S %%i /z /F /RU SYSTEM /SC ONCE /ST %runtime% /TN %%i /TR "D:\%program1% SCHTASKS /run /S %%i /TN %%i ) Bert
  8. Bertv

    LDIFDE Syntax

    Here is what I use to export a report for all the users in a specific OU. I have previously used Ldif and DSquery with success, but this vbs export format is perfect as you don't have to do any trimming. Bert OPTION EXPLICIT DIM FileName, multivaluedsep,strAttributes DIM strFilter, strRoot, strScope DIM cmd, rs,cn DIM objRoot, objFSO,objCSV DIM comma, q, i, j, mvsep, strAttribute, strValue ' ********************* Setup ********************* ' The filename of the csv file produced by this script FileName ="userexport.csv" ' Seperator used for multi-valued attributes multivaluedsep = ";" ' comma seperated list of attributes to export strAttributes = "givenName,sn,description" 'strAttributes = "sAMAccountName,givenName,initials,sn,displayName,description,physicalDeliveryOfficeName," & _ ' "telephoneNumber,mail,wWWHomePage,cn" ' Default filter for all user accounts (ammend if required) strFilter = "(&(objectCategory=person)(objectClass=user))" ' scope of search (default is subtree - search all child OUs) strScope = "subtree" ' search root. e.g. ou=MyUsers,dc=wisesoft,dc=co,dc=uk ' leave blank to search from domain root strRoot = "" ' ************************************************* q = """" SET cmd = CREATEOBJECT("ADODB.Command") SET cn = CREATEOBJECT("ADODB.Connection") SET rs = CREATEOBJECT("ADODB.Recordset") cn.open "Provider=ADsDSOObject;" cmd.activeconnection = cn IF strRoot = "" THEN SET objRoot = GETOBJECT("LDAP://RootDSE") strRoot = objRoot.GET("defaultNamingContext") END IF cmd.commandtext = ";" & strFilter & ";" & strAttributes & ";" & strScope '**** Bypass 1000 record limitation **** cmd.properties("page size")=1000 SET rs = cmd.EXECUTE SET objFSO = CREATEOBJECT("Scripting.FileSystemObject") SET objCSV = objFSO.createtextfile(FileName) comma = "" ' first column does not require a preceding comma i = 0 ' create a header row and count the number of attributes FOR EACH strAttribute in SPLIT(strAttributes,",") objcsv.write(comma & q & strAttribute & q) comma = "," ' all columns apart from the first column require a preceding comma i = i + 1 NEXT ' for each item returned by the Active Directory query WHILE rs.eof <> TRUE AND rs.bof <> TRUE comma="" ' first column does not require a preceding comma objcsv.writeline ' Start a new line ' For each column in the result set FOR j = 0 to (i - 1) SELECT CASE TYPENAME(rs(j).value) CASE "Null" ' handle null value objcsv.write(comma & q & q) CASE "Variant()" ' multi-valued attribute ' Multi-valued attributes will be seperated by value specified in ' "multivaluedsep" variable mvsep = "" 'No seperator required for first value objcsv.write(comma & q) FOR EACH strValue in rs(j).Value ' Write value ' single double quotes " are replaced by double double quotes "" objcsv.write(mvsep & REPLACE(strValue,q,q & q)) mvsep = multivaluedsep ' seperator used when more than one value returned NEXT objcsv.write(q) CASE ELSE ' Write value ' single double quotes " are replaced by double double quotes "" objcsv.write(comma & q & REPLACE(rs(j).value,q,q & q) & q) END SELECT comma = "," ' all columns apart from the first column require a preceding comma NEXT rs.movenext WEND ' Close csv file and ADO connection cn.close objCSV.Close wscript.echo "Finished"
  9. I had this issue in one of my site, but the culprit was a third party application. We are using Deep Freeze (from Faronics) and I had it set to reboot the workstation when the user logout. I don't know if this is a bug or a feature, but it reboots the workstation only when the next user logon and not when login out as intended.
  10. I am using NtBackup on my 2003 servers. It's efficient (and free) and I start it with a batch file running on the 2003 server. The backup 'server' is an XP workstation. The batch file is called by a scheduled task. The backup computer has a share disk(or partition) for each day of the week. I backup the user's data from Monday to Friday (D: drive + system state), and on Saturday night I am doing a full backup (c: and D: and system state). Monday to Friday for the Data drive Every Saturday for the full backup. As I can keep only two backups for each day of the week (space restriction), my batch file will automatically delete the oldest one. With this solution, I basically keep a backup of the users data for 6 weeks. As a bonus, I installed Blat on the server and it sends me an Email reporting the status of the backup. Here is a report: Media name: "Sat-06-11.bkf created 6/11/2011 at 8:00 AM" Backup Type: Normal Backup started on 6/11/2011 at 8:08 AM. Backup completed on 6/11/2011 at 9:37 AM. Directories: 5080 Files: 59662 Bytes: 15,546,301,662 Time: 1 hour, 29 minutes, and 14 seconds Backup (via shadow copy) of "D: Data" Backup set #2 on media #1 Backup description: "Set created 6/11/2011 at 8:00 AM" Media name: "Sat-06-11.bkf created 6/11/2011 at 8:00 AM" Backup Type: Normal Backup started on 6/11/2011 at 9:37 AM. Backup completed on 6/11/2011 at 3:51 PM. Directories: 51284 Files: 291842 Bytes: 99,578,417,240 Time: 6 hours, 13 minutes, and 35 seconds Backup (via shadow copy) of "System State" Backup set #3 on media #1 Backup description: "Set created 6/11/2011 at 8:00 AM" Media name: "Sat-06-11.bkf created 6/11/2011 at 8:00 AM" Backup Type: Copy Backup started on 6/11/2011 at 3:51 PM. Backup completed on 6/11/2011 at 3:54 PM. Directories: 416 Files: 3055 Bytes: 668,402,536 Time: 2 minutes and 41 seconds Here is the batch file: rem Setting school name (for Email report purpose) set school= ADHS rem set variable for email address (for Email report purpose) set [email protected] Echo.|Command /C Date>DOW set /p today= set DOW=%today:~16,3% FOR /F "tokens=1-6 delims=/ " %%J IN ('DATE /t') DO SET date1=%%J-%%K-%%L rem set variable for the day of the week (3 LETTERS MAXIMUM) set day1=%dow% If %dow% == Mon set drive=Monday If %dow% == Tue set drive=Tuesday If %dow% == Wed set drive=Wednesday If %dow% == Thu set drive=Thursday If %dow% == Fri set drive=Friday If %dow% == Sat set drive=Saturday rem mapping the disk associated to the day on the backup server net use f: \\backup\%drive% Del c:\log.txt rem ***************************************************************************** rem * Recording today's backup' and deleting older files to keep only 2 backups * rem ***************************************************************************** f:\ rem ********************************* rem * moving older.txt to todel.bat * rem ********************************* type f:\older.txt > f:\todel.bat rem *************************************** rem * moving the last backup to older.txt * rem *************************************** type f:\new.txt > f:\older.txt rem ************************************************** rem * Recording today's backup' file name in new.bat * rem ************************************************** echo del %date1%.bkf > f:\new.txt rem *************************** rem * deleteting older backup * rem *************************** f: call todel.bat rem *********************** rem * starting backing up * rem *********************** if %dow% == Mon ntbackup backup @c:\daily.bks /l:s /f F:\%date1%.bkf if %dow% == Tue ntbackup backup @c:\daily.bks /l:s /f F:\%date1%.bkf if %dow% == Wed ntbackup backup @c:\daily.bks /l:s /f F:\%date1%.bkf if %dow% == Thu ntbackup backup @c:\daily.bks /l:s /f F:\%date1%.bkf if %dow% == Fri ntbackup backup @c:\daily.bks /l:s /f F:\%date1%.bkf if %dow% == Sat ntbackup backup @c:\full.bks /l:s /f F:\%date1%.bkf c: cd\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\ copy backup*.log c:\log.txt del C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\*.log rem c:\windows\blat c:\log.txt -subject "%school% backup" -to %email% net use f: /delete
  11. If you copy this script, delete the extra space in 'Wi ndows" or 'Cur rentVersion". This is is a result of a cut and paste as the lines were truncated in my editor
  12. Here is my solution to deploy printers on a Windows 7 workstation from a Windows 2003 servers login script. This vbs is going a bit further as it will suppress the prompt for any software installation. Modify it as you need. 'This script will disable Driver Signing, UAC, LUA as well as the prompt for any software installation with Windows 7 '=================================================================================== Option Explicit Dim objWMI, objItem, colItems, strComputer, VerOS, VerBig, Ver9x, Version9x, OS, OSystem Set WshNetwork = CreateObject("WScript.Network") strComputer = "." 'Getting OS version Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems VerBig = Left(objItem.Version,3) Next 'Setting up registry If OS = win7 (It won’t affects Win XP) If Trim(VerBig) = “6.1” then Dim WSHShell Set WSHShell = CreateObject(“WScript.Shell”) ‘Adding point and print to registry (This is part of the policy in win 2008) ‘These reg keys don’t exist and will be created. WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint\restricted", "0", "REG_DWORD" WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint\TrustedServers", "0", "REG_DWORD" WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint\ServerList", "" WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint\InForest", "1", "REG_DWORD" WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\NoWarningNoElevationOnInstall", "1", "REG_DWORD" WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint\UpdatePromptSettings", "2", "REG_DWORD" 'Disable checking if the driver is certified by Microsoft WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows NT\Driver signing\BehaviorOnFailedVerify", "0", "REG_DWORD" 'Disable UAC and LUA (Won't prompt to run for any software) WSHShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA", "0", "REG_DWORD" WSHShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin", "0", "REG_DWORD" End if 'Installing printers WshNetwork.AddwindowsPrinterConnection "\\servername\printer name" WshNetwork.SetDefaultPrinter "\\servername\printer name" WshNetwork.AddwindowsPrinterConnection "\\servername\other printer name"
×
×
  • Create New...