jbyrd1981
asked on
USMT to Send email when complete
Hello! I am wondering if there is a script someone could write that would send an email when a machine has finished the User State Migration Tool process? The email should contain Computer name, completed time and possibly fully successful or errors encountered status. Thanks in advance!
ASKER
Thanks Rob... I already have a CMD file that is run to complete the USMT process. I just need to integrate the Email piece into what I already have. Should have been a little more specific. This runs as a vbs file, right?
ASKER
I think I almost have this working but cannot figure out how it is looking for the log file to attach. Which lines of the code pertain to this? Also I don't think I would want to attach the whole log file since it can be MB in size. Can we just pull a few words from the log like this to put in the email? This way it would inform me that there were no errors encountered.
[0x000000] Activity: 'MIGACTIVITY_SUCCESS'
[0x000000] Success.[gle=0x00000091]
Other than that I think I can add and execution statment for this vbs file of my usmt CMD script and it should work just fine.
[0x000000] Activity: 'MIGACTIVITY_SUCCESS'
[0x000000] Success.[gle=0x00000091]
Other than that I think I can add and execution statment for this vbs file of my usmt CMD script and it should work just fine.
Ok. On Monday I'll have a look at pulling summary lines from the log for you.
ASKER
Appreciate it!!! I could probably use it in its current state but would be nice to include this info. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Intergated this beautifully! Your awesome! A couple of questions... Will it still email the clip from the log file if it errored or was a failure indicating so? Also, is there any way to have this zip the log file and attach? If you edit the code to include this would you point out the line(s) related to the zip addition? Thanks again!!!
To perform the zip operation, would you have the ability to use a command line ZIP program like 7-ZIP? It can just sit on a server share without needing installation, just to reference the zipping program.
It would still email the summary as long as the failed lines began with
Activity: 'MIGACTIVITY
Rob.
It would still email the summary as long as the failed lines began with
Activity: 'MIGACTIVITY
Rob.
ASKER
Again!!! Many Thanks! :)
No problem. Thanks for the grade. If you are able to use the 7-Zip command line tool from a server share, you can post another question, and I can have it zip the log file with the email.
Rob.
Rob.
ASKER
No problem... I am giving up the zip idea but thought of one more thing. I was trying to figure out how to get it to include the start time of the USMT in the email as well. If you don't mind what would I need to add to the script to acomplish this? Thanks!
Looking at my USMT logs, the start time is the first line in it, so we'll just add that to the summary.
Under the "Next" line in the code, I have edited the snippet above and added
Regards,
Rob.
Under the "Next" line in the code, I have edited the snippet above and added
strResult = arrContents(0) & vbCrLf & strResult
Regards,
Rob.
ASKER
That worked! Don't understand how but it did. For some reason it is putting weird formatting on the new line. 2014-01-22 12:41:35, Info [0x000000] USMT Started at 2014/01/22:12:41:35.043
Hmmm, odd....maybe there's some special characters at the start of the file. Try changing
to
Rob.
strResult = arrContents(0) & vbCrLf & strResult
to
strResult = Mid(arrContents(0), InStr(arrContents(0), "[0x") - 1) & vbCrLf & strResult
Rob.
Regards,
Rob.
Open in new window