C# und Powershell mischen

Von Doug Finke gibt es ein interessantes Video, in dem er beschreibt wie man C# Code in Powershell Skripten direkt ausführen kann.

http://dougfinke.com/blog/?p=414

Extrem genial ist die Möglichkeit, den C# Code direkt in der Powershell laufen zu lassen, die einzige Erweiterung war das „public“ Setzen von Klasse und Methode und der passende Aufruf:

Add-Type `
@"
using System;
namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hallo Welt");
            Console.ReadLine();
        }
    }
}
"@
[ConsoleApplication1.Program]::Main($null)

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website