Re: Writing Script for ScanDisk and Defrag
- From: "Jeffery Hicks [MVP]" <jhicks@xxxxxxxxxx>
- Date: Thu, 3 Jan 2008 06:51:48 -0500
Very well put. Unfortunately, it is Jaybee's management that needs to see this. I agree that if this is something to be done on a regular basis, then create a scheduled task.
--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org
Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.
"Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx> wrote in message news:OlckckaTIHA.1204@xxxxxxxxxxxxxxxxxxxxxxx
There are a number of ways something like this could be implemented (as noted by the other responders) - the best one for your situation would likely be the one that you find simplest - and seems to make the most sense to you. I prefer scheduled tasks over startup scripts because then they would not run too frequently on machines that are rebooted many times per day or too infrequently on machines that are rebooted only rarely. If you are more comfortable setting up startup scripts through group policy, however, that would be a point in favour of that method. But you might want your script to actually do more work to make sure it is not defragging and scanning too often..
However, I would still recommend that you go back to square one and make sure that the *reason* for doing these things is well understood. If, as you say, it is a bit of preventive maintenance, then I would ask you who it was that suggested that this include a run of scandisk (or chkdsk).
As I indicated in an earlier response, there can be some validity in simply running defrag.exe periodically. We do this daily on our file and print servers, but not on our workstations - although I have tried to make a case for it. Pegasus recommends against it because of the possibility of corruption in the event of a power failure reboot. That seems a small risk to me, however, as defrag is designed to avoid committing changes that would leave the file structure in an invalid intermediate state. Also, it would depend on how good your electrical power is, and whether or not you have good UPS capability in place.
But running something like scandisk or chkdsk makes very little sense - UNLESS you are routinely capturing and analysing the error messages they produce. If you were just running one of these to fix whatever problems it can find that might seem nice. But it would be far better for you to know which systems are experiencing disk problems of this nature. If not, the scan program is merely going to defer the problems until the drive crashes completely to such an extent that revival is no longer possible.
You seem to have been thrust into a situation that is currently a little bit over your head. What you really need to do is to start understanding what it take to keep a fleet of computers reliably operational, and realize that you do nobody any good by simply making it look as if good things are happening. A good case in point would be a backup and restore capability. There is no point at all in running backups if you have never tested to make sure you can do a restore, possibly even simulating some types of drive failures (preferably in a test lab environment).
/Al
"JayBee" <JayBee@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:65328973-E801-4C7F-B5BA-2237A188E185@xxxxxxxxxxxxxxxxDeskstops only, Windows XP OS, some users have admin rights, some don't, it
would need to be done once a month, no need for results reporting, probably
quite a bit a free space on most pc's, only concern is C:\.
No problems has occurred, just want some sort of preventive maintenance done.
"Jeffery Hicks [MVP]" wrote:
I know you're stuck in a bad position. Managers think scripting can be a
"cheap" solution, but that is not always the case and I suspect in your
situation this is going to be the case. But back to the situation at
hand...
First, are we talking desktops, servers or both? What OS do you have to
support? Do user's have local admin rights? Is this a one time deal or
something you want to do on some sort of repeated basis? Do you need any
sort of centralized results reporting? Do you have an idea of how much
average free space, as a percentage, users or servers have? Do you have to
worry about drives other than C:\?
Can I ask what is driving this? Is there some suspicion of a problem? Did
somebody read something in a trade mag that they think everything needs to
be defragged?
This is not necessarily a difficult task but let's make sure we do it right
--
Jeffery Hicks
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org
Now Available: WSH and VBScript Core: TFM
Coming Soon: Windows PowerShell: TFM 2nd Ed.
"JayBee" <JayBee@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ACB16357-3B13-4403-BA6F-718C750CF54B@xxxxxxxxxxxxxxxx
> I am quite positive I wouldn't get the approval to buy something like
> DiskKeeper. The big bosses want a simple script wrote to run this. Is
> there
> not an easy VB script I can write to get this going? Please Help!!
> Thanks.
>
> "Jeffery Hicks [MVP]" wrote:
>
>> As much as scripting can help, this may be a situation where a third
>> party
>> like DiskKeeper or PerfectDisk may be warranted. You clearly have >> the
>> need
>> to manage multiple machines. Using a third party tool gives you much
>> more
>> control and information. Plus you can do things like boot time >> defrag
>> which
>> you can't do with the built-in defrag tools.
>>
>> If management has identified this task as business critical they >> should
>> recognize the need to get the best solution.
>>
>> -- >> Jeffery Hicks
>> Microsoft PowerShell MVP
>> http://www.scriptinganswers.com
>> http://www.powershellcommunity.org
>>
>> Now Available: WSH and VBScript Core: TFM
>> Coming Soon: Windows PowerShell: TFM 2nd Ed.
>>
>> "Pegasus (MVP)" <I.can@xxxxxxxxxx> wrote in message
>> news:#Th4HMWTIHA.4656@xxxxxxxxxxxxxxxxxxxxxxx
>> > Put these lines into c:\Windows\MyDefrag.bat:
>> > @echo off
>> > chkdsk.exe /.. /.. /..
>> > defrag.exe /.. /.. /..
>> >
>> > Add your own switches as required. As Jeffery recommended, type
>> > defrag /? and
>> > chkdsk /?
>> > at the Command Prompt to see what the switches mean.
>> >
>> > Running these commands frequently may give you a warm feeling
>> > inside but is neither necessary nor recommended. Chkdsk.exe does
>> > not need to be run all the time in a healthy system and defragging
>> > your partition frequently makes no difference to the speed but >> > could
>> > corrupt the file system if the system gets rebooted in the middle, >> > e.g.
>> > because of a power failure.
>> >
>> >
>> > "JayBee" <JayBee@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> > news:6743AA97-3527-4296-986B-9C8762C701A2@xxxxxxxxxxxxxxxx
>> >> Can you give me an example of a basic script for them? I am not >> >> real
>> >> sure
>> >> how
>> >> I would write it to get it to work. Thanks in advance.
>> >>
>> >> "Jeffery Hicks [MVP]" wrote:
>> >>
>> >>> open a command prompt and run defrag /? and chkdsk /? to see the
>> >>> syntax
>> >>> for
>> >>> each command.
>> >>>
>> >>> -- >> >>> Jeffery Hicks
>> >>> Microsoft PowerShell MVP
>> >>> http://www.scriptinganswers.com
>> >>> http://www.powershellcommunity.org
>> >>>
>> >>> Now Available: WSH and VBScript Core: TFM
>> >>> Coming Soon: Windows PowerShell: TFM 2nd Ed.
>> >>>
>> >>> "JayBee" <JayBee@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> >>> news:954818FD-6444-4411-8E96-3584E87D8ABB@xxxxxxxxxxxxxxxx
>> >>> > Do you know of just a basic script I can write in Notepad to >> >>> > run
>> >>> > defrag
>> >>> > and
>> >>> > scandisk?
>> >>> >
>> >>> > "Jeffery Hicks [MVP]" wrote:
>> >>> >
>> >>> >> You could make it part of a user's logon script, assuming >> >>> >> their
>> >>> >> account
>> >>> >> has
>> >>> >> rights to run defrag. Another option would be to make it part >> >>> >> of
>> >>> >> a
>> >>> >> computer
>> >>> >> startup-script. Or as a variation, use a computer startup >> >>> >> script
>> >>> >> to
>> >>> >> set
>> >>> >> the
>> >>> >> scheduled task to run one time only. You could then use a
>> >>> >> computer
>> >>> >> shutdown
>> >>> >> task to delete the job if you wanted.
>> >>> >>
>> >>> >> -- >> >>> >> Jeffery Hicks
>> >>> >> Microsoft PowerShell MVP
>> >>> >> http://www.scriptinganswers.com
>> >>> >> http://www.powershellcommunity.org
>> >>> >>
>> >>> >> Now Available: WSH and VBScript Core: TFM
>> >>> >> Coming Soon: Windows PowerShell: TFM 2nd Ed.
>> >>> >>
>> >>> >> "JayBee" <JayBee@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> >>> >> news:2E9F79A2-BCC4-43AF-B5DC-CA179509280C@xxxxxxxxxxxxxxxx
>> >>> >> > Thanks for the info, but I need a script I can run once and >> >>> >> > it
>> >>> >> > push
>> >>> >> > to
>> >>> >> > all
>> >>> >> > the computers on our network. We don't want to have to go to
>> >>> >> > every
>> >>> >> > pc
>> >>> >> > and
>> >>> >> > set
>> >>> >> > up a scheduled task. Any ideas?
>> >>> >> >
>> >>> >> > "Al Dunbar" wrote:
>> >>> >> >
>> >>> >> >> Running defrag as a scheduled task makes sense; >> >>> >> >> fragementation
>> >>> >> >> occurs
>> >>> >> >> naturally on a healthy volume, so there is really no need >> >>> >> >> to
>> >>> >> >> know
>> >>> >> >> what
>> >>> >> >> is
>> >>> >> >> going on with defrag unless it reports a serious disk >> >>> >> >> error.
>> >>> >> >> But,
>> >>> >> >> as
>> >>> >> >> far
>> >>> >> >> as
>> >>> >> >> I know, any conditions that CHKDSK might resolve would be
>> >>> >> >> better
>> >>> >> >> known
>> >>> >> >> about
>> >>> >> >> than simply "fixed".
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> /Al
>> >>> >> >>
>> >>> >> >> "Jeffery Hicks [MVP]" <jhicks@xxxxxxxxxx> wrote in message
>> >>> >> >> news:ume6yL%23SIHA.4104@xxxxxxxxxxxxxxxxxxxxxxx
>> >>> >> >> > If you have XP and later clients you can use DEFRAG.EXE >> >>> >> >> > from
>> >>> >> >> > the
>> >>> >> >> > command
>> >>> >> >> > line. You can't run it remotely. You might try setting >> >>> >> >> > up a
>> >>> >> >> > scheduled
>> >>> >> >> > task to do it. You can do that remotely using >> >>> >> >> > SCHTASKS.EXE.
>> >>> >> >> > You
>> >>> >> >> > could
>> >>> >> >> > do
>> >>> >> >> > the same thing with CHKDSK.EXE.
>> >>> >> >> >
>> >>> >> >> > -- >> >>> >> >> > Jeffery Hicks
>> >>> >> >> > Microsoft PowerShell MVP
>> >>> >> >> > http://www.scriptinganswers.com
>> >>> >> >> > http://www.powershellcommunity.org
>> >>> >> >> >
>> >>> >> >> > Now Available: WSH and VBScript Core: TFM
>> >>> >> >> > Coming Soon: Windows PowerShell: TFM 2nd Ed.
>> >>> >> >> >
>> >>> >> >> > "JayBee" <JayBee@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in >> >>> >> >> > message
>> >>> >> >> > news:60D55911-5707-4B16-B650-06FE51D6E1DD@xxxxxxxxxxxxxxxx
>> >>> >> >> >> I need help figuring out a good script to write for >> >>> >> >> >> running
>> >>> >> >> >> ScanDisk
>> >>> >> >> >> and
>> >>> >> >> >> Defrag on our network. It would need to be able to run >> >>> >> >> >> on
>> >>> >> >> >> all
>> >>> >> >> >> the
>> >>> >> >> >> pc's.
>> >>> >> >> >> Can
>> >>> >> >> >> I use it in Group Policy? Any suggestions? Thanks in
>> >>> >> >> >> advance.
>> >>> >> >> >>
>> >>> >> >>
>> >>> >> >>
>> >>> >> >>
>> >
>> >
>>
- Follow-Ups:
- Re: Writing Script for ScanDisk and Defrag
- From: JayBee
- Re: Writing Script for ScanDisk and Defrag
- From: Pegasus \(MVP\)
- Re: Writing Script for ScanDisk and Defrag
- References:
- Re: Writing Script for ScanDisk and Defrag
- From: Al Dunbar
- Re: Writing Script for ScanDisk and Defrag
- From: JayBee
- Re: Writing Script for ScanDisk and Defrag
- From: Jeffery Hicks [MVP]
- Re: Writing Script for ScanDisk and Defrag
- From: JayBee
- Re: Writing Script for ScanDisk and Defrag
- From: Jeffery Hicks [MVP]
- Re: Writing Script for ScanDisk and Defrag
- From: JayBee
- Re: Writing Script for ScanDisk and Defrag
- From: Pegasus \(MVP\)
- Re: Writing Script for ScanDisk and Defrag
- From: Jeffery Hicks [MVP]
- Re: Writing Script for ScanDisk and Defrag
- From: JayBee
- Re: Writing Script for ScanDisk and Defrag
- From: Jeffery Hicks [MVP]
- Re: Writing Script for ScanDisk and Defrag
- From: JayBee
- Re: Writing Script for ScanDisk and Defrag
- From: Al Dunbar
- Re: Writing Script for ScanDisk and Defrag
- Prev by Date: Re: Writing Script for ScanDisk and Defrag
- Next by Date: Re: Writing Script for ScanDisk and Defrag
- Previous by thread: Re: Writing Script for ScanDisk and Defrag
- Next by thread: Re: Writing Script for ScanDisk and Defrag
- Index(es):
Loading