Friday, March 4, 2011
Useless Data: Average Daily Work E-mail Volume
Saturday, January 15, 2011
Google Reader + Craig's List = Lazy Happiness
Do you dread searching and sifting through Craig's List for things you're interested in buying (or selling)?
Only interested in items with a photo posted?
Only interested in items below a certain price?
Do you have a Google (Gmail) account? Do you use Google Reader? If not, you should. It's one of the best web-based RSS/Atom feed readers in the known Universe.
Here's how I do it:
- Go to Craig's List and click on a category.
- Open the Search page and enter a search criteria ("search for"), select the category (e.g. "Computers & Tech"), select "Title Only" or "Entire Post", fill-in the desired price ranges (if desired), and check the "Has Image" option.
- Click Search
- If the results look like what you wanted it to find, scroll to the very bottom and click the RSS link (bottom right)
- Paste that URL into your Google Reader subscriptions
- Done!
Now you can have all the search results automatically come to your Google Reader folder without having to go anywhere else. You can add other search results as RSS feeds also.
Shifting Gears: From Twitter to Gmail
I posted some articles in the past on how to leverage Twitter for sending and receiving systems alerts using Direct Messaging (DM). That was using Basic Authentication, not the newer (current) OAuth model. But regardless, the biggest annoyance with that approach was Twitter's downtime and backlog. Some alerts wouldn't show up for almost a half hour. Some never showed up. Even the inverse approach of sending DM tweets to an account monitored by my server suffered the same hinderances.
The better approach? GMail. Yes. GMail. Using standard SMTP commands with CDO and pretty much ANY SCRIPT language you prefer, you can get and send e-mail, and it is infinitely more reliable and prompt.
Here's a sample chunk of VBscript code to try for yourself…
strSubject = "Test Message"
strMessage = "This is a test message"
sender = "YOUR NAME <your_address@GMAIL.COM>"
recipient = "someone@somewhere.com" ' or put in a SMS address like "8005551212@vtext.com"
On Error Resume Next
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
If err.Number <> 0 Then
wscript.Echo "error: unable to invoke CDO interface"
wscript.Quit(1)
End If
Set Flds = iConf.Fields
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 465
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "UserName"
Flds.Item(schema & "sendpassword") = "Password"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
wscript.echo "info: sending smtp message..."
With iMsg
.To = recipient
.From = sender
.Subject = strSubject
.HTMLBody = strMessage
.Sender = " "
.Organization = " "
.ReplyTo = " "
Set .Configuration = iConf
SendEmailGmail = .Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
wscript.echo "info: message was sent"
This is easy enough for outbound work: sending alerts. For doing the opposite, you'll need to set up a dedicated Gmail account for your server to monitor the Inbox and parse what it finds. Same basic concept as the Twitter DM approach, but using SMTP (and/or SMS) instead.
In case you don't feel like digging back and reading old blog posts, some of the things you can do on the inbound side are rather interesting (and empowering):
- Enable or Disable AD (or local) user accounts
- Unlock user accounts
- Add or Remove user accounts within AD security Groups
- Move accounts around
- Start and Stop services
- Initiate secondary automation processes (manual kick-off)
And so on. Since all this does is set your server up to read specially-formatted Inbox messages and take action on them, you can make it do whatever you want. The world (or at least your data center) is your oyster.
Friday, December 24, 2010
Top 10 Blog Readings of 2010 and What's Ahead
Taking a que from Ed Bott's recent blog post, I decided to analyize my Google Analytics to see what the top-ten most read blog articles were for 2010. My blog has picked up in 2010 for sure. I abandoned it twice before, due to falling readership and lack of time to spend on it. I still don't have much time, but with the traffic increases this year, I have tried my best to keep it going and keep it interesting. I hope it is interesting for you.
And now I will open the envelope…
- Windows 7, MSG.EXE and Group Policy Preferences
- Packaging DWG TrueView 2011
- Windows 7 GPEDIT Changes *
- Don't Forget to Mop Up *
- Packaging & Deployment Autodesk 2011 Products with System Center Configuration Manager 2007
- Enabling Windows 7 Remote Management via Group Policy *
- Using PowerShell with an MS-Access Database
- What does the AutoCAD "PURGE" Command Do?
- Packaging DirectX 9.0c as an MSI
- Uninstalling AutoCAD LT 2011 with SCCM 2007 **
- (Honorable Mention) Deploy Autodesk Design Review 2011 with SCCM 2007
- (Honorable Mention) Scripting with Glue and Tape *
* Article was actually posted in 2009 but ranked in the top-10 most-read for 2010
** Autodesk posted a script to perform the same action but with more meticulous attention to detail, so I have to recommend readers to use that instead of what was posted on article marked
What's Ahead
I finished up two e-books and set them out on the waters of Amazon just in the past month. So far they've done pretty well. Now I have to figure out what to do next. I'm sure I will publish updated editions to both of them sometime in 2011, but I'd also like to produce something new. I'm open for suggestions on either of these endeavors (so drop me a line at ds0934 at gmail dot com)
I know I recently posted a list of current projects, but I left a few out:
- Working with managing MED-V clients with SCCM and Scripting
- Aggregating information from SCCM, SQL and Active Directory for a web application
- Spinning up on Sharepoint Foundation 2010 and Search Server Express for a client project
- Testing a Google Chrome Notebook
- Reading a crap-load of books on my Kindle (I love that little gadget!)
- Trying not to ignore my wife, kids and dog (I try)
- Improving my diet and getting back to exercising (walking, bike riding, etc.)
- House and car repairs (plenty of that waiting for me already)
- Doing a better job at everything I do (continuous improvement)
- Helping others wherever I can
For now, I'm going to take a few days off to spend with my family. So I'd like to say to you…
Merry Christmas! Happy Holidays!
Best wishes to you, your families and loved ones!
Tuesday, October 12, 2010
Lonely? Make Your Tasks Talk Back to You
The Windows Vista and Windows 7 “MSG.exe” command is the newest replacement for the old “NET SEND” command. It has a nice, simple syntax, and works pretty well unless you shut down services it relies upon. You probably don’t want to overdo the use of MSG, so use it sparingly (with regards to automated/unattended tasks).
So you could drop this into a “special” script or package to notify you whenever it runs. I know of quite a few times when this has come in handy (in fact I’ve used my infamous Twitter script to tweet me when a job runs as well, or add to a script).
Example
@echo off
msg JohnDoe /SERVER:MyComputer setup has been initiated
...
msg JohnDoe /SERVER:MyComputer setup has completed
Monday, April 26, 2010
Windows 7, MSG.EXE and Group Policy Preferences
So, as of Windows Vista, NET SEND is gone. But you want to send a console message via popup to a remote user or computer? Windows Vista shipped with the MSG.EXE utility, which is still around in Windows 7. But there’s a small problem, which led me to another small problem, but thankfully there’s an easy solution.
Problem 1 – You may need to modify a Registry Value on all your networked Windows 7 computers.
- HKLM\SYSTEM\CurrentControlSet\Control\TerminalServer
- Value: AllowRemoteRPC
- Required value: 1 (REG_DWORD)
Problem 2 – Trying to set that on a remote Windows 7 box
The Remote Registry service is disabled by default. You can start turning on services manually, but…
Solution – Use Group Policy Preferences to do it all at once
- Create a new GPO named something that makes sense
- Edit the new GPO
- Expand Computer Configuration / Preferences / Windows Settings
- Click on Registry
- Right-click and select New –> Registry Item
- Select Action: Update, Hive: HKEY_LOCAL_MACHINE
- Key Path: browse to the key shown above
- Select the Value name: AllowRemoteRPC
- Set the Value data: 1, specify type REG_DWORD
- Click OK
If you also want to enable remote Registry editing…
- Expand “Control Panel Settings”
- Select “Services”
- Right-click and select New –> Service
- Startup: Automatic, Service Name “Remote Registry”, Service Action: Start Service
- Click the Recovery tab
- Specify First and Second failure action as “Restart the Service”
- Specify Restart fail count after to 1 day, Restart service after 1 minute
- Click OK
Wednesday, August 12, 2009
Fetching Twitter Direct Messages Using VBScript or KiXtart
Thanks to the Twitter API documentation (which is lacking examples) and the MSDN reference library on using MSXML/XMLHTTP methods, I’ve put together a simple script to query your Twitter DM inbox and fetch the 20 most recent items (that’s the built-in default of the Twitter API, by the way). Enjoy!
VBscript Example:Const username = "MyTwitterUserName"
Const password = "MyTwitterPassword"
Function Twitter_Get_Direct(strUser,strPass)
Dim oXml, strTwitterURL : strTwitterURL = "http://twitter.com/direct_messages.xml"
Set oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXml.Open "GET", strTwitterURL, False, strUser, strPass
oXml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXml.Send()
Twitter_Get_Direct = oXml.responseText
Set oXml = Nothing
End Function
result = Twitter_Get_Direct(username, password)
wscript.echo result
KiXtart Example:
$username = "MyTwitterUserName"
$password = "MyTwitterPassword"
Function Twitter_Get_Direct($strUser,$strPass)
Dim $oXml, $strTwitterURL
$strTwitterURL = "http://twitter.com/direct_messages.xml"
$oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
$oXml.Open("GET", $strTwitterURL, 0, $strUser, $strPass)
$oXml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oXml.Send
$Twitter_Get_Direct = $oXml.responseText
$oXml = 0
EndFunction
$result = Twitter_Get_Direct($username, $password)
? $result
I could probably post this in PowerShell also, but nobody seems to care, so unless someone asks I won’t bother. Anyhow: putting this together with the previous examples and blog rants, using a little duct tape and glue, you can assemble a nifty little system for monitoring remote servers using Twitter, as well as sending control commands to the remote server to execute. That’s right. You can use the above script on a server to fetch DM messages and process them. I’ll leave that to your imagination, but it does work and is pretty simple to do. The only caveate is Twitter availability (not very good) and how robust you want to make the contraption. Cheers!
Sunday, August 9, 2009
Sending a Twitter Direct Message using VBScript and KiXtart
There are quite a few examples on the web for sending Tweets to your own timeline using scripting and Curl, etc. However, I didn't find a lot of helpful examples on sending direct messages via Twitter using VBscript or KiXtart, so here's what I figured out and it seems to work. For more information on using the Direct_Messages.New API methods, refer to the Twitter API. Enjoy!
VBScript Version
Const username = "MyTwitterUserName"
Const password = "MyTwitterPassword"
Const recipient = "skatterbrainz"
Function Twitter_Send_Direct(strMsg, recipient)
Dim oXml, strTwitterURL
strTwitterURL = "http://twitter.com/direct_messages/new.xml"
Set oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXml.Open "POST", strTwitterURL, False, username, password
oXml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXml.Send "text=" & strMsg & "&user=" & recipient
Twitter_Send_Direct = oXml.responseText
Set oXml = Nothing
End Function
msg = "Test Message (sent from vbscript)"
result = Twitter_Send_Direct(msg, recipient)
wscript.echo result
KiXtart Version
break ON
$username = "MyTwitterUserName"
$password = "MyTwitterPassword"
$recipient = "skatterbrainz"
Function Twitter_Send_Direct($strMsg, $recipient)
Dim $oXml, $strTwitterURL
$strTwitterURL = "http://twitter.com/direct_messages/new.xml"
$oXml = CreateObject("MSXML2.ServerXMLHTTP.3.0")
$oXml.Open("POST", $strTwitterURL, 0, $username, $password)
$oXml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oXml.Send("text=$strMsg&user=$recipient")
$Twitter_Send_Direct = $oXml.responseText
$oXml = 0
EndFunction
$msg = "Test Update (sent from kixtart script)"
$result = Twitter_Send_Direct($msg, $recipient)
? $result
Note the wrapping of arguments with matching parenthesis (…) when using KiXtart. This is not required for VBScript. A small but important thing to keep in mind if you use both languages (as I do quite often). Another “feature” which I have mentioned in previous posts, is that KiXtart supports inline string/variable expansion, so you can bury variables within strings and they work fine, which is nice. PowerShell and some other languages can do that, but not VBScript.
Sunday, June 28, 2009
Using GMail for CDOsys SMTP Relaying
I am in the process of moving one of my externally-hosted web sites to an internal host on my home network. But one of the problems I’ve been working on is how to continue sending e-mail messages without setting up my own SMTP relay host. I wanted to be able to make the process portable, so it could be used on any host as long as the server has an active Internet connection. Thanks to a post on Google Groups, I was able to do this. I’ve taken that code example and made it into a SUB so it’s a little easier to re-use as well. A small but useful modification…
'----------------------------------------------------------------
' function: send cdosys message using GMail as SMTP relay host
' from: http://groups.google.com/group/hosted-the-basics/browse_thread/thread/c6cc889c9db0a02b?pli=1
'----------------------------------------------------------------
Sub SendGmail(RecipientEmail, SenderEmail, Subject, msgBody, msgFormat)
On Error Resume Next
Dim SMTPServer, SMTPusername, SMTPpassword
SMTPserver = "smtp.gmail.com"
SMTPusername = "YOU@gmail.com"
SMTPpassword = "YOUR_PASSWORD"
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "smtpauthenticate") = 1
.Item(sch & "smtpusessl") = True
.Item(sch & "smtpserver") = SMTPserver
.Item(sch & "sendusername") = SMTPusername
.Item(sch & "sendpassword") = SMTPpassword
.Item(sch & "smtpserverport") = 465
.Item(sch & "sendusing") = 2
.Item(sch & "connectiontimeout") = 100
.update
End With
Const cdoSendUsingPickup = "c:\inetpub\mailroot\pickup"
Set cdoMessage = CreateObject("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = SenderEmail
cdoMessage.To = RecipientEmail
cdoMessage.Subject = Subject
If Ucase(msgFormat) = "TEXT" Then
cdoMessage.TextBody = msgBody
Else
cdoMessage.HTMLBody = msgBody
End If
cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing
If Err.Number <> 0 Then
Response.Write "error: " & _
err.Number & " - " & err.Description & _
"<br /><br />"
End If
End Sub
SendGmail SendTo, SendFrom, Subject, MessageBody, "TEXT"
Be sure to edit the values in RED above before trying to use this. Also, be sure to use your Gmail account as the SendFrom address value or it may not be delivered successfully. You can easily modify this to work as VBScript by changing the Response.Write statements to Wscript.Echo, if you want to.
In case you happen to be a TextPad user (like I am), I have added this to the ASP Clip Library posted on my Scripting Resources site at http://www.steinvb.net/scripting.php Yes, I know it’s a bit ironic that I post something about ASP on a page written in PHP, but that’s how my brain works anyway.
Saturday, May 9, 2009
Vice Grips or Socket and Rachet?
send-mailmessage -to "User01" -from "User02 </USER02@EXAMPLE.COM></USER01@EXAMPLE.COM>" -subject "Test mail"
This is from http://technet.microsoft.com/en-us/library/dd347693.aspx
Friday, May 8, 2009
You've Got Mail? Probably Junk Mail
Sub SendMail(from, sendTo, subject, message)
Dim objMessage
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = subject
objMessage.From = from
objMessage.To = sendTo
objMessage.TextBody = message
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mysmtpserver.mycompany.local"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Set objMessage = Nothing
End Sub
Function SendMail($from, $sendTo, $subject, $message)
Dim $objMessage, $server, $s1, $s2, $s3
$s1 = "http://schemas.microsoft.com/cdo/configuration/sendusing"
$s2 = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
$s3 = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
$server = "mysmtpserver.mycompany.local"
$objMessage = CreateObject("CDO.Message")
$objMessage.Subject = $subject
$objMessage.From = $from
$objMessage.To = $sendTo
$objMessage.TextBody = $message
$objMessage.Configuration.Fields.Item($s1) = 2
$objMessage.Configuration.Fields.Item($s2) = $server
$objMessage.Configuration.Fields.Item($s3) = 25
$objMessage.Configuration.Fields.Update
$objMessage.Send
$objMessage = 0
EndFunction
Function SendMail ([string]$from, [string]$sendto, [string]$subject, [string]$msg) {
$SmtpClient = New-Object System.Net.Mail.SmtpClient
$MailMessage = New-Object System.Net.Mail.MailMessage
$SmtpClient.Host = "mysmtpserver.mycompany.local"
$mailmessage.from = ($from)
$mailmessage.To.add($sendto)
$mailmessage.Subject = $subject
$mailmessage.Body = $msg
try {
$smtpclient.Send($mailmessage)
}
catch [System.Net.WebException],[System.Net.Mail.SmtpException] {
"an error occurred: unable to resolve smtp host name"
}
catch {
"an error occurred: unable to send message (details follow)..."
$error[0].Exception.ToString()
}
}
SendMail "you@huh.local" "mom@what.local" "Hey Mom!" "Happy Mother's Day!"