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…
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…
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.
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…
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.
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…
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
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…
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…
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…