Archive

Archive for the ‘Technology’ Category

SQL 2008 and MERGE

May 14th, 2010 No comments

A feature I’ve long awaited in Microsoft SQL (TSQL) has been a function similar to MySQL’s REPLACE function. For those that haven’t used it, the REPLACE function allows you to do an insert of a new record, or replace an existing record if one matches the primary key. In SQL 2008, Microsoft introduced a function called MERGE. This is like REPLACE, but a whole bunch of extra goodies…

Read more…

Categories: Microsoft, Technology Tags: , ,

Tracking the rogue IP address

May 6th, 2010 3 comments

Digging up an old post today, I helped my wife figure out why her office A/C system couldn’t be managed properly. Apparently their system connects on a specific IP address, and it wasn’t responding. It was surmised that it was caused by some work I had done fixing one of the other machines a few months ago. But after some quick digging, turns out it wasn’t. Apparently their “consultant” had a device on the network for VPN, firewall, etc, which had the same address on it. How it got the same, we don’t know, but here is how we figured it out…

Read more…

Categories: Networking Tags:

Reverting a checkout from another workspace

May 6th, 2010 No comments

Every now and again, we have issues where a developer will have their laptop rebuilt, and forget they have files checked out in Team Foundation Server (TFS). This isn’t very helpful as sometimes they cannot undo their check outs. Visual Studio doesn’t give you access to undo a checkout in another workspace if it’s not your workspace, however the TF.exe command does. Here’s how:

tf /undo /workspace:workspacename;username $/project/path/to/file

This will happily undo the change on that particular file. If you have a whole directory to revert the changes on, that’s easy too…

tf /undo /workspace:workspacename;username /recursive $/project/path/to/directory

You must remember when reverting somebody else’s change to use the project URL, not the physical path on your local machine, otherwise you’ll get an error like this:

No pending changes were found for <localpathname>\file.aspx

For more details on the tf.exe undo command, see the Microsoft documentation here. Full details on arguments for the tf.exe command can be found here too.

Categories: Microsoft, Technology, Work Tags:

Hiding web server information

April 17th, 2010 1 comment

In a case of what I’d call security through obscurity, the Linux Poison blog has a posting up on how to hide the PHP information in your web server. The idea is that the less a potential hacker knows about a system, the better. Here, I’m going to take it one step further, and show you the impact of some other options, and what data gets hidden.

Read more…

Categories: Linux, Sys Admin, Technology Tags:

PowerShell: Restart remote services

April 10th, 2010 No comments

In a follow up to @ScriptingGuys post about restarting services using VBScript, here is the same using PowerShell. I’ll probably be dragging the same onto some server monitoring stuff to get a service back up and running we’ve been having a weird issue with.

$names = Get-Content c:\temp\computers.txt
foreach($name in $names) {
    $svc = Get-WmiObject Win32_Service -ComputerName $name `
        -Filter "name='wuauserv'"
    if ($svc.started -eq $true) {
        $svc.StopService()
    }
    $svc.StartService()
}

This takes a file “computers.txt”, loops through the data, and uses WMI to connect to the remote machines to get the wuauserv service (or in plain English Windows Automatic Update). Easy as pie.

Categories: PowerShell Tags:

PowerShell: Top x Processes using CPU

April 6th, 2010 No comments

This is a quick and handy one for server monitoring, and tracking down that process that is using all your CPU. It makes use of WMI counters.

Read more…

PowerShell: Timing Commands

April 6th, 2010 2 comments

Curious about how long your script took to execute? How about just that cmdlet? Powershell has a built in function for you.

  • Open Powershell command prompt
  • Use the command Measure-Command like so:
Measure-Command {c:\scripts\yourscript.ps1}

Enjoy the output broken down by days, hours, minutes, seconds, milliseconds, and ticks.

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 34
Milliseconds      : 287
Ticks             : 342873445
TotalDays         : 0.000396844265046296
TotalHours        : 0.00952426236111111
TotalMinutes      : 0.571455741666667
TotalSeconds      : 34.2873445
TotalMilliseconds : 34287.3445

The same works for cmdlets too…

PS C:\scripts> Measure-Command {Get-Process}

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 6
Ticks             : 65919
TotalDays         : 7.62951388888889E-08
TotalHours        : 1.83108333333333E-06
TotalMinutes      : 0.000109865
TotalSeconds      : 0.0065919
TotalMilliseconds : 6.5919
Categories: General Ramblings, Microsoft, PowerShell Tags:

PowerShell: Cleaning up IIS Logs

April 1st, 2010 2 comments

This one is a quick and easy one. We have multiple IIS boxes, which each generate large usage logs on a daily basis. To save space, and for analytics off-server, we compress the log files. Having found Rar is one of the better compression algorithms, we simply shell out to rar, compress the logs, and cleanup older logs.

Read more…

PowerShell: Remote Registry, and fixing an Office 2007 install

March 29th, 2010 No comments

We’ve had a stubborn Windows 2003 server that we’ve been trying to get Office 2007 installed for a while. It has a couple of things wrong with it which have made the install substantially harder.

Read more…

Support Contacts…

March 17th, 2010 1 comment

The Networker Blog has an excellent post on support contracts, coining the term Icarus Support Contract. Preston warns on the dangers of using a using minimal support agreements when covering equipment, and software in an environment that is covered by an SLA.

Read more…