Script to parse last 24 hours from TaskScheduler Log Cannot figure out how to prase a single task.
All,
I've been tasked with parsing a single task from a server scheduled task and email that to a couple individuals and a distribution list. I had the email portion working, and am now getting...
‘You cannot call a method on a null-valued expression.
$smtp.Send(&msg)
It is defined ‘$msg = new-object Net.Mail.MailMessage’
I also need to parse out only a specific task in the log. I have tried everything that I can think of and find to get to that level, but this is my first attempt at PowerShell. Here is what I have so far.
# Written by Shawn Miller #
# Parse Task Scheduler Log and #
# Email log to Regional Support #
# and End-Users #
# 4 FEB 14 ver. 1 #
# Parse scheduler log and create file
$yesterday = (get-date) - (new-timespan -day 1)
$events = get-winevent -FilterHashtable @{logname = "Microsoft-Windows-TaskScheduler/Operational"; ID = "201","202"; StartTime = $yesterday} | Format-List -Property Message | out-file "c:\stuff\test.log"
$events |foreach {
$_
# Create new email
$smtpServer = “phcmail.peabodyenergy.com”
$msg = new-object Net.Mail.MailMessage
#From Address
$msg.From = "Monitoring Admin <[email protected]>"
#To Address, Copy the below line for multiple recipients
$msg.To.Add(“[email protected]”)
#$msg.To.Add(“[email protected]”)
#$msg.To.Add(“[email protected]”)
#$msg.To.Add(“[email protected]”)
#Message Body
$msg.Body=”Attached is the status report for the EoM Midwest Engineering files copied to STLEN1.”
#Message Subject
$msg.Subject = “EoM Transfer report”
write-host "SENDING FILES"
#your file location
$files=Get-ChildItem “C:\Stuff\report\”
Foreach($file in $files)
Write-Host “Attaching File :- ” $file
$attachment = New-Object System.Net.Mail.Attachment –ArgumentList C:\Stuff\report\$file
$msg.Attachments.Add($attachment)
$smtp.Send($msg)
$attachment.Dispose();
$msg.Dispose();
write-host "Mail Sent Successfully"
Any help would be greatly appreciated.
Respectfully,
Shawn
I would use PowerShell to do this but you need to fix a lot of the code you have copied from various places. Most of it is old.
Start with this:
#Parse scheduler log and create file
$yesterday =[DateTime]::Today.AddDays(-1)
get-winevent -FilterHashtable @{logname = "Microsoft-Windows-TaskScheduler/Operational"; ID = "201","202"; StartTime = $yesterday} |
Format-List -Property Message |
out-file c:\stuff\test.log
$mailprops=@{
SmtpServer='phcmail.peabodyenergy.com'
From ='Monitoring Admin <[email protected]>'
To='[email protected]','[email protected]'
Body='Attached is the status report for the EoM Midwest Engineering files copied to STLEN1.'
Subject='EoM Transfer report'
$files=Get-ChildItem C:\Stuff\report\
Send-MailMessage @mailprops -Attachments $files
write-host "Mail Sent Successfully"
It is more likely to work assuming you have access to an SMTP server which is not likely in a domain. Check with your domain admins to find out how to gain access.
¯\_(ツ)_/¯
Similar Messages
-
I purchased an audio book from itunes and cannot figure out how to get it on my nano 7. I have tried everything.
Have you double checked to make sure these Audiobooks are configured to sync to your iPod from under the iPod's Books configuration tab in iTunes? This is assuming that the audiobooks are already stored in your iTunes library and appear under the Books category.
To access this configuration tab, plug in your iPod and select it from under the Devices section in the left hand pane of iTunes to bring yourself to the iPod's Summary tab. Now locate the Books tab across the top in the main iTunes window and select it. Here you can configure what and how audiobooks are synced to the device.
If you make any changes to this tab, make sure to hit the Apply button on in the lower right hand corner. This will sync the updated changes to your device.
B-rock -
got a new wireless connection for my mac and cannot figure out how to delete the last connection service I had. Everytime I shut the computer, the network goes back to the other one. I cannot find the file ANYWHERE
Under Network Preferences, select the WiFi
click on "Advanced..." button
Select the network you want to delete from the list and click on "-"
Click "Ok"
Click "Apply"
Well done ;-)
You may also want to delete the wireless key from Keychain.
Open Keychain, seach for the old wifi network name, slect it and click delete -
I moved some iTunes TV shows from my PC hard drive to an external drive. I can watch them as long as the external drive is plugged in, but I now want to move them back to my PC to watch from the internal drive, but cannot figure out how to do it. Can anyone help? Thanks in advance.
Is it just the TV Shows that you moved to the external, or did you consolidate all your media there?
What is the current location of the media folder given under Edit > Preferences > Advanced?
If the media folder is currently pointed to a folder on the internal drive you could select the files you want to copy, then right-click and select Consolidate Files from the pop-up menu. This will leave the originals behind. If you want to move specific files to a new media folder then my script ConsolidateByMoving can do this.
tt2 -
I have an iphone 4 which quit working and I had my iphone 3 reactivated until I get my 4 replaced or fixed. My computer does not recognize my iphone 3 when I plug it in. I also cannot figure out how to apply my last backup to my iphone 3
If your iPhone 4 was running iOS 5, you can't install iOS 5 on an iPhone 3G which means you can't restore the 3G from the backup of the iPhone 4 running iOS 5.
http://support.apple.com/kb/TS1538 -
I have an apple iphone 4 that I want to download audio books from my library onto. I cannot figure out how to do that. The iphone does not show up on my mac laptop as a connected device. Does this kind of download have to run through itunes? Thanks
Yes it is done through iTunes. The iPhone will never show up in Finder as a device. The following is general information on iTunes sync: http://support.apple.com/kb/HT1386 and the following is a previous discussion where the post by Andreas Junge helped others that had a problem syncing audiobooks: https://discussions.apple.com/message/20052732#20052732
-
I'm a seller on eBay and very new to Mac. I just started to list an item when I got to the area of uploading pictures of an item to my listing. I cannot figure out how this is done. I downloaded pictures from my camera to iPhoto and they apear not only in my iPhoto library but in an eBay folder/album I created. When I go to upload photos I cannot find my photos in either the Library or the eBay album. I've tried using both the basic uploader and and standard uploader choices provided by eBay.
While running iPhoto you'll need to select the pictures you want to use for eBay and then select Export from the File menu. The Export Dialog box has several options and I believe the second option is File Export - that's the option you want to choose. Now you can select the picture quality, size, and export. The file selector will appear so you can indicate the folder you want the pictures to be exported into. Now you can take the next step, sending them to eBay.
-
I have a new iMac running iTunes 10.4 in OS 10.6.8, and a new Mac Air running iTunes 10.4 in Lion. I was able to transfer all my music etc. from the iMac onto the Air, but cannot figure out how to get the Playlists from the iMac to the Air. iTunes Help says File >Library >Export playlist and choose XML, or to save a copy of all your playlists, File > Library > Export Library, "the Exported info is saved in XML format." Then it says, "to import an iTunes playlist, File > Library > Import Playlist". Now I am assuming I do that import part on the Air, but when I try it doesn't recognize anything that can be imported - what am I missing??? Aside from a clue...
Thanks, Jim, for taking the time, but the reply is unfortunately vague in the exact area of my confusion! "you need to copy that file to your new computer..." Well, the Import/Export instructions make it seem as if the two computers should be able to communicate this file thru wifi, but that's the linkage I can't seem tocreate with Import/Export. Should I instead email a copy to myself (thats what applecare suggested)? Copy it to and from a thumb drive? But then place the file where? And the article was helpful, but should I be trying to move the Library file or the Library.xml file (as iTunes Help suggests)? Sorry to be so clueless about it...I suppose I buy Apple in the hopes of not having to think about this stuff, which approach seems not to be serving me well. Thanks again for your time!
-
The first time I synced my iphone 4 with my mac, I didn't realize that all of my photos from the iphoto library would transfer over to the phone (more than 3,000). Now, I need to remove some, as they are taking up too much space. I cannot figure out how to remove them from the phone. I tried to uncheck boxes and sync again, but I get a message that there is no room on the iphone. I've read as many articles as I can find, but still cannot manage this. Thanks for any help.
Open itunes, connect iphone, select what you want, sync
-
just bought an ipod nano and cannot figure out how to sync the music from itunes onto it. i go to itunes and nothing happens. Is there a sync button im not seeing? I get my playlisits but that is it.
ALSO does anyone know how to have 2 ipods on 1 computer but seperate?Hi there,
I would recommend taking a look at the information found in the articles below. The first two articles have the same content, but are geared towards either OS X or Windows.
iTunes 11 for Windows: Set up syncing for iPod, iPhone, or iPad
http://support.apple.com/kb/PH12313
iTunes 11 for Mac: Set up syncing for iPod, iPhone, or iPad
http://support.apple.com/kb/PH12113
How to use multiple iPhone, iPad, or iPod devices with one computer
http://support.apple.com/kb/ht1495
-Griff W. -
I am a new iPad user. I cannot figure out how to copy and paste from a website to a pages document, and vice versa. Any ideas?
Long press on the text you would like to select (tapping and holding) and then release after the magnifying glass shows up. This will select a single word. Then use the blue dots and drag them to select a region of test. Then press "copy". Open pages, and long press and release where you would like to paste. Then select "paste". That should paste the text.
If the text doesn't select within the browser, it might be an uncopyable format. Like if the text was within an image, naturally you would be unable to select it. The only thing to do there is long press the image and selecting "save image", adding it to your camera roll. Then you could insert the image within pages. -
I am trying to import my itunes library from my old gateway computer to a new imac. I cannot figure out how to export the library from the gateway computer to a flash drive to transfer.
Copy the entire /Music/iTunes folder to /Music/ on the new computer.
That is all you need to do. -
I am new to Lightroom and have also just changed from Apple to PC. I cannot figure out how to download photos from the Photoshop library to a file that will be sent to MPIX for processing. Also, does Lightroom have an easy access to a photo processing capability such as MPIX?
Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps. -
I want to change my apple id primary e-mail from a .msn address to a .gmail address. The problem is that currently my .gmail address is my recovery address; I cannot figure out how to remove and replace my gmail recovery address with a new e-mail address. I want to do this because I no longer use my .msn address.
You should be able to change your rescue address by going to My Apple ID, signing in to manage your ID, then selecting the the Password and Security section, and answering the two security questions. If you have trouble with this, contact the Apple account security team for your country to verify your identity and ask for assistance: Apple ID: Contacting Apple for help with Apple ID account security. If your country isn't listed, contact iTunes store support by filling out this form: https://www.apple.com/emea/support/itunes/contact.html.
-
my wife somehow removed the address bar/toolbar from the page - i cannot figure out how to get it back
In Firefox 3.6 and later on Windows you can hide the "Menu Bar" via "View > Toolbars" or via the right-click context menu on a toolbar.
Press F10 or press and hold the Alt key down to bring up the "Menu Bar" temporarily.
Go to "View > Toolbars" or right-click the "Menu Bar" or press Alt+V T to select which toolbars to show or hide (click on an entry to toggle the state).
See also [[Menu bar is missing]] and http://kb.mozillazine.org/Toolbar_customization
Maybe you are looking for
-
How to access external drives while in Windows
Using VMWare Fusion as the system hosting Windows XP. Have specific programs in Windows only but of course they work much better on the IMac. I edit a ton of video and have the vids all stored on eternal drives. These drives are read by the Mac and a
-
Target file of the same name as source file
Hi, I am working on a file to file scenario. I need the target file name to be same as the source file name. I checked the adapter specific message attributes in the sender as well as receiver file adapter,and also checked the file name.
-
My monitor looks like a negative. My text is white and the background is black. I looked through the system preferences to convert it back and can't seem to figure it out. I also looked through this website and couldn't find in any information. Can s
-
Keynote Remote Doesn't work with iPhone, iPad
Hi, I have the latest versions of Keynote on my iPhone 5S, iPad 4 and MacBook Pro 13" with Retina Display. All three devices on the same WiFi network. Using WiFi I was able to remotely control/play the presetatnion between iPhone 5S and MacBook. Howe
-
Hi, I am trying to use a custom class loader to dynamically load Java classes so that I can get some info (e.g. methods) about the classes via reflection. My problem is that my class loader is written to load Java core classes (i.e. java.lang, java.u