Grabbing Folder size and email info

Hi all,
 I've been working on a script that will get the size of all the users profiles folders on our file server. I then set it up to email the I.T. Dept if the size of the file is over 200MB.
So far, when I run the script, it doesn't throw off any errors, but it doesn't send the email either.
Information:
The file server is added as a relay in Exchange.
We are not using port 25, we're using an alternate port instead.
I've tried it with both authenticate and without.
I can telnet to the Exchange server using Putty and open a connection to the port to issue an HELO command.
I am just learning how to script.
The script is pasted below with the obvious omitted.
Since the script doesn't throw an error, I can't track down the problem.
Script us below.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("D:\Profiles")
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
foldersize = objsubfolder.Size/1024/1024                           
Next  
If foldersize > 200 Then
Set objMessage = CreateObject("CDO.Message")
  objMessage.From = [email protected]"
  objMessage.To = "[email protected]"
  objMessage.Subject = " A profile Folder has exceeded 200MB"
  objMessage.TextBody = "The folder " & objSubfolder & " has exceeded 200MB.  Please panic in an orderly fashion." 
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myemailserver"
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 2525
  objMessage.Configuration.Fields.Update 
  objMessage.Send
End If
SO, as I said, it's not throwing an error, but I'm not getting a test email eihter
What am I missing?

Yes, we want one email sent, per folder.
I'm pretty sure I understand why the OP wasn't working. I had foldersize being read, but, the script had no idea of what to do with it as I had the "Next" statement before telling the script what to do with the folders who's size was more than
200MB.
That is partly the answer. Immediately it satisfies the need but ask yourself...why didn't you see that to begin with.  Now look at a more direct method of "saying " the same thing in code.
Set objMessage = CreateObject("CDO.Message")
objMessage.From = "myemail.com"
objMessage.To = "myemail.com"
objMessage.Subject = " A profile Folder has exceeded 200MB"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myexchangeserver"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = myport
objMessage.Configuration.Fields.Update
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("D:\Profiles")
For Each objSubfolder in objFolder.Subfolders
If foldersize > objSubfolder > (1024*1024*200) Then
objMessage.TextBody = "The folder " & objSubfolder & " has exceeded 200MB. Please panic in an orderly fashion."
objMessage.Send
End If
Next
Note that most of the scrip only needs to be crated once.  This is faster, more efficient, easier to maintain and easier to understand.
As Mike pointed out.  Skip VBScript and learn PowerShell.
Same thing in PowerShell
dir \users -dir |
Where{($_|get-childitem -recurse -ea 0|Measure-Object length -sum).Sum -gt 200Mb}|
ForEach{ Send-MailMessage @props -Body "folder too big $($_,Fullname)"}
¯\_(ツ)_/¯

Similar Messages

  • Will Oracle R12 populate employee bank account and email info to Supplier?

    When create employee type supplier from iExpense, will Oracle populate employee bank account and email info from HRMS to Supplier? Or user need set up this in Supplier screen seperately.

    It will not be created automatically. The user will have to manually create the bank accounts in the supplier again.

  • ITunes Folder Size and DVD Burn

    Not sure whether this is the right category. I'll put it in "iTunes", too.
    Got Sony DVDs. 4.7GB.
    When I click on the iTunes folder and "Get Info", it's shows 4.6GB in it.
    Try to drag and drop it in order to burn it onto a DVD for backup and get a message saying it's too large a file for the disk. I should delete some tunes.
    Check the amount of GB available on the disk in Disk Utility. Says "0". Tried three of them with the same result. Not sure what this means.
    Also: when I put the disks into the drive, the icon that shows up as a folder with a burn symbol on it. Not a disk symbol.
    I'm really not sure what this stuff means. I could start deleting songs/albums from iTunes...but not sure whether that's the problem.
    The file should be able to fit onto the DVD. (?)
    Thanks for your time.

    When you burn a DVD or a CD a directory has to be created on it so that the computer will know what is on the media. This takes a certain amount of the available space. I don't know how much of the space it takes as it depends upon the size of the directory. With the total of your library being so close to the rated capacity of the disk there probably isn't enough room for a directory to be created.
    You will need to reduce the size of your library in order to do the burn.

  • Customize Folder Action and Email script

    I have been adapting the below script so if I drop a file on the script, the file will be emaild to the default address. But, I can't figure out how to customize the two below easy tasks into this script. Thanks for any help out there!
    1. A file is moved into folder1 triggers the script.
    2. After the file is email'd I would like it to be moved into folder 2. I have found a script in this forum that moves the file, but I don't know where to add it.
    on adding folder items to theFolder after receiving theAddedItems
    tell application "Finder"
    move theAddedItems to folder "G5:Users:camille:Desktop:folder2:"
    end tell
    end adding folder items to
    The Send File Script that I have been adapting (concept and initial coding by Paul Van Cotthem):
    property this_folder : "G5:Users:camille:Desktop:folder1"
    property emailAddress : "[email protected]"
    global sendAction
    on open fileList
    -- If one prefers to test for folders before the files are created, the enable this code.
    repeat with filePath in fileList
    if (filePath as string) ends with ":" then
    display dialog "Please drop only files, not folder." buttons {"OK"} default button 1 with icon 0
    return
    end if
    end repeat
    enterAddress()
    repeat with filePath in fileList
    set filePath to filePath as string
    if filePath does not end with ":" then -- it's a file
    tell application "Finder" to set fileName to name of item filePath
    tell application "Microsoft Entourage"
    -- This code is faster, but if the user trashed the attached files before sending them, Entourage cannot send the attachtments.
    make new outgoing message at out box folder with properties {recipient:emailAddress, subject:fileName, attachment:filePath}
    -- This code is slower, but attached files are saved into Entourage's message database immediately.
    set theSubject to "File attached: " & fileName
    set newmsg to make new draft window with properties ¬
    {recipient:{address:emailAddress, recipient type:to recipient}, subject:theSubject, content:theSubject, attachment:filePath}
    send newmsg
    end tell -- Entourage
    end if -- file or folder?
    end repeat -- filePath
    end open
    on run
    enterAddress()
    end run
    on enterAddress()
    display dialog "Send to:" buttons {"Cancel", "Send now"} with icon note ¬
    default button 2 default answer emailAddress giving up after 2
    set dialogResult to result
    set sendAction to button returned of dialogResult
    set emailAddress to text returned of dialogResult
    end enterAddress
    G5   Mac OS X (10.3.9)  
    G5   Mac OS X (10.3.9)  
    G5   Mac OS X (10.3.9)  
    G5   Mac OS X (10.3.9)  

    Go ahead and put that chunk of code on a new line at the very bottom of your script. Then between the on adding folder items to theFolder after receiving theAddedItems line and the tell application "Finder" line, insert the word open on a line by itself.
    By putting the term "open" there you are telling the script to run all the code in the "on open" block when triggered by the folder action handler. To make the folder action active you'll need to save the droplet in your ~/Library/Scripts/Folder Action Scripts folder, and then you'll need to attach it to something by control-clicking the desired folder and/or using the Folder Action Setup Utility to connect script to folder.

  • Folder size and library size don't match?

    I have my iTunes music library located on an external hard drive and when I do the "get info" tool on it it shows up being 43 gigs. However, when I'm using iTunes it says that my total music library is 19 gigs, my videos are only 383 mb, and my podcasts take up 2 gigs. that only amounts to about 21 gigs!? Does this mean that some songs didn't import when initially relocating my music library to my external hard drive? how can I find these songs and import them or delete them?

    Hey There!
    My reply to this person might help you!
    http://discussions.apple.com/thread.jspa?threadID=1210125&tstart=0
    Good luck!
    Sharon

  • Prev. Systems Folder sizes and other folders appear after Arch and Install

    Five days ago I did a successful Archive and Install and I now have on my external HD not only the Previous Systems Folder but two other folders, one named 'home' and one named 'net' - both empty. They do not appear on my Internal HD.
    I have two questions:
    1- The Previous Systems Folder on my HD is 5.7 GB; the Previous Systems Folder on my external HD is 31.02 GB!! Why such a difference? (And no wonder my Deja Vu backups are taking 5 hours.)
    2-Is it OK to trash the empty 'home' and 'net' folders when I finally trash the Previous Systems Folders? Do they have any continuing purpose?

    Dedo wrote:
    The Internal system folder and my backup are the same, of course, because I backed up last night.
    The Previous systems on the external appear to contain all the same things as my System and my backup System except the dates are older on the Previous files.
    I have launched the multitude of applications I have on the Dock and all are fine. So are other apps and the many Utilities I've tried.
    Cool. So toss the Previous System Folder.
    BTW-I also have a folder on my internal HD just below Applications and Applications (Mac OS9) called BaseSystem.pkg.1637wIVhp. Do you know anything about that? It's 2 MB and has 50+ items in it mostly starting with com.apple.xxxx.enabled. Things like airportPrefsUpdater.enabled, coreservices, kernaleventmgr, reportcrash, periodic-daily, monthly, weekly.enabled.
    No idea.
    All carry the same date Jan. 22, 2008 and within a few minutes of each other except SystemVersion. plist which is about 3 mos. old Most are zero KB.
    Do you know where these came from?

  • HT202213 I have suddenly been unable to connect my computer to my apple tv.  I have turned on my home sharing in itunes but it still does not show an icon in the sidebar.  I have reset my apple tv and redone all the passwords and email info and still does

    I have had my apple tv for 2 years and until I updated it I had no problems.  Now it keeps telling me to turn on my home sharing in iTunes which I have done innumerablre times. It won't recognise my macbook pro so I reset my apple tv to original settings and still it won't work.  Any ideas??????

    Me too I have the same problem as MicheleP57!!!! What can I do???

  • Listing File, path, sizes and dates

    Hi all
    Case: I have 6 machines on one network (some with 2 drives), another on another network (connected by vpn) and 3 external drives.
    These all have accumulated stuff, some repeated as I've upgraded and re-purposed machines but left directories behind as a safeguard.
    I need to rationalise the space and develop a more systematic approach to backup and archiving.
    My first step is do an inventory of what's where and my natural approach is work with a data base of file name, path, size, created date and last modified to allow me to do some maths on archiving to dvd.
    Using find as follows
    find [Start Somewhere Directory] -print > [workspace path]/TestOutput.txt
    gives me a nice list of file name I can parse out in a database
    But I don't get size and dates.
    Adding -ls produces that info but creates header lines for parent directories and adds permissions, node and other info I don't need.
    I got to here
    find [Start Somewhere Directory] -type df -exec ls -lshk {} \; -print > [workspace path]/TestOutput.txt
    but still has the hierarchical output rather than flat paths.
    Am I doing this all the hard way ? Is there a tool that returns just what I'm looking for ?
    Or what command will allow me to take just the relevant columns form ls to the print parameter ?
    Or can I extend find to add the size and date info to the output ?
    Kind Regards
    Eric

    Eric
    I just so happened to have done something similar before!
    It relies on mdls so isn't exactly speedy, but produces a full path, size, modification date, modification time, creation date and creation time as a comma separated list. mdls is not exactly predictable as to which order you get its output, so basically you have to try first without any editing.
    Anyway, here it is:
    sudo find ~/testfolder -type f \! -name ".*" -exec echo 'mdls -name kMDItemFSSize -name kMDItemFSCreationDate -name kMDItemFSContentChangeDate "{}" | tr "\n" "," | sed "s%^\(/.*\) .*ChangeDate = \(....-..-..\) \(.*\) .CreationDate.= \(....-..-..\) \(.*\) ...00,.FSSize.= \(.*\),$%\"\1\",\6,\2,\3,\4,\5%"' \; | shI'm sure it could be improved!
    You could also do it with AppleScript, since that can access the creation date easily.

  • Create/run Report on specific folder size on machines?

    Done some searching but can't seem to get a suitable solution for this. Essentially I want to run a report which will tall the the total size of a folder, if it exists, on all my machine. "C:\myprograms\tax". It's not in the user context which
    should make this somewhat easier?
    Does anyone know any relatively straightforward ways of getting a report on this?
    Thanks!

    ok; here's what I did in my lab (and it worked for me):
    1. Create a new ConfigItem -- check the box about "This Configuration item contains application settings".  For this example, I'm going to name it "InetPub Folder Size"
    2. Detection methods, use a custom script, powershell
       if (Test-Path c:\inetpub) {write-host exists}
    3.  Setting, New, Script, String data type, add script of Powershell.  I know your script appended "MB"; but I think from the standpoint of what I'd do with the data (potentially) once I get a report out, I'd want it to be just a raw number,
    so if I had to do stuff with that number in sql or excel, I don't have to strip out the MB part.  You'll know it's MB, right?
    if (Test-Path c:\inetpub) {
    $colItems = (Get-ChildItem c:\inetpub -recurse | Measure-Object -property length -sum)
    $result = [int]($colItems.sum / 1MB)
    write-host $result
    4.  Compliance Rules; Value EQUALS the phrase  "Report Any Value" 
    Since it will never ever return that result, everything will be a non-compliant (which is what we want)
    5. Supported Platforms: select all or just select the OS' you care about.
    6.  Create a baseline (name doesn't matter), add this CI to it.  after you add it, make sure you change Purpose from "Required" to "Optional".
    7. Deploy the Baseline on a (for example) daily re-run schedule to a collection--probably just a test box for now.
    8. Bunch of policy refreshes, and interactively run the baseline.  in the control panel applet, it SHOULD say it's non-compliant.  Locally check the report there, see what the results are (just so you see it working).
    9. in SQL Management Studio (might take a few minutes for the non-compliant value to show up from the client through your MP into your database, i.e., wait 15-20 min maybe), run this against your CM_ database:
    select
      s1.netbios_name0,
      ci.displayname,
      rooles.RuleName,
      perclientdetails.DiscoveredValue
    from
    v_localizedciproperties ci
    join vDCMDeploymentNonCompliantRuleDetailsPerClientMachine perclientDetails
     on perclientdetails.ci_id=ci.ci_id
    join v_CIRules rooles on rooles.rule_id=perclientdetails.rule_id
    join v_r_system s1 on s1.ResourceID=perclientDetails.ItemKey
    where
      ci.displayname = 'InetPub Folder Size'
     and
     ci.localeid = 1033
    order by s1.Netbios_Name0
    Standardize. Simplify. Automate.

  • How to create a folder in which email forms are stored which cab be used and usen again

    Hi folks of the free software comunity,
    in the olden days I used to use a mail program made by MARINET in England. This received an sent emails via a sattelite connection an nothing else.
    The program had a feature called pre-formed mails:
    In a special folder lots of pre-written emals where stored - messages that needed to be sent again an again wit slightly changed contens. The address, reference and text fields where already filled.
    If needed you would open one of these pre-written mail, change a few items - say the date, number of item or some such
    Adress an reference would remain the same.
    The SENT the bugger an finished.
    In the SENT folder this mail would be shown with the corrected text.
    In the special folder the not corrected mail would remain.
    The special folder served as a file of mails already written as well as a remainder of what needed to be sent - by looking at the stored mails - an so save the user a lot of work.
    My question:
    How can this be created in THUNDERBIRD ?
    tks n bregards
    i.b.b
    [email protected] (pls copy an answer to this mail address

    Open a new Write message.
    Create the email you want to use as a Template, give the 'Subject' a suitable title so you can easily locate that template email, but do not enter any email addresses.
    Then click on 'Save' as 'Template' OR File > Save As > Template.
    A Templates folder will be auto created and th email will be stored in that Templates folder.
    To use:
    Select Templates folder to see emails.
    Double click on email OR right click on email and select 'Edit as new Messge' to open in a new Write window.
    Edit as required and send as usual.
    The email in the Templates folder will remain as is and can be reused again and again.
    Additional info:
    If you wish to send one personalised email to a group, so each person gets their own personalised email, you could consider an addon called 'Mail Merge' which works with Template email and either a .csv file or an address book.
    * https://addons.mozilla.org/en-US/thunderbird/addon/mail-merge/

  • Finder won't display folder size in "Size" column or Info window

    Normally, the Finder window will display a folder's size in the Size column. However, I have one folder which shows as "Zero KB" in the Size column. When I open the General Info window, the Size reads as "Zero KB on disk (Zero bytes) for 0 items."
    In order to get the folder size I have to go into the folder, select all folders (there's many), then with either the Summary Info or Inspector window, it'll show the folder size ("185.32 GB on disk").
    Why is this occurring in only this folder? Is it because it's a large folder or a folder with many subfolders?
    I'm running Snow Lep 10.6.2. The folder is on an external drive in FAT32 format. I've already tried deleting the "com.apple.finder.plist" file and rebooting.
    Thanks for any help.

    go to view menu->show view options and check the box 'calculate all sizes". then click "use as defaults".

  • Font size and color will not change in emails, blogs, forums etc.

    I can no longer change the style or color of fonts in emails, blogs, forums etc. I can change the font size and nothing else. Everything works when I am connected using explorer so it is a setting or update in firefox that is causing the problem. If I cut/copy and paste into a word document from a web site I still cannot make a change. If I copy from a word document into a web site the colors and fonts revert to some default setting. I have tried changing the setting in Options for the fonts and colors, they make changes but they don't solve the problem.

    Hi,
    Please check if this happens in a [https://support.mozilla.org/en-US/kb/Managing-profiles new profile]. If it's okay, you can later [https://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile?s=profile&r=1&e=sph&as=s copy the personal data] from the old profile. Firefox stores your personal data and settings in another location separate from its [http://kb.mozillazine.org/Installation_directory files/folder]. A new profile would have the default Firefox settings ('''Tools''' ('''Alt''' + '''T''') > [https://support.mozilla.org/en-US/kb/Options%20window '''Options'''] and [http://kb.mozillazine.org/About:config '''about:config'''] ) and usually would also be empty of any '''Extensions''' and themes ('''Appearance''') in '''Tools''' > '''Add-ons''') and their settings. Also, a new profile would have no previous stored website data/settings etc. ('''Tools''' > '''Clear Recent History''').
    [https://support.mozilla.org/en-US/kb/Profiles?s=profile&r=2&e=sph&as=s Profiles Howto]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder & Files]
    [http://kb.mozillazine.org/About:config_entries about:config Entries]

  • Finding Folder Size including subfolders and files

    Hi Friends,
    Could you please Help in getting a Folder size through pure java.The folder contains subfolders and files.I have done rest of the things related to file operation and i can help in other things if you could please help in this regard.
    thanks and regards
    Avanish
    Avanish Kumar Singh
    Software Engineer
    Samsung SDS India Development Center
    Bangalore-560 001
    [email protected]
    [email protected]

    thanks bbrita !
    I too did the way it has given in reply but thats taking huge resource so if you know any direct way to find the directory size please let me know.
    thanks and regards
    avanish

  • I delete some emails ,there are moved to trash . I delete them from trash folder too and they still appear in a folder called 'all messages". I repeat the same actions and after a while they appear again!what should i do to delete them permanently??

    I delete some emails ,there are moved to trash . I delete them from trash folder too and they still appear in a folder called 'all messages". I repeat the same actions and after a while they appear again!what should i do to delete them permanently??

    If you are using Apple's Mail app 6.5 is the latest version irrespective of what a previous poster says. It does sound though that you are using a gmail account online via a web browser. Please confirm and fill in missing information.

  • I have two iPads about a year old and have 5 full folders of web links that I would like to copy from one to the other.  Both have iCloud but not the same account.  Is there an easy way to grab those folders or the icons and email?

    I have two iPad 2 with separate iCloud accounts.  I want to copy folders of weblinks from one iPad to the other.  Email solution?  Answer needs to be written for a user who doesn't know how to select a folder or a number of icons and email or copy them to something that can be emailed.  I know how to do it one at a time by opening weblink and then emailing the link from safari.

    Good idea. I've already used the feedback for my general suggestions to improve the way Apple handles bug reports (and tried sending it to Steve Jobs too), but I'll send a specific suggestion for a bug app on the iPhone.
    However, my question is whether there is a simple way to send bug reports from the iPhone now that I have overlooked.

Maybe you are looking for