Monday, March 26, 2012
Texas. We messed with you (by cleaning up the beach a bit) and got away scot-free!
ae58e953-9c1b-4f9a-afa9-1f0a97f9f0eb +

Texas. We messed with you (by cleaning up the beach a bit) and got away scot-free!

ae58e953-9c1b-4f9a-afa9-1f0a97f9f0eb +

While debugging an Azure project a couple of weeks ago the Azure Emulator startup process kept throwing the unhandled exception “A heap has been corrupted.”

After poking around for a bit looking for x86/x64 settings compat problems I remembered that as a part of some PowerShell v3 testing I’d done earlier in the week on this same machine I’d set a registry key so that PowerShell would use the latest CLR. Unwinding those registry keys seems to have resolved the DFAgent error.

Run these commands to unwind the ‘OnlyUserLatestCLR’ change on your machine (the 2nd line only applies to x64):

reg add hklm\software\microsoft.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 0

reg add hklm\software\wow6432node\microsoft.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 0

Thursday, March 8, 2012

If you’re like me you may have be using a specific type of SQL database known as a ‘User Instance’ without knowing what it is or how it works. You’d never known there was anything unusual until you tried to access your database from outside of Visual Studio. For example, in Microsoft SQL Server Management Studio …

Dude, where’s my database?

No worries. First, make sure your app is running. The database is started at app runtime by Visual Studio. Once your app is running execute this SQL statement in SQL Server Management Studio:

SELECT owning_principal_name, instance_pipe_name, heart_beat FROM sys.dm_os_child_instances

Take note of the named pipe that’s alive. That’s where your database is hiding. Copy the pipe name.

Open up the ‘Connect to Server’ dialog and paste in your named pipe address. Hit Connect.

Dude, there’s your database.

Friday, May 27, 2011

Yammer SHOULD be in the Chrome App Store but isn’t. Tell them so.

Yammer in Chrome Apps

In the meantime, you can add them into your own personal apps by following these 5 simple steps:

  1. Download and unzip this manifest/icon app folder for Yammer: http://db.tt/64K0l8W
  2. Open up the Chrome Extension by clicking the wrench icon, choosing ‘Tools’, then choosing ‘Extensions’
  3. Click the ‘+’ next to ‘Developer mode’ to open up the developer tools
  4. Click the ‘Load unpacked extension’ button
  5. Navigate to the unzipped yammer_app folder, click ‘OK’
Thursday, May 26, 2011

Shay Levy did an excellent PowerShellization of ‘netstat’ (link) on his blog back in February. JRich also had an excellent take on implementing NetStat in PowerShell (link). There is also a simple one-liner [net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties().GetActiveTcpConnections() that will get you Tcp connection information without the process information but IMHO the info provided is practically useless in most real world scenarios without the process info.

One can argue over which solution is more PowerShellicous, “inlining c#” or “scraping cmd output”. Meanwhile while that flame war is happening I’ll be over here extending either of these solutions because PowerShell is awesome like that. Here I added filtering to the Shay’s solution. Behold:

PS C:\Users\ben> Get-NetworkStatistics skype | ft -AutoSize

Protocol LocalAddress LocalPort RemoteAddress RemotePort State     ProcessName PID 
-------- ------------ --------- ------------- ---------- -----     ----------- --- 
TCP      0.0.0.0      443       0.0.0.0       0          LISTENING Skype       4068
TCP      0.0.0.0      9841      0.0.0.0       0          LISTENING Skype       4068

PS C:\Users\ben> Get-NetworkStatistics -ProcessId 3368


Protocol      : TCP
LocalAddress  : 192.168.10.115
LocalPort     : 49899
RemoteAddress : 204.152.18.196
RemotePort    : 443
State         : ESTABLISHED
ProcessName   : chrome
PID           : 3368

Here’s the source:

Friday, January 7, 2011
Change the welcome background image in Windows7:
Set this key value to 1: HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground
Overwriting this file: %windir%\system32\oobe\info\backgrounds\backgroundDefault.jpg

Change the welcome background image in Windows7:

Set this key value to 1: HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background\OEMBackground

Overwriting this file: %windir%\system32\oobe\info\backgrounds\backgroundDefault.jpg

Friday, April 23, 2010

Back from #MMS2010

Thursday, December 17, 2009

I really like the @PowerTip blog series but I find myself wanting to talk back with more than 120 characters. Please enable comments @PowerTip. Comments are enabled for authenticated users. In the meantime, I’ll blog my comments.

re: Get Process Owners

function Get-PSOwner($searchString)
{	
    $foundProcess = ps $searchString
    if($foundProcess -eq $null) { return; }
    gwmi Win32_Process -Filter ("Handle={0}" -f $foundProcess.id ) | 
        % { Add-Member `
            -InputObject $_ `
            -MemberType NoteProperty `
            -Name Owner `
            -Value ($_.GetOwner().User) `
            -PassThru } | 
        select Name, Handle, Owner
}

The four minor changes I made to the @PowerTip script are: 1) it’s functionized, 2) the input is a search string for process (wildcards accepted), 3) it spits out the correct errors if the process can’t be found, and 4) the process handle is added to the results.

Download the script here: http://bitbucket.org/xcud/powershell-snippets/src/tip/Get-PSOwner.psm1

Wednesday, September 30, 2009

(tongue set firmly in cheek)

I happened upon Dana Merrick’s blog entry with a ruby script that retrieves an order status from dominos. In the spirit of “anything you can do I can do better" i threw this Psh equivalent together and submitted it to PoshCode.org. It’s phenomenally simple. It makes a request to the Dominos SOAP order status service and selects and displays the order status nodes if they exist.

function Get-DominosOrderStatus($pn) {
  [xml]$content = (new-object System.Net.WebClient).DownloadString(
    "http://trkweb.dominos.com/orderstorage/GetTrackerData?Phone=$pn");
  $statii = select-xml -xml @($content) `
    -Namespace @{dominos="http://www.dominos.com/message/"} `
    -XPath descendant::dominos:OrderStatus
  if($statii.Count -gt 0) { $statii | %{ $_.Node } }
  else { "No orders" }
}

Sample Output:

Version               : 1.3
OrderAsOfTime         : 2008-06-04T16:40:48
StoreAsOfTime         : 2008-06-04T16:44:55
StoreID               : 3189
OrderID               : 2008-06-04#73694
Phone                 : 3145551234
ServiceMethod         : Delivery
AdvancedOrderTime     :
OrderDescription      : 2 Small(10") Hand Tossed Pizza

OrderTakeCompleteTime : 2008-06-04T16:27:52
TakeTimeSecs          : 0
CsrID                 : Power
CsrName               :
OrderSourceCode       : Web
OrderStatus           : Out the Door
StartTime             : 2008-06-04T16:27:52
MakeTimeSecs          : 237
OvenTime              : 2008-06-04T16:31:49
OvenTimeSecs          : 360
RackTime              : 2008-06-04T16:37:49
RackTimeSecs          : 179
RouteTime             : 2008-06-04T16:40:48
DriverID              : 0818
DriverName            : Edna
OrderDeliveryTimeSecs :
DeliveryTime          :
OrderKey              : 1dRprcnzmWxaOXvlzj06OlFdzuexcIC/
ManagerID             : 5560
ManagerName           : Danillo

#text : Out the Door

You can download it here: http://bitbucket.org/xcud/powershell-snippets/src/tip/Get-DominosOrderStatus.psm1

Monday, September 21, 2009

Inspired by Chad Miller’s work MSChart I threw this ANSI barchart module together:

#
# Out-AnsiGraph.psm1
# Author:       xcud
# History:
#       v0.1 September 21, 2009 initial version
#
# PS Example> ps | select -first 5 | sort -property VM | 
#             Out-AnsiGraph ProcessName, VM
#                 AEADISRV ███ 14508032
#                  audiodg █████████ 50757632
#                  conhost █████████████ 73740288
# AppleMobileDeviceService ████████████████ 92061696
#                    btdna █████████████████████ 126443520
#
function Out-AnsiGraph($Parameter1=$null) {
	BEGIN {
		$q = new-object Collections.queue
		$max = 0; $namewidth = 0;
	}

	PROCESS {
		if($_) {
			$name = $_.($Parameter1[0]);
			$val = $_.($Parameter1[1])
			if($max -lt $val) { $max = $val}		 
			if($namewidth -lt $name.length) { 
				$namewidth = $name.length }
			$q.enqueue(@($name, $val))			
		}
	}

	END {
		$q | %{
			$graph = ""; 0..($_[1]/$max*20) | 
				%{ $graph += "█" }
			$name = "{0,$namewidth}" -f $_[0]
			"$name $graph " + $_[1]
		}

	}
}

Export-ModuleMember Out-AnsiGraph

Download the script here: http://bitbucket.org/xcud/powershell-snippets/src/tip/Out-AnsiGraph.psm1