How to auto save output with date added to file name, and email the results?

Hi,
We found a script to capture disk space usage, that automatically places the results into an Excel file. We would like the script to autosave this file to a specific directroy with the date ran as part of teh file name. We would then like these results to
be emailed to us if possible. (also if possible to highlight cell in red that is 5% OR less available disk space would be great)
Here is what we have:
$erroractionpreference = “SilentlyContinue”
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = “Machine Name”
$c.Cells.Item(1,2) = “Drive”
$c.Cells.Item(1,3) = “Total size (GB)”
$c.Cells.Item(1,4) = “Free Space (GB)”
$c.Cells.Item(1,5) = “Free Space (%)”
$c.cells.item(1,6) = "Name "
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit()
$intRow = 2
$colComputers = get-content "C:\Servers.txt"
foreach ($strComputer in $colComputers)
$colDisks = get-wmiobject Win32_LogicalDisk -computername $strComputer -Filter “DriveType = 3"
foreach ($objdisk in $colDisks)
$c.Cells.Item($intRow, 1) = $strComputer.ToUpper()
$c.Cells.Item($intRow, 2) = $objDisk.DeviceID
$c.Cells.Item($intRow, 3) = “{0:N0}” -f ($objDisk.Size/1GB)
$c.Cells.Item($intRow, 4) = “{0:N0}” -f ($objDisk.FreeSpace/1GB)
$c.Cells.Item($intRow, 5) = “{0:P0}” -f ([double]$objDisk.FreeSpace/[double]$objDisk.Size)
$c.cells.item($introw, 6) = $objdisk.volumename
$intRow = $intRow + 1
$d.EntireColumn.AutoFit()
cls
Thank You

Hi Phorbin1128,
The script below amy be helpful for you to save the Excel file with date in filename, and send email with the attachment of the excel report.
$erroractionpreference = “SilentlyContinue”
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = “Machine Name”
$c.Cells.Item(1,2) = “Drive”
$c.Cells.Item(1,3) = “Total size (GB)”
$c.Cells.Item(1,4) = “Free Space (GB)”
$c.Cells.Item(1,5) = “Free Space (%)”
$c.cells.item(1,6) = "Name "
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit()
$intRow = 2
$colComputers = get-content "C:\Servers.txt"
foreach ($strComputer in $colComputers)
$colDisks = get-wmiobject Win32_LogicalDisk -computername $strComputer -Filter “DriveType = 3"
foreach ($objdisk in $colDisks)
$c.Cells.Item($intRow, 1) = $strComputer.ToUpper()
$c.Cells.Item($intRow, 2) = $objDisk.DeviceID
$c.Cells.Item($intRow, 3) = “{0:N0}” -f ($objDisk.Size/1GB)
$c.Cells.Item($intRow, 4) = “{0:N0}” -f ($objDisk.FreeSpace/1GB)
$c.Cells.Item($intRow, 5) = “{0:P0}” -f ([double]$objDisk.FreeSpace/[double]$objDisk.Size)
$c.cells.item($introw, 6) = $objdisk.volumename
$intRow = $intRow + 1
$d.EntireColumn.AutoFit()
$date=Get-Date -f yyyy-MM-dd
$filename = "D:\test\"+$date+".xlsx"
$b.SaveAs($filename)
$a.Quit()
Send-MailMessage -SmtpServer xxxxxxxxxx -To [email protected] -From [email protected] -Subject "test mail" -Body "file name is: $new_file" -attachment $filename
For more detailed information about the cmdlet Send-MailMessage, please refer to this article:
Send-MailMessage
I hope this helps.

Similar Messages

  • How do I make a DVD copy of a file? And does the file have to be converted from mpeg or mp4 or.MOV to a different format before it can be copied and is readable by DVD? Thanks.

    How do I make a DVD copy of a file? And does the file have to be converted from mpeg or mp4 or.MOV to a different format before it can be copied and is readable by DVD? Thanks.

    Great hearing for you all! I thought I was all alone this past weekend. I did learn a lot this weekend. I really like the InDesign product.(half-the-battle) But to be helped by the prestigious “Sandee Cohen” was an honor indeed.”  I ordered the InDesign CC today.  Peter, I appreciate all the feedback on Lynda too. They are loaded with lots of good videos. Derek too honed in on one of the most important aspects!  Since I have been working with Word for most of the first portion of the book this will be a big help. I looked at the comments big help ! Thanks a ton ALL!  Have a wonder day or evening whenever you read this reply.

  • Adding image file name and logo to image

    Can you do batch processing of images to automatically insert the image file name, say at the bottom along with a logo, in black font. The logo stays constant but the image deatils will change with each image?
    Can this be done in Lightroom or then the full Photoshop?
    Thanks!

    I've taken the script mentioned above and modified it to the best of my abilities.  Still getting the same error, unfortunately:
    function main(){
    var suffix ="cropped";
    var docPath =Folder("~/Desktop");
    if(!docPath.exists){
       alert(docPath + " does not exist!\n Please create it!");
       return;
    var fileName =activeDocument.name.match(/(.*)\.[^\.]+$/)[1];
    var fileExt =activeDocument.name.toLowerCase().match(/[^\.]+$/).toString();
    var saveFile = new File(docPath +"/"+fileName+suffix+'.'+fileExt);
    switch (fileExt){
       case 'jpeg' : SaveJPEG(saveFile); break;
       default : alert("Unknown filetype please use manual save!"); break;
    if(documents.length) main();
    function SaveJPEG(saveFile, jpegQuality){
    jpgSaveOptions = new JPEGSaveOptions();
    jpgSaveOptions.embedColorProfile = true;
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgSaveOptions.matte = MatteType.NONE;
    jpgSaveOptions.quality = jpegQuality; //1-12
    activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);

  • Auto Save Form with Data

    Hi All ,
    I have a BSP which is stateful and no MVC. My production server has a sesison timeout of 15 mins. I need to autosave my form and send this data to a Ztable. Can u help me out in solving this...
    awaiting eagerly...
    Regards,
    Guru

    Hi Guru,
    user the setTimeout function to call a function that submits your form.
    An example can be found at http://www.plus2net.com/javascript_tutorial/timer-set.php
    Cheers
    Graham Robbo

  • How to edit inbound idoc with data errors in multiple segments and reproces

    Hi friends,
    i have a requirement for error handling of inbound sales order(ORDERS04) without using WORKFLOW and WE19.
    i have seen some function modules like edic_* ..
    but my doubt is how to edit the error data(how can i identify the particular error fileds in the segments)and how to reprocess the same idoc.
    Please help me...
    Thanks in advance

    Hi Narasimh,
    Please find the following steps to edit IDOC segment after you find the error using WE02.
    The example codes can be found in website 
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    STEP 1 - Open document to edit
    CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT'
           EXPORTING
                document_number               = t_docnum
           IMPORTING
                idoc_control                  = itab_edidc
           TABLES
                idoc_data                     = itab_edidd
           EXCEPTIONS
                document_foreign_lock         = 1
                document_not_exist            = 2
                document_not_open             = 3
                status_is_unable_for_changing = 4
                OTHERS                        = 5.
    STEP 2 - Loop at itab_edidd and change data
    LOOP AT itab_edidd WHERE segnam = 'E1EDKA1'.
      e1edka1 = itab_edidd-sdata.
      IF e1edka1-parvw = 'LF'.
        e1edka1-partn = t_eikto.
        itab_edidd-sdata = e1edka1.
        MODIFY itab_edidd.
        EXIT.
      ENDIF.
    ENDLOOP.
    STEP 3 - Change data segments
    CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENTS'
               TABLES
                    idoc_changed_data_range = itab_edidd
               EXCEPTIONS
                    idoc_not_open           = 1
                    data_record_not_exist   = 2
                     OTHERS                  = 3.
    STEP 3a - Change control record
    CALL FUNCTION 'EDI_CHANGE_CONTROL_RECORD'
           EXPORTING
                idoc_changed_control         = itab_edidc
           EXCEPTIONS
                idoc_not_open                = 1
                direction_change_not_allowed = 2
                OTHERS                       = 3.
    STEP 4 - Close Idoc
    Update IDoc status
    CLEAR t_itab_edids40.
      t_itab_edids40-docnum      = t_docnum.
      t_itab_edids40-status      = '51'.
      t_itab_edids40-repid       = sy-repid.
      t_itab_edids40-tabnam      = 'EDI_DS'.
      t_itab_edids40-mandt       = sy-mandt.
      t_itab_edids40-stamqu      = 'SAP'.
      t_itab_edids40-stamid      = 'B1'.
      t_itab_edids40-stamno      = '999'.
      t_itab_edids40-stapa1      = 'Sold to changed to '.
      t_itab_edids40-stapa2      = t_new_kunnr.
      t_itab_edids40-logdat      = sy-datum.
      t_itab_edids40-logtim      = sy-uzeit.
      APPEND t_itab_edids40.
      CALL FUNCTION 'EDI_DOCUMENT_CLOSE_EDIT'
           EXPORTING
                document_number  = t_docnum
                do_commit        = 'X'
                do_update        = 'X'
                write_all_status = 'X'
           TABLES
                status_records   = t_itab_edids40
           EXCEPTIONS
                idoc_not_open    = 1
                db_error         = 2
                OTHERS           = 3.
    Hope this will help.
    Regards,
    Ferry Lianto

  • How to get target file name and buffer the incoming messages?

    Hi Experts
    I have one scenarion like
    I wanted to find whether is there any file existing in target folder. If it exists I dont want to overwrite it but I have to buffer the incoming messages in some queue or something like that. And when ever the request comes next time I have to send the data buffered in queue first.
    I dont want to add any time stamp for target file to avoide duplication.
    Can we do this using XI. If yes please suggest me how to achive this.
    Regards
    Sowmya

    >
    Sowmya wrote:
    > Hi Experts
    >
    > I have one scenarion like
    > I wanted to find whether is there any file existing in target folder. If it exists I dont want to overwrite it but I have to buffer the incoming messages in some queue or something like that. And when ever the request comes next time I have to send the data buffered in queue first.
    >
    > I dont want to add any time stamp for target file to avoide duplication.
    >
    > Can we do this using XI. If yes please suggest me how to achive this.
    >
    >
    > Regards
    > Sowmya
    there is no standard way to achieve this. I suggest a redesign.
    post the files to a different directory and write a script which will move the file to the required target directory only if it is not present there.

  • How do i delete music with grayed titles in my iphone and ipad. iTunes Match is on

    how do i delete music with grayed titles in my iPhone and iPad. the grayed titles happened when i installed iTunes Match.

    I've done the reset iTunes Match routine turning it on or off in my devices. Everytime its On, it goes thru d scan, match and upload process. When it gets to tge upload stage, it takes sooooo long for just one song to upload, as if d remaining song (2k+) will take years. Anyway, the grayed titles still don't go away. These titles are not exactly missing. I can play those titles because they also appear in my devices as regular content - meaning, the grayed titles are duplicates but don't go away.
    By the way, these grayed titles are viewable only in iTunes Match not on my devices (iPhone 4 and ipad2)

  • Running 10.6.8 with quicken 2006.  Would like to upgrade to a new machine/software.  How can I save my quicken data?

    Would like to upgrade to a new Macbook Pro machine/software.  How can I save my quicken data from quicken 2006?

    Users have reported that Quicken 2015 for Mac is an upgrade of the generally loathed Quicken Essentials for Mac.
    I recommend you continue your Quicken operating experience by purchasing Quicken 2007 for Mac directly from Intuit for $15.  It will open your Quicken 2006 file and operate as you have before.
    To obtain Quicken 2007 for Mac for $15:
    Use the chat feature for Quicken for Mac: Quicken 2007 for Lion: Shopping and Buying: Buying Quicken on this page

  • How do I save a PDF as an excel file when the PDF is horizontal. Adobe tries to rotate the page, but the data is entered in an  horizontal format.

    How do I save a PDF as an excel file when the PDF is horizontal. Adobe tries to rotate the page, but the data is entered in an  horizontal format.

    Thanks for the quick reply.  I figured out how to get the desired results by using tagging.  For anyone who may reference this post in the future, I went to "Customize" in the top right corner of Adobe, then selected "Create new tool set...", looked under "accessiblity and found the "tag" option.  Hit ok, tag is added to the toolbar.  Then I highlighted the dataset in the PDF that was relevant to the output format, then clicked "tag", saved as spreadsheet.  Sorry I can't provide more details on how tagging works or if there's a more elegant solution available, but I'm sure one's out there.

  • HT4753 Can auto save work with Photoshop 5.0?

    Can auto save work with Photoshop 5.0?
    [email protected]

    No. Autosave/Versions must be built into the app itself to use those OS features. It doesn't work just because it's part of the OS. None of the CS6 apps support it, either. The only Adobe apps that do are the latest versions of Photoshop Elements and Premiere Elements. And that's only because the have to in order to be allowed in the App Store. In both cases, Adobe also gives users a preference to turn it off.
    What Adobe did do in Photoshop CS6 is add an autosave feature of their own. It saves your work according to whatever time increment you choose. Then if the app crashes, it will try to reopen the saved data when you relaunch the app.

  • How can I copy songs with metadata (added in iTunes) from my PC to my new iMac?

    I have iTunes 12.0.1 on my Windows PC. I'm about to get a new iMac (hooray!) and I'm beginning the process of transferring everything on my PC to my Mac. I've got all the documents, pictures, files, etc. covered, but now I have to make a copy of all of my music.
    Most of the music in my iTunes library is not bought through the iTunes Store (I download most of my songs from the Internet). Then, after saving the downloaded song to my computer, I go into iTunes on my computer and add the song. I also add metadata like artist, album, genre, album artwork, etc. to the song in iTunes. What concerns me is that only the songs in iTunes have this metadata: the original downloaded files I saved onto my computer don't have any metadata.
    I really don't want to have to go through the long and tedious process of adding artist/album names, genre, etc. to every single song in my iTunes library on my new iMac. How can I copy songs with metadata (added in iTunes) from my PC to my new iMac?
    Thank you so much for any help!

    Hello! I'd like to learn more about Home Sharing. To do this, would both my PC (which I hope to get rid of) and my new iMac need to be plugged in?
    Also, after Home Sharing with the old PC is initiated, I understand that all my songs would appear on my iMac. Is there a way to copy all of these (with album artwork, name, artist, etc.) directly to the iMac's hard drive and then disconnect home sharing so I can get rid of my PC?
    Thank you!

  • How do I save attachments with an E Mail?

    How do I save attachments with an E Mail?

    Hover the mouse at the top of an email with an attachment, in the area shown in the image below, and it should reveal the attachments icon - select it and download the attachments to wherever you wish on your HD.

  • How to use MAX() function with date field

    Hi Frzz,
    I have created a Graphical calculation view in which i have multiple records for each employee with different dates. But my requirement is to take the records which have maximum date.
    I have converted the date into Integer and applied the MAX() function. But still am getting multiple records.
    Is there is any other way we can achieve this requirement in Graphical Calculation view??  Your suggestion will really help me.
    Thank  you.
    Krishna.

    Hmm... what have you tried out so far?
    Look, I took the effort and created a little example, just for you
    Assume we have a table that contains the logon dates of users.
    Every line contains the logon date and some info on the user.
    Very much like a not-normalized log file could look like.
    Now, the output we want is: one line per user with the most current logon time.
    Not too difficult:
    1. Have a aggregation node that gives you the distinct user details - one line for every user:
    2. Have another aggregation node that gives you the last (MAX) logon date per user:
    Finally you do a 1:1 join on the USER_ID and map the result to the output.
    Easy as pie
    - Lars

  • How to use TRUNC function with dates in Expression Builder in OBIEE.

    Hi There,
    How to use TRUNC function with dates in Expression Builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
    Thanks in advance

    use this instead:
    TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE)

  • HT1553 i am upgrading my 2008 macbook to an ssd drive and want to save my settings. how do i save then? I have my files backed up with time machine ,but dont want to restore all files ,as there might be some junk backed up too. Help will be appretiated

    i am upgrading my 2008 macbook to an ssd drive and want to save my settings. how do i save then? I have my files backed up with time machine ,but dont want to restore all files ,as there might be some junk backed up too. Help will be appretiated

    When you restore from a Time Machine back up you can pick and chose what is restored. It is not an all or nothing process. Nor do you have to do the partial restores all at the same time. If days after the first partial restore you find something else you want you can restore just that.

Maybe you are looking for

  • How to generate a single output pulse on 64 different digital out lines (PCI-6513) each with a different start time relative to an event in a main program loop.

    Long question. I am running a main program loop of 60 msec. At one point in the loop I create a 64 element array of delay times. At that point I need to begin outputting a predefined single pulse to each of the 64 lines on my PCI-6513. Each line outp

  • Adobe slow to open PDF with digital signature

    Hi, We have recently added a digital signature to our PDF reports for security. Adobe takes an age to open the PDF on some PC's but instant on others. Can anyone offer any assistance to this problem. Thanks.

  • Error connecting to HDD on my router

    I am running Mountain Lion on MacBook Air. I have a HDD connected to my router (A Technicolor VDSL Wifi Modem). I can Connect to the HDD from both my PCs, however the Mac cannot. I have read a lot about this and am very confused. I get the following

  • Upgraded 5600 to 5700 killed clone overlay

    I just upgraded from a 5600 to a 5700. With the 5600 and the 61.77 driver the clone mode identically overlayed the video in both my primary digital screen and my analog screen. In other words, I did not have to use "full screen" on the secondary to s

  • Mapping fields on TR

    Hi Friends I am extracting 3 fields (partnr, roletyp and sobjekt) from vdgpo.Now i want to map the fields partnr and sobjekt based on roletyp. If roletyp = TR0120 then zauthdrawer = vdgpo_partnr. If roletyp = TR0992 then zstateclk = vdgpo_partnr. If