xcud

May 27

Add Yammer to Chrome Apps

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’

May 26

Get-NetworkStatistics (or ‘netstat’ for PowerShell)

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:

Jan 07

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

Apr 23

[video]

Dec 17

Get Process Owners

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

Sep 30

Get-DominosOrderStatus, a profound poshcode contribution

(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

Sep 21

Out-AnsiGraph

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

Sep 19

MSChart in Psh

Read Chad Miller’s blog entry on using MSChart from PowerShell. This is another great visualization extension for PowerShell. To make it work:

  • Download and install Microsoft Chart Controls for Microsoft .NET Framework 3.5
  • Download LibraryChart
  • The easiest way to enable it is to import the library with a call to ‘Import-Module’. Now run one of the samples:

    If you see this error or one like it it’s an easy fix. Edit the lib and edit the input param list in the function “New-Chart” from this:

    param ([int]$width,[int]$height,[int]$left,[int]$top,$chartTitle)

    To this:

    param ([int]$width,[int]$height,[int]$left,[int]$top,[string]$chartTitle)

    Voila. Re-import the module and the error is gone. The only item on my wish list for this lib is that it attempt to infer the X and Y fields. A call like this, for example, should be able to (but can’t) infer that xField is ‘name’ and yField is ‘ws’:

    ps | Sort-Object WS | select name, ws -first 5 | out-chart

    It makes eye-candy. Check this one out. Grab the top 5 memory consuming processes and push them into a relative pie chart that auto-updates itself.

    out-chart -chartType ‘pie’ -xField ‘name’ -yField ‘WS’ -scriptBlock { Get-Process | Sort-Object -Property WS | Select-Object Name,WS -Last 5}

    Sep 15

    enable ‘svn commit’ from PowerShell

    If you’re trying to use Subversion from the PowerShell command line and you can’t get around this error message:

    PS C:\Users\Public\Source> svn commit .

    svn: Commit failed (details follow):

    svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the —message (-m) or —file (-F) options

    svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no ‘editor-cmd’ run-time configuration option was found

    Set your SVN_EDITOR preference with this command (substituting “type” for your preferred editor):

    PS C:\Users\Public\Source> set-item -path env:SVN_EDITOR -value “type”

    Aug 09

    back from vacation

    Vacation pics: http://www.flickr.com/photos/benvierck/sets/72157621985515336/

    I’m not completely back. i have not quite completed re-entry back into my daily work habits. I was a bit gobsmacked at my encounter with the ocean and our history. The vastness of the ocean which it seems to me could swallow us all up in an instant or two and not mind one bit on the one hand. The encounters with historical peoples whose very daily existence represented more adventure than I’ll know in a lifetime are on the other hand.

    Tomorrow i’ll shove this aside and do some work on the build process to make this last push to VMWord more productive and I’ll get the next build ready to go for a Monday release.