?
Solved

Disk Quota Notifications (Using Script) Not Working

Posted on 2008-10-30
6
Medium Priority
?
3,011 Views
Last Modified: 2013-12-02
I am pulling my hair out on this one.  I am trying to set up disk notifications using a simple .vbs script I have written that simply pops up a message box.  I cannot, for the life of me, figure out how to get this working within the quota template (in file system resource manager).  E-mail notification works fine, but I do not want to use that.

I need to know:

1 - What to put in the "Run this command or script" field
2 - What to put in the "Command arguments" field
3 - What to choose for the working directory
4 - What permissions to use on these folders
5 - Which command security option I should choose (I would rather go with most secure)

I found somewhere online that I should put "%windir%\system32\cscript.exe" in the "Run this command or script field, and "//nologo C:\Admin\nameofmyvbsscript.vbs" in the "Command arguments" field.  DOESN'T WORK.  What am I doing wrong?

All I want to do is have my vbs execute on the user's machine when they exceed the warning limit.  Seems easy, but no!  Thanks in advance for any help.
0
Comment
Question by:mtsi
  • 3
  • 3
6 Comments
 
LVL 31

Expert Comment

by:Henrik Johansson
ID: 22857623
You nead to run the quota-notification on the file server instead of at the client workstation. Let the result of the script execute a 'net send' targetting the user.
0
 

Author Comment

by:mtsi
ID: 22867362
Yes, I've tried that as well, and could not get it to work.  But that still doesn't answer the question.  Even if I wanted the script to do a net send, I can't get it to execute.  I've even tried a batch file and that doesn't work.  I need more details about how I can get the script to work (with any command).  The command is irrelevant at this point.  I just want the script to run.  Thanks.
0
 
LVL 31

Expert Comment

by:Henrik Johansson
ID: 22881755
The below sample is a working quota configuration file.

Notification=C
RunLimitInterval=1
Command=C:\WINDOWS\SYSTEM32\cmd.exe
Arguments=/c C:\quota-notify.cmd [Source IO Owner] [Quota Path] [Quota Threshold] [Quota Limit]
LogResult=Enable
Account=LocalSystem
WorkingDirectory=c:\temp
MonitorCommand=Enable
KillTimeout=5
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 

Author Comment

by:mtsi
ID: 22890192
Great, thanks for the response.  A few more questions:

1 - I have no idea what path the actual quota configuration file is located at.  I know where to edit some of those things within the GUI configurator, but not the file.  Please let me know.
2 - What are the contents of your "quota-notify.cmd" file in this example?
3 - Do I have to run it as LocalSystem?  I would rather avoid that if possible, and run it as LocalService instead.

Thanks again for your help.
0
 
LVL 31

Accepted Solution

by:
Henrik Johansson earned 1500 total points
ID: 22896087
1. The configuration file is just a textfile used for importing configuration with dirquota CLI-tool.
C:\>dirquota quota add /path:path-to-folder /add-notification:80,C,c:\quota-notify.cfg
C:\>dirquota quota modify /path:path-to-folder /modify-notification:80,C,c:\quota-notify.cfg

If you prefer GUI-based management, the management dialog should look like the attached printscreen.

2. Handle %~1 %~2 etc for each counted parameter (%1 works also, but will not handle "spaced argument" as a single argument). First line splits out USERNAME from  DOMAIN\USERNAME. The script is only logging to a text file, but can also use msg command (replaces 'net send') to send an alert.

for /F "delims=\ tokens=2" %%a in ("%~1") do set quotauser=%%a
echo %DATE% %TIME% %quotauser% passed %~2 percent of %~3 in %~4 >> c:\temp\quota-notify.txt

3. Yes, you shall be able to run it as LocalService instead of LocalSystem. I just used LocalSystem in a lab environment
quota-mgmt.jpg
0
 

Author Comment

by:mtsi
ID: 22932028
Just for those that might be in the same boat...

I was never able to get the .cmd file working, although I'm sure it's possible.  Instead, I used a .vbs script to run a net send command.  Here were the commands I used in FSRM for the template I was setting up:

Run this command or script:

C:\Windows\System32\cscript.exe

Command arguments (note that [Source Io Owner] is very important cause the vbscript uses that to find the current user and send them a message):

//nologo "FULL PATH TO YOUR SCRIPT" [Source Io Owner] [Quota Limit MB] [Whatever other args you want from FSRM]

Working directory:

Same as FULL PATH TO YOUR SCRIPT, minus the script name and last backslash

Run the command as:

LocalService

Here are the contents are my .vbs script:

'*******************************

'Turn on error checking
On Error Resume Next

'Declare variables
Dim objShell
Dim strUser
Dim strLimitMB
Dim intSlashPos

'Get arguments that were passed to the script through File System Resource Manager.  
'You can modify this based on how many arguments you want to give the script in the
'"Command Arguments" field
strUser = WScript.Arguments.Item(0)
strLimitMB = WScript.Arguments.Item(1)

'Remove the "DOMAIN\" portion from the user name
intSlashPos = Instr (1, strUser, "\", vbTextCompare)
strUser = Mid (strUser, intSlashPos + 1, Len(strUser) - intSlashPos)

'Create the object
Set objShell = Wscript.CreateObject("WScript.Shell")

'Create the message to send - this relies on arguments that were passed
'from File System Resource Manager
strMessage = "Some message here.  For example, your folder has reached the limit of " & _
                       strLimitMB & " MB."

'Send the message to the user
objShell.Run "net send " & [strUser] & " " & [strMessage], True

WScript.Quit

******************

I hope this helps others, cause I know how frustrating this is...
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

616 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