+ Reply to Thread
Page 1 of 2 1 2 Last
Results 1 to 25 of 33
  1. Senior Member TechStriker's Avatar
    Join Date
    May 2007
    Posts
    131

    Certifications
    BSc (Hons) Computer Science, CCNA, MCP, MCSA:M, MCSE, SCSP, VCP-DV5, VCP6
    #1

    Default Schedule DiskDefrag using Group Policy

    I have been googling this for 3 hours I had no luck, I want if there is an option in group policy to schedule a disk defrag and disk clean up? I can setup a scheduled task on each PC but I want to avoid this. I don’t want to go round 500+ clients and schedule defrags if any one did this please let me know best way to do it. If there is third party open source software which can automate this task is even better but I haven’t seen it and we can’t purchase third party software like Diskeeper.
    Passed SNIA - SCSP
    Working on VCP4
    Reply With Quote Quote  

  2. SS -->
  3. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #2
    Push out a script to schedule the tasks using "at"

    i.e.

    at 4:30 "defrag.exe C:"

    Take a look at the command line options to customize it to your tastes.
    Reply With Quote Quote  

  4. Member
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    77

    Certifications
    A+, Network+, MCSA: Messaging 2003, MCSE 2003, MCTS: Vista Config
    #3
    I did this once by putting it into a startup script. Type in defrag /? to see the syntax for it. Then to trigger a restart I made another script to restart all the PC's. The shutdown command is useful for this. Just schedule the restart script to run on one of your DC's. Unfortunatley you have to add a line for every PC you want to restart so it is a little time consuming. Although it is still a lot faster than going around to everyone and restarting it yourself.

    Hope this helps!!



    undomiels way is better then you won't have to make a big restart script.
    Reply With Quote Quote  

  5. Senior Member TechStriker's Avatar
    Join Date
    May 2007
    Posts
    131

    Certifications
    BSc (Hons) Computer Science, CCNA, MCP, MCSA:M, MCSE, SCSP, VCP-DV5, VCP6
    #4
    Thanks guys for your quick response, I will test this command lines with start up script
    Passed SNIA - SCSP
    Working on VCP4
    Reply With Quote Quote  

  6. Drops by now and again astorrs's Avatar
    Join Date
    May 2008
    Location
    Vancouver, Canada
    Posts
    3,141

    Certifications
    I have numerous certs from VMware, Citrix, Microsoft, EMC, Nimble Storage, Palo Alto Networks and more...
    #5
    Instead of AT.EXE (which stems from NT4 and is somewhat handicapped by that) use SCHTASKS.EXE it has far more switches and I believe fully supports everything you can go from the GUI.
    Reply With Quote Quote  

  7. mikej412's caddy sprkymrk's Avatar
    Join Date
    Feb 2006
    Location
    Charleston, SC
    Posts
    4,976

    Certifications
    MCP (NT4 Server), MCSA 2000, MCSA 2003, CCNA, Security+, Network+
    #6
    These suggestions should get you on the right track, and I would only add one or two options that are simply my opinions, not necessarily better than other suggestions already given.

    First, check out the command "for". It's great when you want to write a script with one variable that will read a text file and substitute the variable with each line/item in the text file in turn. It is easy to create a text file of all your computers (export list) from Active Directory. I'm sure a look through my past posts will show a dozen or more times I have suggested it to people for situations such as this.

    This way you can run the script at will using "psexec" from the pstools suite, a free download from Microsoft. To me this is better than a startup script, because honestly your users will get tired of waiting for a defrag and disk cleanup every time they have to restart their computer. It would also be a pain when you're trying to help trouble shoot an issue or install new software requiring a restart.

    Anyway, those are my two suggestions, "psexec" and "for".
    I can post an example script if you want, it all fits in one line.
    Reply With Quote Quote  

  8. Senior Member TechStriker's Avatar
    Join Date
    May 2007
    Posts
    131

    Certifications
    BSc (Hons) Computer Science, CCNA, MCP, MCSA:M, MCSE, SCSP, VCP-DV5, VCP6
    #7
    sprkymrk can you please post an example script, I really appreciate for all your help and suggestions
    Passed SNIA - SCSP
    Working on VCP4
    Reply With Quote Quote  

  9. Senior Member TechStriker's Avatar
    Join Date
    May 2007
    Posts
    131

    Certifications
    BSc (Hons) Computer Science, CCNA, MCP, MCSA:M, MCSE, SCSP, VCP-DV5, VCP6
    #8
    I want to schedule defrag and disk clean up once a month at 19.00 I know all client machines are free after 19.00 and we have software which shuts down all clients machines at 21.00, can you post sample script please which will help me do this task.
    Passed SNIA - SCSP
    Working on VCP4
    Reply With Quote Quote  

  10. mikej412's caddy sprkymrk's Avatar
    Join Date
    Feb 2006
    Location
    Charleston, SC
    Posts
    4,976

    Certifications
    MCP (NT4 Server), MCSA 2000, MCSA 2003, CCNA, Security+, Network+
    #9
    Well here is a sample script that you can run at will (or simply use the Task Scheduler on your computer to run it once a month). Make sure you run it as an account that has admin rights on all the client machines.

    1. You need a text file of all the computers you want to run this on. You can use AD and simply choose the OU with your client computers, right click, select export list. You'll want to pull it into excel (import data) to clean it up and leave only the computer names. Then copy and paste it back to a text file. Let's call it "computers.txt" in c:\temp for example.

    2. Download the PSTools from Microsoft and just unzip them into your C:\Windows directory.

    3. Then open notepad and type:

    for /f %%C in (C:\Temp\computers.txt) do psexec \\%%C defrag C:

    4. Save this as "defrag.bat". Now you can either double click it to launch at will or run it as a scheduled task on your computer (not the clients, just yours). This will cause it to run defrag on all the computers in the text file. You can create a second script that runs disk cleanup the same way.

    One thing to note about the "for" command, if you use it in a batch file as I described, you use 2 percent symbols for the variable (%%). If you run "for" direct from the cmd line you only use 1 percent symbol (%).

    Good luck.
    Reply With Quote Quote  

  11. Senior Member TechStriker's Avatar
    Join Date
    May 2007
    Posts
    131

    Certifications
    BSc (Hons) Computer Science, CCNA, MCP, MCSA:M, MCSE, SCSP, VCP-DV5, VCP6
    #10
    Thank you very much sprkymrk, your example works like charm, is it best practice to group the clients per 100 or you can run 500 client computers on one file at one go and walk away.

    The other thing I noticed is PsExec executes commands sequential one computer at a time I could see from command that it started the defrag the first computer on the list of my computers.txt file after defrag finishes goes to the second computer on the list, is that how is supposed to work
    Passed SNIA - SCSP
    Working on VCP4
    Reply With Quote Quote  

  12. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #11
    psexec is a great program, I would dare say it is my number one favourite command line tool, and I would recommend getting fully familiar with it. Psexec works like this: it jumps on the computer, executes the command, then jumps off and moves on to the next computer. So yes it is one at a time like you saw.

    By the way, instead of using a for loop by the way you could also do:
    psexec @c:\Temp\computers.txt defrag C:

    Edit:
    Oh and thanks astorrs for pointing out schtask.exe. Didn't know about that one! "at" I'm familiar with from linux. I love the command line, always something new to find out.
    Reply With Quote Quote  

  13. mikej412's caddy sprkymrk's Avatar
    Join Date
    Feb 2006
    Location
    Charleston, SC
    Posts
    4,976

    Certifications
    MCP (NT4 Server), MCSA 2000, MCSA 2003, CCNA, Security+, Network+
    #12
    Quote Originally Posted by TechStriker
    Thank you very much sprkymrk, your example works like charm, is it best practice to group the clients per 100 or you can run 500 client computers on one file at one go and walk away.
    Yes, I do like to split them up into multiple files with 50 or so computers each. You can launch them all at the same time and they work independantly. So you might have 10 lists with 50 computers each, just have each batch file work on different lists:

    for /f %%C in (C:\Temp\computers1.txt) do psexec \\%%C defrag C:
    for /f %%C in (C:\Temp\computers2.txt) do psexec \\%%C defrag C:
    for /f %%C in (C:\Temp\computers3.txt) do psexec \\%%C defrag C:

    etc.


    Quote Originally Posted by undomiel
    By the way, instead of using a for loop by the way you could also do:
    psexec @c:\Temp\computers.txt defrag C:
    True, but for some reason I've always had bad luck with that particular syntax. However, another easy way would be using the "start, step, stop" method instead of a text file. Just use your IP addresses like so:

    for %%C in (1,1,254) do psexec \\192.168.10.%%C defrag C:

    This would run the command on all IP addresses from 192.168.10.1-254. Start at 1, increment (or step) by 1, all the way to 254.
    Reply With Quote Quote  

  14. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #13
    Wow was I being redundant by the way.

    What problems have you had with @? I haven't run into anything so far. Which is not to imply there aren't problems but to know what to keep an eye out for.
    Reply With Quote Quote  

  15. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #14
    Finally I think I have found a solution to a big problem with our network! Thank you for the insight...

    I do have a question about the PsInfo.exe though. I am curious where it 'dumps' the information? I ran it on my local system via command line and it just ran and closed the window. I am using Vista on this machine and have not tried it on another machine in the network with a different OS so it might be that.

    Is there a way to output it to a text file somewhere on my system and retrieve it?

    Anyway...thanks for the defrag information as well.

    Chris
    Reply With Quote Quote  

  16. Sie
    Sie is offline
    Running on caffine
    Join Date
    Dec 2005
    Location
    England, UK
    Posts
    1,207

    Certifications
    ADITP (Advanced Diploma for IT Practitioners) & MCSA (70-270, 70-290, 70-291, 70-299) | Currently working towards C|EH
    #15
    Following a command with the below:

    >> Text.txt

    Would save the output of the command to a txt file called Text.txt. You can call this whatever you like and even in a different directory, just include the full path.

    Coincidently :

    > Text.txt

    Does the same but appends the file.
    Reply With Quote Quote  

  17. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #16
    I was entering it in the run box...I guess it actually has to be run IN a command window...

    All good...

    Thank you so much!

    Chris
    Reply With Quote Quote  

  18. mikej412's caddy sprkymrk's Avatar
    Join Date
    Feb 2006
    Location
    Charleston, SC
    Posts
    4,976

    Certifications
    MCP (NT4 Server), MCSA 2000, MCSA 2003, CCNA, Security+, Network+
    #17
    Quote Originally Posted by Sie
    Following a command with the below:

    >> Text.txt

    Would save the output of the command to a txt file called Text.txt. You can call this whatever you like and even in a different directory, just include the full path.

    Coincidently :

    > Text.txt

    Does the same but appends the file.
    Might just be a typo, but a single "greater than" sign (>) overwrites a file if one exists with that name or just creates it. Using double "greater than" signs (>>) appends information to the end of an existing file if it exists or just creates it.
    Reply With Quote Quote  

  19. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #18
    I am trying to run the defrag on a remote machine, but get this error now:

    Make sure that the default admin$ share is enabled on col3

    col3 being the machine I am trying to run this one.

    I ran it as:

    c:PsTools\psexec -u \\domainname\Administrator -p <PASSWORD> defrag \\col3\c:

    Tha machine is part of the domain and I have the user/pass correct.

    I did that from a cmd prompt and not from a script. I am sure it is something simple or stupid.

    Please advise accordingly...

    Chris
    Reply With Quote Quote  

  20. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #19
    Wouldn't the command go something more along the lines of this?

    psexec -u \\domainname\Administrator -p <PASSWORD> \\col3 defrag c:

    Because from the looks of things in your command it would be trying to access a \\col3\c: computer.
    Reply With Quote Quote  

  21. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #20
    Nope...same result. Will keep poking around at it...

    Chris
    Reply With Quote Quote  

  22. mikej412's caddy sprkymrk's Avatar
    Join Date
    Feb 2006
    Location
    Charleston, SC
    Posts
    4,976

    Certifications
    MCP (NT4 Server), MCSA 2000, MCSA 2003, CCNA, Security+, Network+
    #21
    First make sure the default admin share is available. I am assuming it is, but better to ask.

    Then try the command like this:

    psexec \\col3 -u domain\username password defrag.exe c:

    You need to specify the remote computer first, then the credentials, then the command you want to run.
    Reply With Quote Quote  

  23. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #22
    Other than you missing the -p it works perfectly...

    Now to build the script to make it happen...

    Can you specify a date/time easily to possibly activate this?

    I am trying to schedule a MONTHLY defrag on ALL of the systems in the network...also disk cleanup...

    Slowly making my way...but progress is progress...heh..

    Thanks!!

    Chris
    Reply With Quote Quote  

  24. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #23
    As astorrs mentioned earlier you could use schtasks. Open up a command prompt and do schtasks /create /? to find out what the options are for scheduling a task.

    Put your defrag jobs into a batch file in c:\jobs\defrag.bat for this example.

    schtasks /create /sc monthly /st 18:30:37 /tn "Monthly Defrag" /tr "c:\jobs\defrag.bat"

    That will set it up to run as the currently logged in user (it will ask for your password) and then ta da it is scheduled. You can use /u domain/user /p password to schedule it under a different account. Take a look at the options and customize it to your needs.
    Reply With Quote Quote  

  25. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #24
    Quote Originally Posted by TechStriker
    Thank you very much sprkymrk, your example works like charm, is it best practice to group the clients per 100 or you can run 500 client computers on one file at one go and walk away.

    The other thing I noticed is PsExec executes commands sequential one computer at a time I could see from command that it started the defrag the first computer on the list of my computers.txt file after defrag finishes goes to the second computer on the list, is that how is supposed to work
    Does it actually WAIT for the first defrag to finish before starting the NEXT machine?

    That could be VERY time consuming...it can take an hour of more to defrag a single computer in our collection of crap machines...

    Is there a way around this or would I have to build a batch file that triggers each of them individually?

    Sorry if I missed a solution to this assuming I am correct in my thought process on it...

    Chris
    Reply With Quote Quote  

  26. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #25
    I am also working on setting up the task scheduler, which I know would solve this sequential problem, but in the case of not using the task scheduler is there a way around this...

    Chris
    Reply With Quote Quote  

+ Reply to Thread
Page 1 of 2 1 2 Last

Social Networking & Bookmarks