Monday, December 20, 2010

Remote Desktop not displaying Local Drives

This may have you stumped if you are a performance freak and like to tweak (disable) certain services that are OOTB with Windows.  You can categorize me within that column, if you like. Winking smile I typically disable the service called: Server on my workstation because in my eyes, it’s not necessary unless I’m serving something up.  That’s what servers are for eh?  Well in the case of Remote Desktop, you are serving up files if you want to connect to your local drives.  I ran into that issue earlier today and felt like passing it along.  Below is a picture of what local drives look like when logged into a server/PC via Remote Desktop.


If you constantly tweak settings, it’s always good to keep documentation of what you are doing.  It just so happens that I do this often enough to remember that this was the setting at fault.  Hopefully, it’ll help you along the way…

Friday, December 17, 2010

Create an event receiver script within your ActiveScriptEventConsumer with PowerEvents

I’ve had the pleasure of meeting Trevor Sullivan when I convinced him he should learn all about SQL Server.  Not really, but we did chat it up on Twitter and decided to both go to Cleveland for an intro on SQL Server 2008 R2.  Little did I know what he was working on.  Quite simply one of the coolest projects I’ve used from Codeplex.  Trevor has created PowerEvents!  I’ll admit, some of it is way over my head at the moment.  It’s directly related to how much I really know about WMI, but I feel that’s about to change drastically.

I posted a tweet earlier about what I’ve created with PowerEvents.  Actually, I feel as if it would be a best practice for the ActiveScriptEventConsumer.  You can be the judge of that Winking smile.  Since it’s almost impossible to see what you’ve created as an Event Consumer, I’ve simply created only one: ActiveScriptEventConsumer.  That way I don’t have to worry about what has been added under the hood to WMI.  All I have to do is tweak the script that is fired when the event occurs.  So, I’ve built a basic script that looks for the arguments you have passed to it.  Based on these arguments, you can dynamically call different scripts or functions.  Pretty slick, eh?  Here’s a basic script that will email two different people based on what the WMI query results are.

Option Explicit
Const strFrom = ""
Const strMailserver = ""
Const strSchema = ""
Dim objArgs, objEmail
Dim strProcessName, strSubject, strBody, strTo
'Get arguments from command line
set objArgs = WScript.Arguments
strProcessName = WScript.Arguments(0)
strSubject = WScript.Arguments(1)
strBody = Wscript.Arguments(2)
'Dynamically change the email recipient
'Or even change the function to be called
'Or call a completely different script: .bat, .vbs, .ps1
'Endless possibilities
If strProcessName = "NotePad.exe" Then
	strTo = ""
ElseIf strProcessName = "Outlook.exe" Then
	strTo = ""
End If
'Call to send email, but many different functions could be within this script and
'dynamically called based on arguments
Call SendEmail(strSubject, strBody)
Sub SendEmail(Subject, Body)
	Set objEmail = CreateObject("CDO.Message")
	objEmail.From = strFrom
	objEmail.To = strTo
	objEmail.Subject = Subject
	objEmail.Textbody = Body
	objEmail.Configuration.Fields.Item _
	    (strSchema & "sendusing") = 2
	objEmail.Configuration.Fields.Item _
	    (strSchema & "smtpserver") = strMailserver
	objEmail.Configuration.Fields.Item _
	    (strSchema & "smtpserverport") = 25
End Sub
'Clean up vars
set strProcessName = nothing
set strSubject = nothing
set strBody = nothing


I hope you find this useful.  I’m brand new to creating PowerEvents, but I do feel this is the best way to handle scripting based on events.  Feel free to post a comment if I’m an idiot Rolling on the floor laughingand there is a much easier way…

Saturday, December 4, 2010

Download pictures from HootSuite:

Maybe you have noticed, maybe you haven’t, but when you send pictures to this service, you cannot download them from their website.  Right click as much as you want, you’ll never get a Save Picture As option.  That’s a major flaw in my book.  I send pictures to the cloud not to lock them into a vault.  I send them because I’d like to share them!  These pictures are not yours HootSuite, they are mine and will always be mine!

What can you do about it?

Being the curious guy that I am, I noticed an embed link on the page.  Let’s look at this one for example:  Cracking open notepad, I pasted this link and saved the .txt file to a .htm.  Upon opening the newly created web page, I see my beautiful picture with all of it’s glorious pixels.  Well, it’s not that great of a photo, but the end result is gratifying.  Since I’m now viewing a web page with MY photo on it, that isn’t controlled by HootSuite, I’m able to right click the page and Save Picture As. Winking smile Ha ha, I win HootSuite…  When you save the photo, the file type is defaulted to a .gif.  Go ahead and save it as a .gif.  When I did this earlier, I tried opening my picture, but it didn’t display my photo…  Did HootSuite one-up me again?!?  Absolutely not!  Right click that .gif file and select edit.  This will open the picture up in MSPaint.  Then simply save this photo as a .jpeg or .jpg.  Congratulations, you now own your digital media…. again!

I OWN MY PHOTOS HOOTSUITE and it’s quite ridiculous that I have to resort to these tactics just to share my digital life.  What if my friends or family wanted to download that photo?  Give up the policy of what is yours is mine and what’s mine is mine.  It’s so not attractive.Steaming mad