Powershell ~ Shorten Shortcut Names

Renaming Files

Here is something I just came up with. It is a really short Powershell one-liner to remove the annoying ‘- Shortcut’ from your shortcuts.

dir “*- Shortcut*” | foreach{ren -Path $_.Name -NewName $_.Name.Replace(” – Shortcut”,””)}

It is a good idea to execute it first with -whatif in the foreach loop.

Note: Be sure to be in the desktop directory when you run this.


Visual Basic 2010 Object and List Initialization

I just found this out and I am really excited about it! The With & From are cooler than ever!

Check this out:

Module Module1
Private Class TestClass
Public Property Subject As String
Public Property Grade As String
Public Property Student As String
End Class
Sub Main()
Dim myTest As New TestClass With {.Grade = "A+", .Student = "Myself", .Subject = "Advanced Chromotography"}

Dim test As New System.Collections.Generic.List(Of TestClass) From {
New TestClass With {.Subject = "Math", .Student = "John Bowman", .Grade = "B"}}

End Sub
End Module

The With and From are now part of the declaration statement, saving even more real estate on the screen.

Powershell Retrieving Remote System Time

Compare Local Date and Time to a Remote Computer

This is a rather interesting problem. I was doing a comparison between an audit table and a trace for SQL Server, which was proving to be dificult as I soon realized there was latency as well as the system date’s had an offset. So I turned to my good old friend, Powershell. Powershell has a very nice interface for coding against WMI, which I fully leveraged in this code snippet.

#Server name here. 
$ServerName = <Server Name Here>
#Retreive the localtime of the server. 
$remoteDate = Get-WmiObject -ComputerName $ServerName -Class win32_operatingsystem -Property LocalDateTime
#Converting a WMI time to a standard datetime format. 
$remoteDate = [System.Management.ManagementDateTimeConverter]::ToDateTime($remoteDate.LocalDateTime)

$localDate = Get-Date

#Displaying the difference. 
$remoteDate - $localDate

Mozilla is Alienating Businesses and Education with Firefox

Downside of Firefox

Firefox has been really destroying its chances of being deployed to organizations. Why is that you might ask? Well Firefox was used widely back in the version 3.xx but now, they are up to version 12. Version 3 was released back in June of 2008, we are now in April 2012 and they are now up to version 12.

Frequent Updates are the Demise of Firefox

This rapid “major” update schedule means that organizations have to perform testing (for applications and penetration testing), develop new system images for workstations, create new virtual apps for shops that use that technology-such as BMW. I quote major because many of the updates could be considered by many to be minor. This results in a major amount of money to be spent every time Firefox gets updated.

Meanwhile, Microsoft is still supporting IE6 from years ago, Mozilla provides very limited support.

Is Firefox going away? Not any time soon, but they are going to lose market share. Institutions cannot support this behavior.

If someone from Mozilla is paying attention to me, how about acknowledging the operations people in the world exist and you might want to make them happy. After all, they recommend web browsers not just to the businesses but to friends and family. The users in the businesses are going to be biased to use the same web browser at home and at work. If the business is using Internet Explorer, more likely than not, the employees will be using that at home as well.

SQL Server Reporting Services ~ Cascading/Dependant Parameters

This is my first screencast, enjoy!

SQL Server Null Values ~ Into the Void (pun intended)

Null values can get some people rather confused writing queries. I hope I can shed some light on that. By default, SQL Server uses ANSI Nulls. This behavior says that any value compared to null is not equal to null.

if ‘a’=null
print ‘true’
print ‘false’

Returns false

Here is something interesting and if you are slightly devious, what about null compared to null?

if null=null
print ‘true’
print ‘false’

Returns false

if null is null
print ‘true’
print ‘false’

Returns true

Lets turn off ANSI_Null:


if null=null
print ‘true’
print ‘false’ 


if null is null
print ‘true’
print ‘false’ 

Returns true

According to MSDN, if you are trying to search for or compare null values using “is null” is recommended and will return consistent results.

If you are trying to create a query and want to include nulls in the result set you have to do it explicitly like this:
WHERE name = ‘Smith’ OR name IS NULL
Or if you want to exclude nulls:
WHEREname = ‘Smith’ OR name IS NOT NULL

If you want to be tricky you could do something like:

WHERE ISNULL (name,) = ‘Smith’

In London, they have signs that say “Mind the gap”, I say MIND THE NULLS!

One handy function to deal with nulls is Coalesce, which I describe here.

DataGridViewComboBoxColumn requires multiple clicks to select an item

I am reposting this because I think this guy did a good job posting this. I wish I got to this first! 🙂

DataGridViewComboBoxColumn requires multiple clicks to select an item.