Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Low Disk Space Script to warn logged in User (not via email)

Posted on 2016-08-16
6
Medium Priority
?
120 Views
2 Endorsements
Last Modified: 2016-08-17
Hi,

I have an ongoing problem where users are copying 100's of GB of presonal content onto their local PC hard drives, consuming 100% of their disk space and then complaining to IT that their computer runs slow...
Well, D'Oh!

I dont want to continually have to manually warn people about this and for various reasons i dont want to stop them being able to save to their local disk.
Obviously the little Windows message in the taskbar is not enough a warning for the users

We use File Resource Manager so they cant save these files to the Server mapped drives and the servers themselves are monitored so the server hard drives are fine.

This is just for the users local drives, in particular, just their C drive (i dont care if their external hard drive is at 100%).
The users PCs are Windows 7/10 Pro.

Ive been looking around and found many scripts for Low Disk Space Warnings, almost all for Servers (though it would work for users PCs) but all send email alerts. Which i dont want.

Id like a script that i can run as a group policy, or as a scheduled task, that will pop up a configurable message to the end user every 4 hours when the user is logged on with some message like:

"Your C drive is full. Your computer will run poorly until the drive is cleared.
Please DELETE all movies, music and similar non-work related material from this PC immediately.
This message will continue to be seen every 4 hours until you do so.
Contact your friendly IT Helpdesk for more information"


An added bonus would be to then email IT Helpdesk once a week (as i dont want to be bombarded with emails for low disk space)
But this isnt important.


The main thing I would like is a Warning Message to appear on the users screen they they have to acknowledge (by pressing a radio button saying OK, or I Understand or similar) every 4 hours telling them to delete their movies.
2
Comment
Question by:HBS-Mach
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Senior IT System Engineer
ID: 41758683
Do you mean usingthe pop up like Net Send ?
0
 
LVL 25

Accepted Solution

by:
NVIT earned 2000 total points
ID: 41758690
This works.

Save this to WarnLowDisk.vbs file:

' List Available Disk Space

' Use: cscript WarnLowDisk.vbs 1000000000
' Note: Here, I use 1000000000 as the limit. Adjust per your needs.

Const HARD_DISK = 3

If WScript.Arguments.Count = 0 Then
	FreeSpaceAllowed = 1000000000
Else
	FreeSpaceAllowed = WScript.Arguments.Item(0)
End If

sMessage = "Your C drive is full." & vbCrLf & vbCrLf & _
 "Your computer will run poorly until the drive is cleared. Please DELETE all movies, music and similar non-work related material from this PC immediately. " & vbCrLf & _
 "This message will continue to be seen every 4 hours until you do so." & vbCrLf & vbCrLf & _
 "Contact your friendly IT Helpdesk for more information."
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk Where " & "(DeviceID='C:')")

For Each objDisk in colDisks
    If objDisk.FreeSpace + 1.0 <= FreeSpaceAllowed + 1.0 Then
    	MsgBox sMessage
    End If
Next

Open in new window


To run it in a scheduled task...

If you're on a domain, open group policy management. If not, the Task Settings for a standalone station are similar.

Create a gpo and link it.
Edit the gpo.

Navigate down to User, Control panel settings, Scheduled tasks.

Task Settings

General
New scheduled task (vista and later)
Action: Replace
Name: Low disk space warning
Run only when user is logged on.
Run with highest privileges.

Trigger
Add 2 daily triggers. You may need more, depending on the length of the user's workday. Set each to trigger 4 hrs apart.

Action
Program: cscript
Arguments: WarnLowDisk.vbs 1000000000
1
 
LVL 1

Author Comment

by:HBS-Mach
ID: 41758821
NVIT
Looks great!
I will test this out and get back to you.
1
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 8

Expert Comment

by:Senior IT System Engineer
ID: 41759042
@NVIT,

Does it works on Windows 10 workstations ?
0
 
LVL 1

Author Closing Comment

by:HBS-Mach
ID: 41760249
Can confirm that this works well on Windows 7 and 10.

I put it as a scheduled task via GPO, reoccurring once an hour.
That should annoy the users enough that they delete the junk.

Thank you for your assistance NVIT
0
 
LVL 25

Expert Comment

by:NVIT
ID: 41760314
I overlooked the Windows 10 need in your question and just tested with Windows 7. Still... It worked. Awesome!

I'm glad to have helped, HBS-Mach. Have a nice day/night...
0

Featured Post

Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question