<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>justdaft&#039;s Blog</title>
	<atom:link href="http://justdaft.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://justdaft.wordpress.com</link>
	<description>it&#039;s justdaft not doing it this way.</description>
	<lastBuildDate>Thu, 26 Jan 2012 09:14:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='justdaft.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>justdaft&#039;s Blog</title>
		<link>http://justdaft.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://justdaft.wordpress.com/osd.xml" title="justdaft&#039;s Blog" />
	<atom:link rel='hub' href='http://justdaft.wordpress.com/?pushpress=hub'/>
		<item>
		<title>PowerShell + WPF + XAML = Cool</title>
		<link>http://justdaft.wordpress.com/2012/01/25/powershell-wpf-xaml-cool/</link>
		<comments>http://justdaft.wordpress.com/2012/01/25/powershell-wpf-xaml-cool/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 20:21:03 +0000</pubDate>
		<dc:creator>human1428</dc:creator>
				<category><![CDATA[GUI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">https://justdaft.wordpress.com/?p=87</guid>
		<description><![CDATA[To create a GUI for your script try using WPF + XAML. Here is a few things that worked for me. Lets start with a basic script. 1: Add-Type -AssemblyName presentationframework 2: 3: [xml]$XAML = @" 4: &#60;Window 5: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 6: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 7: Height="150" Width="150"&#62; 8: 9: &#60;/Window&#62; 10: "@ 11: 12: $Reader=(New-Object System.Xml.XmlNodeReader $xaml) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=87&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To create a GUI for your script try using WPF + XAML.</p>
<p>Here is a few things that worked for me.</p>
<p>Lets start with a basic script.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:96.28%;font-family:'Courier New', courier, monospace;direction:ltr;height:255px;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;"> 1:</span> Add-Type -AssemblyName presentationframework</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;"> 2:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;"> 3:</span> [xml]$XAML = <span style="color:#006080;">@"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;"> 4:</span> &lt;Window</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;"> 5:</span>   xmlns="http:<span style="color:#008000;">//schemas.microsoft.com/winfx/2006/xaml/presentation"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;"> 6:</span>   xmlns:x=<span style="color:#006080;">"http://schemas.microsoft.com/winfx/2006/xaml"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;"> 7:</span>   Height=<span style="color:#006080;">"150"</span> Width=<span style="color:#006080;">"150"</span>&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;"> 8:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;"> 9:</span> &lt;/Window&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;"> 10:</span> "@</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;"> 11:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;"> 12:</span> $Reader=(New-Object System.Xml.XmlNodeReader $xaml)</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;"> 13:</span> $Window=[Windows.Markup.XamlReader]::Load( $Reader )</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;"> 14:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;"> 15:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;"> 16:</span> $Window.ShowDialog() | <span style="color:#0000ff;">out</span>-null</pre>
</div>
</div>
<p>That should make a small blank window appear.</p>
<p><a href="http://justdaft.files.wordpress.com/2012/01/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" src="http://justdaft.files.wordpress.com/2012/01/image_thumb.png?w=158&#038;h=160" alt="image" width="158" height="160" border="0" /></a></p>
<p>So what you may be thinking! what good is that?</p>
<p>But be patient please this is only the beginning.</p>
<p>Lets make some text appear in the window.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;"> 1:</span> Add-Type -AssemblyName presentationframework</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;"> 2:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;"> 3:</span> [xml]$XAML = <span style="color:#006080;">@"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;"> 4:</span> &lt;Window</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;"> 5:</span>   xmlns="http:<span style="color:#008000;">//schemas.microsoft.com/winfx/2006/xaml/presentation"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;"> 6:</span>   xmlns:x=<span style="color:#006080;">"http://schemas.microsoft.com/winfx/2006/xaml"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;"> 7:</span>   Height=<span style="color:#006080;">"150"</span> Width=<span style="color:#006080;">"150"</span>&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;"> 8:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;"> 9:</span>     &lt;Label Content=<span style="color:#006080;">"Hello World!"</span>/&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;"> 10:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;"> 11:</span> &lt;/Window&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;"> 12:</span> "@</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;"> 13:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;"> 14:</span> $Reader=(New-Object System.Xml.XmlNodeReader $xaml)</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;"> 15:</span> $Window=[Windows.Markup.XamlReader]::Load( $Reader )</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;"> 16:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum17" style="color:#606060;"> 17:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum18" style="color:#606060;"> 18:</span> $Window.ShowDialog() | <span style="color:#0000ff;">out</span>-null</pre>
</div>
</div>
<p>So guess what might happen?</p>
<p><a href="http://justdaft.files.wordpress.com/2012/01/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" src="http://justdaft.files.wordpress.com/2012/01/image_thumb1.png?w=154&#038;h=154" alt="image" width="154" height="154" border="0" /></a></p>
<p>So have I got your attention yet?</p>
<p>Ok it’s still not that exciting but hopefully you are following along.</p>
<p>To make it a tiny bit better to look at lets center the label in the window.and add a bit of colour.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;"> 1:</span> Add-Type -AssemblyName presentationframework</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;"> 2:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;"> 3:</span> [xml]$XAML = <span style="color:#006080;">@"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;"> 4:</span> &lt;Window</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;"> 5:</span>   xmlns="http:<span style="color:#008000;">//schemas.microsoft.com/winfx/2006/xaml/presentation"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;"> 6:</span>   xmlns:x=<span style="color:#006080;">"http://schemas.microsoft.com/winfx/2006/xaml"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;"> 7:</span>   Height=<span style="color:#006080;">"150"</span> Width=<span style="color:#006080;">"150"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;"> 8:</span>   Background=<span style="color:#006080;">"lightblue"</span>&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;"> 9:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;"> 10:</span>    &lt;Label HorizontalAlignment=<span style="color:#006080;">"Center"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;"> 11:</span>           VerticalAlignment=<span style="color:#006080;">"Center"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;"> 12:</span>           FontSize=<span style="color:#006080;">"18"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;"> 13:</span>           Foreground=<span style="color:#006080;">"White"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;"> 14:</span>           Content=<span style="color:#006080;">"Hello World!"</span>/&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;"> 15:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;"> 16:</span> &lt;/Window&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum17" style="color:#606060;"> 17:</span> "@</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum18" style="color:#606060;"> 18:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum19" style="color:#606060;"> 19:</span> $reader=(New-Object System.Xml.XmlNodeReader $xaml)</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum20" style="color:#606060;"> 20:</span> $Window=[Windows.Markup.XamlReader]::Load( $reader )</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum21" style="color:#606060;"> 21:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum22" style="color:#606060;"> 22:</span> $Window.ShowDialog() | <span style="color:#0000ff;">out</span>-null</pre>
</div>
</div>
<p><a href="http://justdaft.files.wordpress.com/2012/01/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" src="http://justdaft.files.wordpress.com/2012/01/image_thumb2.png?w=154&#038;h=154" alt="image" width="154" height="154" border="0" /></a></p>
<p>Now that we have it looking a bit better lets change the content of our label via PowerShell.</p>
<p>To be able to change the content of the label we have to do three things:</p>
<p>Give the label a name, find the label in the xaml and then set the content to the new value.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:104.36%;font-family:'Courier New', courier, monospace;direction:ltr;height:210px;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;"> 1:</span> Add-Type -AssemblyName presentationframework</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;"> 2:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;"> 3:</span> [xml]$XAML = <span style="color:#006080;">@"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;"> 4:</span> &lt;Window</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;"> 5:</span>   xmlns="http:<span style="color:#008000;">//schemas.microsoft.com/winfx/2006/xaml/presentation"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;"> 6:</span>   xmlns:x=<span style="color:#006080;">"http://schemas.microsoft.com/winfx/2006/xaml"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;"> 7:</span>   Height=<span style="color:#006080;">"150"</span> Width=<span style="color:#006080;">"150"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;"> 8:</span>   Background=<span style="color:#006080;">"lightblue"</span>&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;"> 9:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;"> 10:</span>    &lt;Label HorizontalAlignment=<span style="color:#006080;">"Center"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;"> 11:</span>           VerticalAlignment=<span style="color:#006080;">"Center"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;"> 12:</span>           FontSize=<span style="color:#006080;">"18"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;"> 13:</span>           Foreground=<span style="color:#006080;">"White"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;"> 14:</span>           Content=<span style="color:#006080;">"Hello World!"</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;"> 15:</span>           Name=<span style="color:#006080;">"myHostName"</span> /&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;"> 16:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum17" style="color:#606060;"> 17:</span> &lt;/Window&gt;</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum18" style="color:#606060;"> 18:</span> <span style="color:#006080;">"@</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum19" style="color:#606060;"> 19:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum20" style="color:#606060;"> 20:</span> $reader=(New-Object System.Xml.XmlNodeReader $xaml)</pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum21" style="color:#606060;"> 21:</span> $Window=[Windows.Markup.XamlReader]::Load( $reader )</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum22" style="color:#606060;"> 22:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum23" style="color:#606060;"> 23:</span> $myHostName = $Window.findname("myHostName")</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum24" style="color:#606060;"> 24:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum25" style="color:#606060;"> 25:</span> $myHostName.Content = $env:computername</pre>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum26" style="color:#606060;"> 26:</span></pre>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span id="lnum27" style="color:#606060;"> 27:</span> $Window.ShowDialog() | <span style="color:#0000ff;">out</span>-null</pre>
</div>
</div>
<p><a href="http://justdaft.files.wordpress.com/2012/01/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" src="http://justdaft.files.wordpress.com/2012/01/image_thumb3.png?w=154&#038;h=154" alt="image" width="154" height="154" border="0" /></a></p>
<p>The change to the script will display you computer name in the window.</p>
<p>&nbsp;</p>
<p>This has been a very basic intro but it should be enough to get you going.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justdaft.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justdaft.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justdaft.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justdaft.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justdaft.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justdaft.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justdaft.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justdaft.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=87&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justdaft.wordpress.com/2012/01/25/powershell-wpf-xaml-cool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6ae75bbde913d2f10a8674d90c7f203?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">human1428</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Search an XML Document for a Specific Value</title>
		<link>http://justdaft.wordpress.com/2012/01/24/search-an-xml-document-for-a-specific-value/</link>
		<comments>http://justdaft.wordpress.com/2012/01/24/search-an-xml-document-for-a-specific-value/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 15:45:20 +0000</pubDate>
		<dc:creator>human1428</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xml file]]></category>

		<guid isPermaLink="false">http://justdaft.wordpress.com/?p=64</guid>
		<description><![CDATA[Here is an example of how to search through an XML document for a value of an attribute: Here is the XML file: To find &#60;archive Name=&#8221;20100828&#8243;&#62; try this: This should return these results:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=64&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is an example of how to search through an XML document for a value of an attribute:</p>
<p>Here is the XML file:</p>
<p><pre class="brush: css;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;root&gt;
 &lt;archive Name=&quot;20100821&quot;&gt;
 &lt;File Name=&quot;Log20100821.log&quot; SizeKB=&quot;117727&quot; LastWriteTime=&quot;08/21/2010 06:33:35&quot; /&gt;
 &lt;File Name=&quot;Archive20100821.log&quot; SizeKB=&quot;3&quot; LastWriteTime=&quot;08/21/2010 06:33:35&quot; /&gt;
 &lt;File Name=&quot;Routine20100821.log&quot; SizeKB=&quot;74&quot; LastWriteTime=&quot;08/21/2010 06:33:36&quot; /&gt;
 &lt;/archive&gt;
 &lt;archive Name=&quot;20100828&quot;&gt;
 &lt;File Name=&quot;Log20100828.log&quot; SizeKB=&quot;148740&quot; LastWriteTime=&quot;08/28/2010 06:34:14&quot; /&gt;
 &lt;File Name=&quot;Archive20100828.log&quot; SizeKB=&quot;4&quot; LastWriteTime=&quot;08/28/2010 06:34:15&quot; /&gt;
 &lt;File Name=&quot;Routine20100828.log&quot; SizeKB=&quot;90&quot; LastWriteTime=&quot;08/28/2010 06:34:15&quot; /&gt;
 &lt;/archive&gt;
&lt;/root&gt;

</pre></p>
<p>To find &lt;archive Name=&#8221;20100828&#8243;&gt; try this:</p>
<p><pre class="brush: css;">
$xml = [xml](get-content xml.xml)
$searchItem = &quot;20100828&quot;
$xml.SelectNodes(&quot;root/archive&quot;) | ? { $_.Name -eq $searchItem} | % {$_.File } | ft -AutoSize
</pre></p>
<p>This should return these results:</p>
<p><a href="http://justdaft.files.wordpress.com/2012/01/capture3.png"><img class="alignnone size-medium wp-image-68" title="Capture3" src="http://justdaft.files.wordpress.com/2012/01/capture3.png?w=300&#038;h=126" alt="" width="300" height="126" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justdaft.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justdaft.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justdaft.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justdaft.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justdaft.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justdaft.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justdaft.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justdaft.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=64&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justdaft.wordpress.com/2012/01/24/search-an-xml-document-for-a-specific-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6ae75bbde913d2f10a8674d90c7f203?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">human1428</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/capture3.png?w=300" medium="image">
			<media:title type="html">Capture3</media:title>
		</media:content>
	</item>
		<item>
		<title>How to initiate a Remote Desktop Session from Powershell</title>
		<link>http://justdaft.wordpress.com/2012/01/24/how-to-initiate-a-remote-desktop-session-from-powershell/</link>
		<comments>http://justdaft.wordpress.com/2012/01/24/how-to-initiate-a-remote-desktop-session-from-powershell/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 13:13:11 +0000</pubDate>
		<dc:creator>human1428</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://justdaft.wordpress.com/?p=54</guid>
		<description><![CDATA[To initiate a RDP session from a script try this: Create a new RDP Connection Enter all the required details and then save the connection Then you can run it from you script using this: If you want your script to wait for the RDP session to exit before it continues then add this:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=54&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To initiate a RDP session from a script try this:</p>
<p>Create a new RDP Connection</p>
<p><a href="http://justdaft.files.wordpress.com/2012/01/capture1.png"><img class="alignnone size-medium wp-image-57" title="Capture" src="http://justdaft.files.wordpress.com/2012/01/capture1.png?w=265&#038;h=300" alt="" width="265" height="300" /></a></p>
<p>Enter all the required details and then save the connection</p>
<p><a href="http://justdaft.files.wordpress.com/2012/01/capture2.png"><img class="alignnone size-medium wp-image-58" title="Capture2" src="http://justdaft.files.wordpress.com/2012/01/capture2.png?w=300&#038;h=219" alt="" width="300" height="219" /></a></p>
<p>Then you can run it from you script using this:</p>
<p><pre class="brush: css;">

$RDPServer = &quot;c:\RDP\Server1.rdp&quot;
Write-Verbose &quot; Invokeing $RDPServer Session&quot;
invoke-Expression &quot;mstsc.exe '$RDPServer'&quot;

</pre></p>
<p>If you want your script to wait for the RDP session to exit before it continues then add this:</p>
<p><pre class="brush: css;">
$mstscProcess = (Get-Process | Where-Object { $_.ProcessName -ieq &quot;mstsc&quot; })
Write-verbose &quot;Waiting for MSTSC.EXE to exit&quot;
$mstscProcess.WaitForExit()
Write-verbose &quot;MSTSC.EXE ended&quot;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justdaft.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justdaft.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justdaft.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justdaft.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justdaft.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justdaft.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justdaft.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justdaft.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=54&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justdaft.wordpress.com/2012/01/24/how-to-initiate-a-remote-desktop-session-from-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6ae75bbde913d2f10a8674d90c7f203?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">human1428</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/capture1.png?w=265" medium="image">
			<media:title type="html">Capture</media:title>
		</media:content>

		<media:content url="http://justdaft.files.wordpress.com/2012/01/capture2.png?w=300" medium="image">
			<media:title type="html">Capture2</media:title>
		</media:content>
	</item>
		<item>
		<title>Get a test page from your printers</title>
		<link>http://justdaft.wordpress.com/2012/01/24/get-a-test-page-from-your-printers/</link>
		<comments>http://justdaft.wordpress.com/2012/01/24/get-a-test-page-from-your-printers/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 11:19:57 +0000</pubDate>
		<dc:creator>human1428</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://justdaft.wordpress.com/?p=49</guid>
		<description><![CDATA[Here is a little function to request a test page from each of the printers you are connected to.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=49&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a little function to request a test page from each of the printers you are connected to.</p>
<p><pre class="brush: css;">
# Get Printer Objects for this computer from WMI

$vPrinters = Get-WmiObject -Class Win32_printer

# Print a test page for each printer

foreach ($vPrinter in $vPrinters)

{ $vPrinter.PrintTestPage() }

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justdaft.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justdaft.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justdaft.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justdaft.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justdaft.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justdaft.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justdaft.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justdaft.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=49&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justdaft.wordpress.com/2012/01/24/get-a-test-page-from-your-printers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6ae75bbde913d2f10a8674d90c7f203?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">human1428</media:title>
		</media:content>
	</item>
		<item>
		<title>CREATE NEW XML FILE</title>
		<link>http://justdaft.wordpress.com/2012/01/24/create-new-xml-file/</link>
		<comments>http://justdaft.wordpress.com/2012/01/24/create-new-xml-file/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 11:02:20 +0000</pubDate>
		<dc:creator>human1428</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xml file]]></category>

		<guid isPermaLink="false">http://justdaft.wordpress.com/?p=38</guid>
		<description><![CDATA[Here is a little function i created to create an XML file from the structure of a folder. The folder structure looks like this: E:\Archives\LatestArchiveFiles 20100821 Log20100821.log Archive20100821.log Routine20100821.log 20100828 Log20100828.log Archive20100828.log Routine20100828.log It works by doing a Get-ChildItem on the folder and creating the XML file based on the folder structure. The XML File [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=38&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-family:'Segoe WP';"><span style="font-family:'Segoe WP';">Here is a little function i created to create an XML file from the structure of a folder.</span></span></p>
<p>The folder structure looks like this:</p>
<p>E:\Archives\LatestArchiveFiles</p>
<p style="padding-left:30px;">20100821</p>
<p style="padding-left:60px;">Log20100821.log<br />
Archive20100821.log<br />
Routine20100821.log</p>
<p style="padding-left:30px;">20100828</p>
<p style="padding-left:60px;">Log20100828.log<br />
Archive20100828.log<br />
Routine20100828.log</p>
<p>It works by doing a Get-ChildItem on the folder and creating the XML file based on the folder structure.</p>
<p><pre class="brush: css;">

Function New-XMLFile ($Path = &quot;E:\Gateway\Archives&quot;)
 {
Set-Location $path
Write-Verbose &quot;Path has been set to $path&quot;
$VerbosePreference = &quot;Continue&quot;
#$VerbosePreference = &quot;silentlyContinue&quot;
Write-Verbose $pwd
$xml = New-Object xml
$rootElements = gci
$root = $xml.CreateElement(&quot;root&quot;)
[void]$xml.AppendChild($root)

foreach($archiveElement in $rootElements ){
 Write-Verbose &quot;Archive Loop, for $archiveElement &quot;
 Write-Verbose &quot;Setting location to $archiveElement&quot;
 set-location $path\$archiveElement
 Write-Verbose &quot;location Set to $pwd&quot;
 $archive = $xml.CreateElement(&quot;archive&quot;)
 [void]$root.AppendChild($archive)
 $archive.SetAttribute(&quot;Name&quot;, $archiveElement)
 $fileElements = gci
 foreach ($fileElement in $fileElements){
 Write-Verbose &quot;File Loop&quot;
 Write-Verbose &quot;Looking at $fileElement`n&quot;
 $fileSize = ($fileElement.Length/1KB).tostring(&quot;0&quot;)
 $file = $xml.CreateElement(&quot;File&quot;)
 [void]$archive.AppendChild($file)
 $file.SetAttribute(&quot;Name&quot;, $fileElement)
 $file.SetAttribute(&quot;SizeKB&quot;, $fileSize )
 $file.SetAttribute(&quot;LastWriteTime&quot;, $fileElement.LastWriteTime)
 }
 }
$xml.save(&quot;E:\Gateway\Archives&quot;)
}

New-XMLfile &quot;C:\Documents and Settings\psuser&quot;

</pre></p>
<p>The XML File created would look like this</p>
<p><pre class="brush: css;">
&lt;root&gt;
 &lt;archive Name=&quot;20100821&quot;&gt;
 &lt;File Name=&quot;Log20100821.log&quot; SizeKB=&quot;117727&quot; LastWriteTime=&quot;08/21/2010 06:33:35&quot; /&gt;
 &lt;File Name=&quot;Archive20100821.log&quot; SizeKB=&quot;3&quot; LastWriteTime=&quot;08/21/2010 06:33:35&quot; /&gt;
 &lt;File Name=&quot;Routine20100821.log&quot; SizeKB=&quot;74&quot; LastWriteTime=&quot;08/21/2010 06:33:36&quot; /&gt;
 &lt;/archive&gt;
 &lt;archive Name=&quot;20100828&quot;&gt;
 &lt;File Name=&quot;Log20100828.log&quot; SizeKB=&quot;148740&quot; LastWriteTime=&quot;08/28/2010 06:34:14&quot; /&gt;
 &lt;File Name=&quot;Archive20100828.log&quot; SizeKB=&quot;4&quot; LastWriteTime=&quot;08/28/2010 06:34:15&quot; /&gt;
 &lt;File Name=&quot;Routine20100828.log&quot; SizeKB=&quot;90&quot; LastWriteTime=&quot;08/28/2010 06:34:15&quot; /&gt;
 &lt;/archive&gt;
&lt;/root&gt;


</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justdaft.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justdaft.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justdaft.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justdaft.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justdaft.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justdaft.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justdaft.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justdaft.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=38&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justdaft.wordpress.com/2012/01/24/create-new-xml-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6ae75bbde913d2f10a8674d90c7f203?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">human1428</media:title>
		</media:content>
	</item>
		<item>
		<title>create new folder structure</title>
		<link>http://justdaft.wordpress.com/2012/01/24/create-xml-file-from-folder-structure-2/</link>
		<comments>http://justdaft.wordpress.com/2012/01/24/create-xml-file-from-folder-structure-2/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 09:24:02 +0000</pubDate>
		<dc:creator>human1428</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xml file]]></category>

		<guid isPermaLink="false">http://justdaft.wordpress.com/?p=22</guid>
		<description><![CDATA[Here is a little function to create a new folder structure from a bunch of files. The folder structure looks like this: E:\Archives\LatestArchiveFiles Log20100821.log Archive20100821.log Routine20100821.log Log20100828.log Archive20100828.log Routine20100828.log After running the function the folder structure looks like this: E:\Archives\LatestArchiveFiles 20100821 Log20100821.log Archive20100821.log Routine20100821.log 20100828 Log20100828.log Archive20100828.log Routine20100828.log It works by doing a Get-ChildItem on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=22&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-family:'Segoe WP';">Here is a little function to create a new folder structure from a bunch of files.</span></p>
<p>The folder structure looks like this:</p>
<p>E:\Archives\LatestArchiveFiles</p>
<p style="padding-left:30px;">Log20100821.log<br />
Archive20100821.log<br />
Routine20100821.log<br />
Log20100828.log<br />
Archive20100828.log<br />
Routine20100828.log</p>
<p>After running the function the folder structure looks like this:</p>
<p>E:\Archives\LatestArchiveFiles</p>
<p style="padding-left:30px;">20100821</p>
<p style="padding-left:60px;">Log20100821.log<br />
Archive20100821.log<br />
Routine20100821.log</p>
<p style="padding-left:30px;">20100828</p>
<p style="padding-left:60px;">Log20100828.log<br />
Archive20100828.log<br />
Routine20100828.log</p>
<p>It works by doing a Get-ChildItem on the folder and grouping the files by the date part of the file name, then it creates new folders based on the group name and moves the relevant files in to the new folder.</p>
<p><pre class="brush: css;">
Function Create-New-Folder-Structure{
param($path = 'E:\Archives\LatestArchiveFiles')
$VerbosePreference = &quot;Continue&quot;
$ArchivePath = $null
Set-Location $path

$GroupByDate = {$z =($_.name).ToString(); $z.Substring($z.Length – 12, 8)}

$archiveGroups = Get-ChildItem '*.log' | Group-Object $GroupByDate | select group,name
write-verbose &quot;The current folder is $pwd&quot;
write-verbose &quot;Start of Date Group Processing`n&quot;

foreach ($archiveGroup in $archiveGroups){
 Set-Location $path
 $thisName = $archiveGroup.name
 write-verbose &quot;Create new sub folder for archive $thisName&quot;
 New-Item -Name $thisName -itemType directory
 # Copy logs to relevant year folder
 Write-Verbose &quot;Moving archive files $thisName to $pwd\$thisName&quot;
 $archiveGroup | % {$_.Group | % {move-item $_ -destination ($archiveGroup.name)}}
 }

Write-Verbose &quot;$ArchivePath = $pwd&quot;
#$global:ArchivePath = $pwd.path
Write-Verbose &quot;$global:ArchivePath = $pwd&quot;
return $ArchivePath
}

Create-New-Folder-Structure E:\Archives\LatestArchiveFiles

Write-Verbose $ArchivePath

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justdaft.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justdaft.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justdaft.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justdaft.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justdaft.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justdaft.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justdaft.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justdaft.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justdaft.wordpress.com&amp;blog=12973032&amp;post=22&amp;subd=justdaft&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justdaft.wordpress.com/2012/01/24/create-xml-file-from-folder-structure-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e6ae75bbde913d2f10a8674d90c7f203?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">human1428</media:title>
		</media:content>
	</item>
	</channel>
</rss>
