Wednesday, November 25, 2009

Statistical Data Mining Tutorials

Just a little note to myself to not lose this link.

Tuesday, November 24, 2009

Listing User Last Logon with Powershell

This script assumes that you have enabled auditing on successful logins (by default, it doesn't).

The general process it follows is:
  • retrieve the Security event log
  • pulls login information up to the last reboot
  • gets unique usernames and the time they logged in
  • writes it all out to a text file
It's still a little raw, but it works. It runs very slow over the network; I'll work up one that uses the PSJob facilities...


function getLastBoot( $computername )
{
$wmi = Get-WmiObject -Class Win32_OperatingSystem
return $wmi.ConvertToDateTime( $wmi.LastBootUpTime )
}

function getTopDates()
{
$logins = @()
$input | foreach {
$rec = $_

# this is ugly...I'm going thru the list twice
$hasit = ($logins | where {($_.UserName -eq $rec.UserName) -and ($_.MachineName -eq $rec.MachineName)})

if( $hasit )
{
for( $x = 0; $x -lt $logins.Count; $x++ )
{
if(($rec.UserName -eq $logins[ $x ].UserName ) -and
($rec.MachineName -eq $logins[ $x ].MachineName ))
{
$logins[ $x ] = $rec
}
}
}
else
{
$logins = $logins + @(,$rec)
}
}
return $logins
}

$start_time = (Get-Date)
Write-Host "starting all $start_time"

$target_computers = @( "dal1mspwb16",
"dal1mspwb19",
"dal1mspwb36",
"dal1mspwb37",
"dal1mspwb12",
"dal1mspwb35")

# $target_computers = @( "dal1msdwb34" )

$target_computers | foreach {
$target = $_
$lastboot = getLastBoot( $target )

Remove-Item "iis_logins_$target.txt" -ErrorAction SilentlyContinue


Write-Host "processing $target :" (get-date)
Get-EventLog -LogName "Security" -ComputerName $target -After $lastboot |
select -Property UserName, MachineName, TimeGenerated -Unique |
sort -Property TimeGenerated |
getTopDates |
Out-File -Append -FilePath "iis_logins_$target.txt"

Write-Host "completed $target :" (get-date)
}

$end_time = (Get-Date)

Write-Host "complete"
Write-Host "Started: $start_time"
Write-Host "Finished: $end_time"
Write-Host ($end_time - $start_time)

Thursday, November 19, 2009

Creating System Restore Points with Powershell

Getting ready to install a new video driver? What about that "interesting" piece of software you found?

Aren't you worried that it is going to screw up your computer?

Well, if so, Windows XP/Vista/7 have a facility known as "System Restore Points". Basically, these are snapshots of your filesystem. There is a good chance they are already enabled, and being used by Windows Update.

What about those other times, though?

If you have Powershell 2.0 installed (whaddya mean, you don't? Get on it!), then you have a couple of commands to help you out:

Checkpoint-computer creates a system restore point.

Restore-computer reverts to the specified restore point

So, before you install that problematic driver/update/app, this is a quick and dirty way to cover your butt.

Be warned, though, this will restore everything - including any changes to any files you may have made.

Wednesday, November 18, 2009

Tracing Internet Explorer

eJohn has this article discussing dynaTrace Ajax, a utility for IE6-8 performance tracing. Sounds like neat stuff:
Not only can you see the execution count for your defined JavaScript methods but you can also see execution time for the built-in DOM methods! Wondering what native method calls are slowing down your application? Wonder no more. From the HotSpot view you can filter by DOM or regular JavaScript and see exactly where execution time is going and what methods are so slow.

Worth a look.

Tuesday, November 17, 2009

25 Tips For Intermediate Git Users

Nice little list of stuff about git.

Read it here.

You Don't Know Jack About Software Maintenance

Communications of the ACM has this article up on their site.
Software maintenance involves moving an item away from its original state. It encompasses all activities associated with the process of changing software. That includes everything associated with "bug fixes," functional and performance enhancements, providing backward compatibility, updating its algorithm, covering up hardware errors, creating user-interface access methods, and other cosmetic changes.

In software, adding a six-lane automobile expressway to a railroad bridge is considered maintenance—and it would be particularly valuable if you could do it without stopping the train traffic.

The article asserts that this can be managed, because it has been managed in the past. However, it is pretty weak on the "how" - only that it can be done.

Thursday, November 12, 2009

Powershell v1.0, IIS6, and remote machines

I found this snippet on the web:


$computer="server"
$co = new-object System.Management.ConnectionOptions
#$co.Username="domain\username"
#$co.Password="password"
$co.Authentication=[System.Management.AuthenticationLevel]::PacketPrivacy
#$co.EnablePrivileges=$true;
$wmi = New-Object System.Management.ManagementObjectSearcher
$wmi.Query="Select * From IIsApplicationPool"
$wmi.Scope.Path="\\$computer\root\MicrosoftIISv2"
$wmi.Scope.Options=$co
$wmi.Get() | foreach { $_.name }
In PowerShell v2.0 there is a new parameter, -Authentication, to specify
the authentication level (one line):
gwmi -class IIsApplicationPool -namespace "root\MicrosoftIISv2" -computer
$computer -authentication PacketPrivacy | foreach { $_.name}

Live failover for Xen images

Remus promises to bring to the Xen hypervisor live failovers. In other words, if a host system crashes, another machine picks up the load without any interruption to services.

From the Remus website:

Remus provides transparent, comprehensive high availability to ordinary virtual machines running on the Xen virtual machine monitor. It does this by maintaining a completely up-to-date copy of a running VM on a backup server, which automatically activates if the primary server fails. Key features:


  • The backup VM is an exact copy of the primary VM. When failure happens, it continues running on the backup host as if failure had never occurred.

  • The backup is completely up-to-date. Even active TCP sessions are maintained without interruption.

  • Protection is transparent. Existing guests can be protected without modifying them in any way.


This is neat because the only thing that I know of that provided this functionality is VMWare, which costs big bucks (and still holds the tools advantage). Xen is free, and available for Linux and OpenSolaris.

Thursday, November 5, 2009

Google Chrome Beta 4

I installed Google Chrome today, since I saw that the latest beta was out. I'm not much of a browser fanboy, so this was my first spin with it.

It's fast.

Very fast.

As in, it seems like I went from DSL to fiber.

I haven't run into any rendering issues, but I haven't tried banking yet, either. It doesn't have nearly the plethora of plugins that Firefox does. For day to day browsing, though, this thing is looking pretty good.

Tuesday, November 3, 2009

Open Data Kit

The University of Washington's "Change" project has just announced a collection of tools to simplify the development of data-collection applications. Called the "Open Data Kit", the primary client target is the Android operating system (no surprise, since Google was heavily involved).

Anyway, Change hopes to help out the third world with these tools, as cellular connectivity is often the only connectivity. That's a noble cause, but it is sure to have less-altruistic uses, as well. All open-source, under the Apache license.

Here's their rundown of the goodies:

ODK Collect is powerful phone based replacement for your paper forms. Collect is built on the Android platform and can collect a variety of form data types: text, location, photos, video, audio, and barcodes.

ODK Aggregate provides a ready to deploy online repository to store, view and export collected data. Aggregate is currently implemented on Google App Engine and enables free hosting of data on Google's reliable infrastructure.

ODK Manage maintains a database of all phones in a deployment to enable remote device management. By sending an SMS to a deployed phone, Manage can trigger the transfers of forms, data, and applications.

ODK Validate ensures that you have a OpenRosa complaint form -- one that will also work with all the ODK tools.

ODK Voice facilities mapping XForms to sound snippets that can be played over a "robo" call to any phone. Responses are collected using the phone's keypad (DTMF) and are automatically aggregated.