Remote version of Get-Service

This is a powershell version of get-service that works across remote machines (provided that you have sufficient access to the box).

function Get-ServiceRemote($computerName = “.”)
{
Get-WmiObject win32_service -ComputerName . | sort Name | select SystemName,State,Name,DisplayName
}

This can be passed through ft -Auto to become more readable.
A few scripts like these could be of great use in checking the state of a remote system.

Json.Net Parsing Example

I have been looking at how to easily consume json from C#.
Given the source of the data I don’t want to create specific types (I’ll be creating a dynamic wpf control to allow editing of json read from a configuration database).
This requires newtonsoft.json to be pulled from nuget and a reference made to newtonsoft.json.


using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace SimpleJsonTest
{
class Program
{
static void Main(string[] args)
{

string json = @"[{""First"":""Chris"",""LastName"":""Pietschmann""}, {""First"":""Chris"",""LastName"":""Eyre""}]";
List<Dictionary> values = JsonConvert.DeserializeObject<List<Dictionary>>(json);

Console.WriteLine( string.Join(",", values[0].Keys));
Console.WriteLine(string.Join(",", values[0].Values));
Console.WriteLine(string.Join(",", values[1].Values));

Console.ReadLine();
}
}
}

StudioShell and the Debugger

This is a wonderful article on using StudioShell with the visual studio debugger.

This artictle shows how to script the local variables of the currently debugged process.
Given StudioShell has out-html and out-chart this allows the dynamic creation of visualised data straight from the current debug session.

StudioShell is a powershell console that is embedded into visual studio (it can also be invoked from the NuGet console).
It exposes the visual studio extension api known as dte as a set of powershell scripts.

This Code Was Generated By A Tool

This comment seems to be appearing in my code rather more frequently recently, especially as I have been working with WCF.
This should include the important information which tool generated the file, include version information and parameters used.

WCF code generation is rather weak. It includes 7 wierdly named hidden files. One of these includes a url reference to the web service that generated the client proxy.
If the config file for the service fails to include a reference to the service then the service that generated the client is used. This is very dangerous and will make production code accidently refer to a test server.