<?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/"
	>

<channel>
	<title>vmweaver.com &#187; Miscellaneous</title>
	<atom:link href="http://vmweaver.com/index.php/category/miscellaneous/feed/" rel="self" type="application/rss+xml" />
	<link>http://vmweaver.com</link>
	<description>Mindless ramblings of a geek...</description>
	<lastBuildDate>Thu, 06 Oct 2011 20:42:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Oooey-GUI Script Searcher</title>
		<link>http://vmweaver.com/index.php/2011/10/oooey-gui-script-searcher/</link>
		<comments>http://vmweaver.com/index.php/2011/10/oooey-gui-script-searcher/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 20:40:39 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=290</guid>
		<description><![CDATA[As a follow up to my Script Tagging post, I have put together a Powershell GUI script that one can use to search a folder structure that has tagged scripts in it. I haven&#8217;t documented this as well as I normally would, so perhaps that will come at a later time. Basically you launch it [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow up to my <a href="http://vmweaver.com/index.php/2011/07/tag-youre-it/">Script Tagging post</a>, I have put together a Powershell GUI script that one can use to search a folder structure that has tagged scripts in it.</p>
<p>I haven&#8217;t documented this as well as I normally would, so perhaps that will come at a later time.</p>
<p>Basically you launch it and the &#8220;Folder Root&#8221; will default to the current directory.</p>
<p>Once you enter some values in the text boxes, and &#8220;Execute&#8221; the search, the script will recursively interrogate all powershell scripts in the root folder and all child folders looking for the appropriate tags as created by the &#8220;Tagging&#8221; post.</p>
<p><img src="http://vmweaver.com/wp-content/uploads/2011/10/ScriptSearchGUI.png" alt="UI ScreenShot" /></p>
<p>I hope you find it helpful and here is the code!<br />
As always&#8230; Happy scripting!!!<br />
 &#8212; Mark</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">function</span> Find<span style="color: pink;">-</span>Script
<span style="color: #000000;">&#123;</span>
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Term</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;/*&quot;</span> <span style="color: pink;">,</span><span style="color: #800080;">$Path</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;.\&quot;</span><span style="color: pink;">,</span><span style="color: #800080;">$FilePattern</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;*.ps1&quot;</span><span style="color: pink;">,</span><span style="color: #800080;">$Tag</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;/*&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$Auth</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;/*&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$Desc</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;/*&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$Misc</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;/*&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$AllScripts</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-ChildItem</span> <span style="color: pink;">*</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$Path</span> <span style="color: #008080; font-style: italic;">-include</span> <span style="color: #800080;">$FilePattern</span> <span style="color: #008080; font-style: italic;">-recurse</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$AllTags</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Null</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$FoundScripts</span><span style="color: pink;">=</span><span style="color: #800080;">$null</span>
<span style="color: #0000FF;">Foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Script</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$AllScripts</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  <span style="color: #800080;">$Contents</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$Script</span>
  <span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$AllTags</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Null</span>
  <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800000;">&quot;_BEGINMARKUP&quot;</span><span style="color: #000000;">&#41;</span>
   <span style="color: #000000;">&#123;</span>
    <span style="color: #008000;"># ($Contents -imatch &quot;_TAG:&quot;).gettype()</span>
	<span style="color: #800080;">$Found</span> <span style="color: pink;">=</span> <span style="color: #800080;">$False</span>
     <span style="color: #800080;">$Tags</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_TAG:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;#&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	 <span style="color: #800080;">$Author</span><span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_AUTH:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;#&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
     <span style="color: #800080;">$Description</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_DESC:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;#&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	 <span style="color: #800080;">$Version</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_VER:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;#&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	 <span style="color: #800080;">$Miscellaneous</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_MISC:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;#&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	 <span style="color: #800080;">$ModifiedDate</span> <span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_DATE:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.replace<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;#&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">1</span><span style="color: #000000;">&#93;</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	 <span style="color: #800080;">$AllTags</span> <span style="color: pink;">+=</span><span style="color: #800080;">$Tags</span>
	 <span style="color: #800080;">$AllTags</span> <span style="color: pink;">+=</span><span style="color: #800080;">$Author</span>
	 <span style="color: #800080;">$AllTags</span> <span style="color: pink;">+=</span><span style="color: #800080;">$Description</span>
	 <span style="color: #800080;">$AllTags</span> <span style="color: pink;">+=</span><span style="color: #800080;">$Version</span>
	 <span style="color: #800080;">$AllTags</span> <span style="color: pink;">+=</span><span style="color: #800080;">$Miscellaneous</span>
&nbsp;
	<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Tags</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800080;">$Tag</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-and</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Author</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800080;">$Auth</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-and</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Description</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800080;">$Desc</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-and</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Miscellaneous</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800080;">$Misc</span><span style="color: #000000;">&#41;</span><span style="color: #FF0000;">-and</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$AllTags</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800080;">$Term</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Found</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span><span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Found</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	  <span style="color: #800080;">$FoundItem</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-Object</span> Script<span style="color: pink;">,</span>Author<span style="color: pink;">,</span>LastModified<span style="color: pink;">,</span>Tags<span style="color: pink;">,</span>Description
	  <span style="color: #800080;">$FoundItem</span>.Script <span style="color: pink;">=</span> <span style="color: #800080;">$Script</span>
	  <span style="color: #800080;">$FoundITem</span>.Author <span style="color: pink;">=</span> <span style="color: #800080;">$Author</span>
	  <span style="color: #800080;">$FoundItem</span>.LastModified <span style="color: pink;">=</span> <span style="color: #800080;">$Script</span>.LastWriteTime
	  <span style="color: #800080;">$FoundItem</span>.Tags <span style="color: pink;">=</span> <span style="color: #800080;">$Tags</span>
	  <span style="color: #800080;">$FoundItem</span>.Description <span style="color: pink;">=</span> <span style="color: #800080;">$Description</span>
	  <span style="color: #800080;">$FoundScripts</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$FoundItem</span>
	<span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$FoundScripts</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
 <span style="color: #008000;"># Write-Host &quot;Search Term: $Term&quot;</span>
 <span style="color: #0000FF;">return</span> <span style="color: #800080;">$FoundScripts</span>
  <span style="color: #000000;">&#125;</span>
  <span style="color: #0000FF;">else</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;No Scripts found with specified criteria.&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Yellow
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;">#Generated Form Function</span>
<span style="color: #0000FF;">function</span> GenerateForm <span style="color: #000000;">&#123;</span>
&nbsp;
<span style="color: #008000;">#region Import the Assemblies</span>
<span style="color: #000000;">&#91;</span>reflection.assembly<span style="color: #000000;">&#93;</span>::loadwithpartialname<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;System.Windows.Forms&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #000000;">&#91;</span>reflection.assembly<span style="color: #000000;">&#93;</span>::loadwithpartialname<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;System.Drawing&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #008000;">#endregion</span>
&nbsp;
<span style="color: #008000;">#region Generated Form Objects</span>
<span style="color: #800080;">$form1</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Form
<span style="color: #800080;">$btnBrowse</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Button
<span style="color: #800080;">$txtPath</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$button1</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Button
<span style="color: #800080;">$label5</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Label
<span style="color: #800080;">$label4</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Label
<span style="color: #800080;">$label3</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Label
<span style="color: #800080;">$label2</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Label
<span style="color: #800080;">$label1</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Label
<span style="color: #800080;">$label6</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.Label
<span style="color: #800080;">$txtTag</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$txtMisc</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$txtAuth</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$fldBrowser</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.FolderBrowserDialog
<span style="color: #800080;">$txtDesc</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$textBox2</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$txtTerm</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.TextBox
<span style="color: #800080;">$dataGridView1</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.DataGridView
<span style="color: #800080;">$InitialFormWindowState</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Windows.Forms.FormWindowState
<span style="color: #008000;">#endregion Generated Form Objects</span>
&nbsp;
<span style="color: #008000;">#----------------------------------------------</span>
<span style="color: #008000;">#Generated Event Script Blocks</span>
<span style="color: #008000;">#----------------------------------------------</span>
<span style="color: #008000;">#Provide Custom Code for events specified in PrimalForms.</span>
<span style="color: #800080;">$button1_OnClick</span><span style="color: pink;">=</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">#TODO: Place custom script here</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtPath</span>.text <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
<span style="color: #800080;">$fldBrowser</span>.ShowDialog<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$txtPath</span>.Text <span style="color: pink;">=</span> <span style="color: #800080;">$fldBrowser</span>.SelectedPath
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtAuth</span>.Text <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Auth</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;/*&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Auth</span> <span style="color: pink;">=</span> <span style="color: #800080;">$txtAuth</span>.Text.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtTag</span>.Text <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Tags</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;/*&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Tags</span> <span style="color: pink;">=</span> <span style="color: #800080;">$txtTag</span>.Text.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtMisc</span>.Text <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Misc</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;/*&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Misc</span> <span style="color: pink;">=</span> <span style="color: #800080;">$txtMisc</span>.Text.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtTerm</span>.Text <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Term</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;/*&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Term</span> <span style="color: pink;">=</span> <span style="color: #800080;">$txtTerm</span>.Text.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtDesc</span>.Text <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Desc</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;/*&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$Desc</span> <span style="color: pink;">=</span> <span style="color: #800080;">$txtDesc</span>.Text.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;">#Write-Host ($txtAuth.Text -eq &quot;&quot;)</span>
<span style="color: #800080;">$Path</span> <span style="color: pink;">=</span> <span style="color: #800080;">$txtPath</span>.Text
<span style="color: #008000;">#Write-Host &quot;find-script -Path &quot;&quot;$Path&quot;&quot; -Auth $Auth -Desc $Desc -Misc $Misc -Tag $Tags -Term $Term&quot;</span>
&nbsp;
<span style="color: #800080;">$FoundScripts</span> <span style="color: pink;">=</span> find<span style="color: pink;">-</span>script <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800000;">&quot;$Path&quot;</span> <span style="color: pink;">-</span>Auth <span style="color: #800000;">&quot;$Auth&quot;</span> <span style="color: pink;">-</span>Desc <span style="color: #800000;">&quot;$Desc&quot;</span> <span style="color: pink;">-</span>Misc <span style="color: #800000;">&quot;$Misc&quot;</span> <span style="color: pink;">-</span>Tag <span style="color: #800000;">&quot;$Tags&quot;</span> <span style="color: pink;">-</span>Term <span style="color: #800000;">&quot;$Term&quot;</span>
<span style="color: #800080;">$array</span><span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> System.Collections.ArrayList
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$FoundScripts</span>.count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
<span style="color: #800080;">$array</span>.addrange<span style="color: #000000;">&#40;</span><span style="color: #800080;">$FoundScripts</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #800080;">$array</span>.add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$FoundScripts</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
    <span style="color: #800080;">$dataGridview1</span>.datasource <span style="color: pink;">=</span> <span style="color: #800080;">$array</span>
    <span style="color: #800080;">$form1</span>.refresh<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> 
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$dataGridView1_Selectionchanged</span> <span style="color: pink;">=</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #800080;">$f</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span>
   <span style="color: #800080;">$SelectedPath</span> <span style="color: pink;">=</span> <span style="color: #800080;">$datagridview1</span>.selectedcells<span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.value
   <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$SelectedPath</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
   <span style="color: #000000;">&#123;</span>
   <span style="color: #800080;">$f</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$SelectedPath</span>
   <span style="color: #000000;">&#125;</span>
   <span style="color: #800080;">$textBox2</span>.lines <span style="color: pink;">=</span><span style="color: #800080;">$f</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$btnBrowse_OnClick</span><span style="color: pink;">=</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #800080;">$object</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> <span style="color: #008080; font-style: italic;">-comObject</span> Shell.Application  
&nbsp;
    <span style="color: #800080;">$folder</span> <span style="color: pink;">=</span> <span style="color: #800080;">$object</span>.BrowseForFolder<span style="color: #000000;">&#40;</span><span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #800080;">$message</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$folder</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> 
&nbsp;
<span style="color: #800080;">$txtPath</span>.Text <span style="color: pink;">=</span> <span style="color: #800080;">$folder</span>.self.Path
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$handler_form1_Load</span><span style="color: pink;">=</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">#TODO: Place custom script here</span>
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$OnLoadForm_StateCorrection</span><span style="color: pink;">=</span>
<span style="color: #000000;">&#123;</span><span style="color: #008000;">#Correct the initial state of the form to prevent the .Net maximized form issue</span>
	<span style="color: #800080;">$form1</span>.WindowState <span style="color: pink;">=</span> <span style="color: #800080;">$InitialFormWindowState</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;">#----------------------------------------------</span>
<span style="color: #008000;">#region Generated Form Code</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">650</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">1050</span>
<span style="color: #800080;">$form1</span>.ClientSize <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$form1</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$form1</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;form1&quot;</span>
<span style="color: #800080;">$form1</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Script Search Interface&quot;</span>
<span style="color: #800080;">$form1</span>.add_Load<span style="color: #000000;">&#40;</span><span style="color: #800080;">$handler_form1_Load</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$button1</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">900</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">35</span>
<span style="color: #800080;">$button1</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$button1</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;button1&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">23</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">100</span>
<span style="color: #800080;">$button1</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$button1</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">2</span>
<span style="color: #800080;">$button1</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Execute Search&quot;</span>
<span style="color: #800080;">$button1</span>.UseVisualStyleBackColor <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
<span style="color: #800080;">$button1</span>.add_Click<span style="color: #000000;">&#40;</span><span style="color: #800080;">$button1_OnClick</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$button1</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$btnBrowse</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">259</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">36</span>
<span style="color: #800080;">$btnBrowse</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$btnBrowse</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;btnBrowse&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">23</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">60</span>
<span style="color: #800080;">$btnBrowse</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$btnBrowse</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">14</span>
<span style="color: #800080;">$btnBrowse</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Browse...&quot;</span>
<span style="color: #800080;">$btnBrowse</span>.UseVisualStyleBackColor <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
<span style="color: #800080;">$btnBrowse</span>.add_Click<span style="color: #000000;">&#40;</span><span style="color: #800080;">$btnBrowse_OnClick</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$btnBrowse</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$txtPath</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">38</span>
<span style="color: #800080;">$txtPath</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$txtPath</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;txtPath&quot;</span>
<span style="color: #800080;">$txtPath</span>.Text <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-Location</span><span style="color: #000000;">&#41;</span>.Path
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">241</span>
<span style="color: #800080;">$txtPath</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$txtPath</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">13</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtPath</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$fldBrowser</span>.RootFolder <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.Environment<span style="color: pink;">+</span>SpecialFolder<span style="color: #000000;">&#93;</span>::Personal
&nbsp;
<span style="color: #800080;">$dataGridView1</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">80</span>
<span style="color: #800080;">$dataGridView1</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$dataGridView1</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;dataGridView1&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">218</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">1000</span>
<span style="color: #800080;">$dataGridView1</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$dataGridView1</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$dataGridView1</span>.Autosizecolumnsmode<span style="color: pink;">=</span><span style="color: #800000;">&quot;AllCells&quot;</span>
<span style="color: #800080;">$dataGridView1</span>.SelectionMode <span style="color: pink;">=</span> <span style="color: #804000;">1</span>
<span style="color: #800080;">$dataGridView1</span>.Readonly <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
<span style="color: #800080;">$dataGridView1</span>.add_SelectionChanged<span style="color: #000000;">&#40;</span><span style="color: #800080;">$dataGridView1_Selectionchanged</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$dataGridView1</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$textBox2</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">300</span>
<span style="color: #800080;">$textBox2</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$textBox2</span>.Multiline <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
<span style="color: #800080;">$textBox2</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;textBox2&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">350</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">1000</span>
<span style="color: #800080;">$textBox2</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$textBox2</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">3</span>
<span style="color: #800080;">$textbox2</span>.scrollbars <span style="color: pink;">=</span> <span style="color: #804000;">3</span>
<span style="color: #800080;">$textBox2</span>.Readonly<span style="color: pink;">=</span><span style="color: #800080;">$true</span>
<span style="color: #800080;">$textBox2</span>.wordwrap <span style="color: pink;">=</span> <span style="color: #800080;">$False</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$textBox2</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$label5</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">703</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">38</span>
<span style="color: #800080;">$label5</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$label5</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;label5&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">17</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">46</span>
<span style="color: #800080;">$label5</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$label5</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$label5</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Misc:&quot;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$label5</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$label6</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$label6</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$label6</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;label6&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">17</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">200</span>
<span style="color: #800080;">$label6</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$label6</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">13</span>
<span style="color: #800080;">$label6</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Search Folder Root:&quot;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$label6</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$label4</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span><span style="color: #804000;">703</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">15</span>
<span style="color: #800080;">$label4</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$label4</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;label4&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">46</span>
<span style="color: #800080;">$label4</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$label4</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">11</span>
<span style="color: #800080;">$label4</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Tags:&quot;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$label4</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$label3</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">484</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">41</span>
<span style="color: #800080;">$label3</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$label3</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;label3&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">23</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">64</span>
<span style="color: #800080;">$label3</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$label3</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">10</span>
<span style="color: #800080;">$label3</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Description:&quot;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$label3</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #000000;">&#91;</span>System.Environment<span style="color: pink;">+</span>SpecialFolder<span style="color: #000000;">&#93;</span><span style="color: #800080;">$SearchRoot</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;MyDocuments&quot;</span>
<span style="color: #800080;">$fldBrowser</span>.RootFolder <span style="color: pink;">=</span> <span style="color: #800080;">$SearchRoot</span>
&nbsp;
<span style="color: #800080;">$label2</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">507</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$label2</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$label2</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;label2&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">41</span>
<span style="color: #800080;">$label2</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$label2</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">9</span>
<span style="color: #800080;">$label2</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Author:&quot;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$label2</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$label1</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">310</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">15</span>
<span style="color: #800080;">$label1</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$label1</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;label1&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">23</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">60</span>
<span style="color: #800080;">$label1</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$label1</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">8</span>
<span style="color: #800080;">$label1</span>.Text <span style="color: pink;">=</span> <span style="color: #800000;">&quot;All Fields:&quot;</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$label1</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$txtTag</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span><span style="color: #804000;">755</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$txtTag</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$txtTag</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;txtTag&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">100</span>
<span style="color: #800080;">$txtTag</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$txtTag</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">7</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtTag</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$txtMisc</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">755</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">35</span>
<span style="color: #800080;">$txtMisc</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$txtMisc</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;txtMisc&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">100</span>
<span style="color: #800080;">$txtMisc</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$txtMisc</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">6</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtMisc</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$txtAuth</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">554</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$txtAuth</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$txtAuth</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;txtAuth&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">100</span>
<span style="color: #800080;">$txtAuth</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$txtAuth</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">5</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtAuth</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$txtDesc</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">554</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">38</span>
<span style="color: #800080;">$txtDesc</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$txtDesc</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;txtDesc&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">100</span>
<span style="color: #800080;">$txtDesc</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$txtDesc</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">4</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtDesc</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$txtTerm</span>.DataBindings.DefaultDataSourceUpdateMode <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
<span style="color: #800080;">$System_Drawing_Point</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Point
<span style="color: #800080;">$System_Drawing_Point</span>.X <span style="color: pink;">=</span> <span style="color: #804000;">374</span>
<span style="color: #800080;">$System_Drawing_Point</span>.Y <span style="color: pink;">=</span> <span style="color: #804000;">12</span>
<span style="color: #800080;">$txtTerm</span>.Location <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Point</span>
<span style="color: #800080;">$txtTerm</span>.Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;txtTerm&quot;</span>
<span style="color: #800080;">$System_Drawing_Size</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Drawing.Size
<span style="color: #800080;">$System_Drawing_Size</span>.Height <span style="color: pink;">=</span> <span style="color: #804000;">20</span>
<span style="color: #800080;">$System_Drawing_Size</span>.Width <span style="color: pink;">=</span> <span style="color: #804000;">100</span>
<span style="color: #800080;">$txtTerm</span>.Size <span style="color: pink;">=</span> <span style="color: #800080;">$System_Drawing_Size</span>
<span style="color: #800080;">$txtTerm</span>.TabIndex <span style="color: pink;">=</span> <span style="color: #804000;">1</span>
&nbsp;
<span style="color: #800080;">$form1</span>.Controls.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$txtTerm</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;">#endregion Generated Form Code</span>
&nbsp;
<span style="color: #008000;">#Save the initial state of the form</span>
<span style="color: #800080;">$InitialFormWindowState</span> <span style="color: pink;">=</span> <span style="color: #800080;">$form1</span>.WindowState
<span style="color: #008000;">#Init the OnLoad event to correct the initial state of the form</span>
<span style="color: #800080;">$form1</span>.add_Load<span style="color: #000000;">&#40;</span><span style="color: #800080;">$OnLoadForm_StateCorrection</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;">#Show the Form</span>
<span style="color: #800080;">$form1</span>.ShowDialog<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
&nbsp;
<span style="color: #000000;">&#125;</span> <span style="color: #008000;">#End Function</span>
&nbsp;
<span style="color: #008000;">#Call the Function</span>
GenerateForm</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2011/10/oooey-gui-script-searcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell 3.0 &#8211; drool</title>
		<link>http://vmweaver.com/index.php/2011/09/powershell-3-0-drool/</link>
		<comments>http://vmweaver.com/index.php/2011/09/powershell-3-0-drool/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 03:09:20 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=272</guid>
		<description><![CDATA[Okay, so if you live under a rock and haven&#8217;t heard, the CTP for the Windows Management Framework 3.0 has been released by Microsoft (http://www.microsoft.com/download/en/details.aspx?id=27548). I know, you are probably thinking &#8220;Big Deal!!&#8221; another Community Tech Preview. Not so fast there&#8230; THIS CTP includes Powershell 3.0! Let me restate: &#8220;THIS CTP INCLUDES POWERSHELL 3.0!&#8221; What [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so if you live under a rock and haven&#8217;t heard, the CTP for the Windows Management Framework 3.0 has been released by Microsoft (<a href="http://www.microsoft.com/download/en/details.aspx?id=27548">http://www.microsoft.com/download/en/details.aspx?id=27548</a>).</p>
<p>I know, you are probably thinking &#8220;Big Deal!!&#8221; another Community Tech Preview.  Not so fast there&#8230; THIS CTP includes Powershell 3.0!</p>
<p>Let me restate: &#8220;<strong>THIS CTP INCLUDES POWERSHELL 3.0</strong>!&#8221;</p>
<p>What I hope to do is post more as I begin to learn about what is new, what is cool, what is fresh, etc.</p>
<p>A little story about me and Powershell 3.0 &#8230;.</p>
<p>When I found out about the Windows 8 &#8211; Developer Preview, I wasn&#8217;t excited about the new interface, the new look of familiar applications&#8230; no.  After I found out how to actually get to a command prompt, my first thing was to run Powershell and do a:</p>
<p>                        $host.version</p>
<p>To my UTTER DELIGHT, I saw the number &#8220;3&#8243; in the output.  My colleagues, of course, we interested in why I was ooo-ing and ahhh-ing.. then they saw that I was sitting at a Powershell prompt (of course) and the &#8220;geek&#8221;, &#8220;nerd&#8221;, and &#8220;dork&#8221; comments began.</p>
<p>Anyway, needless to say, I soon discovered I could install Powershell 3 on my Windows 7, SP1 laptop at home so I prompty did so upon arriving home from work.</p>
<p>Wow&#8230;that was a longer little story than I was expecting.</p>
<p>The bottom line is that I finally have it installed and have begun playing with it and I am a TOTAL GEEK.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>One of the things I was afraid of was losing my Powershell 2.0 installation, yet I had read that they could co-exist.  Well, seeing is believing, and I am a believer now.</p>
<p>Launching &#8220;powershell.exe&#8221; from a command line, by default, will open up version 3.</p>
<p>Launching &#8220;powershell.exe -version 2&#8243; from a command line will bring up version 2.</p>
<p>Yes, it really is that simple.</p>
<p>Upon a cursory glance at the cmdlets available I notice that there are many more geared toward command line management of the system and features.</p>
<p><em></p>
<p>       get-controlpanelitem</p>
<p>              show-controlpanelitem &#8220;Display&#8221;</p>
<p>              get-counter</p>
<p>	new-webbinding</p>
<p></em></p>
<p>Also there is a cmdlet that helps you explore all of the cmdlets available via a GUI:</p>
<p>	<em>show-command</em></p>
<p>I have, literally, been playing with the new powershell for about an hour, so stay tuned for more updates on this.</p>
<p>Please, everyone, go grab it, kick the tires, run it through its paces, and poke it with a stick.</p>
<p>As always, happy scripting and have a good time discovering Powershell 3.0.</p>
<p> &#8212; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2011/09/powershell-3-0-drool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tag, You&#8217;re It!</title>
		<link>http://vmweaver.com/index.php/2011/07/tag-youre-it/</link>
		<comments>http://vmweaver.com/index.php/2011/07/tag-youre-it/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 03:29:28 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=266</guid>
		<description><![CDATA[This will be part one of two posts to talk about a few little scripts I have been working on to help me search through my script repository. Using dropbox, I have created my own little script repository that is out in the &#8220;cloud&#8221;.  I didn&#8217;t know how much I would like it, but it certainly [...]]]></description>
			<content:encoded><![CDATA[<p>This will be part one of two posts to talk about a few little scripts I have been working on to help me search through my script repository.</p>
<p>Using dropbox, I have created my own little script repository that is out in the &#8220;cloud&#8221;.  I didn&#8217;t know how much I would like it, but it certainly makes it easy for me and others on my team to share the same scripts.</p>
<p>Anyway&#8230;the thought behind this part was to have an easy way to &#8220;tag&#8221; my scripts with information that would make it easier to search all of the scripts I have been working on.</p>
<p>All it is basically doing is creating some well-formed comments that I could then parse out.  As a safety precaution, this version makes a backup copy of the script before modifying it.  If you don&#8217;t want to back it up, just comment out the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">	<span style="color: #008080; font-weight: bold;">Copy-Item</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$Script</span> <span style="color: #008080; font-style: italic;">-Destination</span> <span style="color: #800080;">$BackupScriptPath</span> <span style="color: #008080; font-style: italic;">-Force</span></pre></div></div>

<p>Without further ado, here is the code:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #008000;">##-------------------------------------------------------------------</span>
<span style="color: #008000;">## Script: Add-ScriptTags.ps1</span>
<span style="color: #008000;">## Written by: Mark A. Weaver </span>
<span style="color: #008000;">## Website: vmweaver.com</span>
<span style="color: #008000;">## </span>
<span style="color: #008000;">## Version: 1.0</span>
<span style="color: #008000;">## Creation Date: 7/2/2011</span>
<span style="color: #008000;">## Purpose: This script will be used to add the specified tags to a script file</span>
<span style="color: #008000;">##              It will prepend the tag data to the script text as commented strings.</span>
<span style="color: #008000;">## Markup Definitions:</span>
<span style="color: #008000;">##       _TAG:  - Comma-separated list of tag words</span>
<span style="color: #008000;">##	 _AUTH: - Text with Authors name</span>
<span style="color: #008000;">##       _DESC: - Text with Description  </span>
<span style="color: #008000;">##       _DATE: - DateTime text with last update</span>
<span style="color: #008000;">##       _VER:  - Version number</span>
<span style="color: #008000;">##       _MISC: - Miscellaneous information</span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##    </span>
<span style="color: #008000;">##   Input: </span>
<span style="color: #008000;">##                      -Script &quot;Path to Script you are tagging&quot;</span>
<span style="color: #008000;">##                      -Auth &quot;AUthor Name&quot;</span>
<span style="color: #008000;">##                      -Tag &quot;comma separated list of tags&quot;</span>
<span style="color: #008000;">##			-Desc &quot;Description of the script&quot;</span>
<span style="color: #008000;">##			-Date &quot;Date information&quot;</span>
<span style="color: #008000;">##			-Ver &quot;Script Version&quot;</span>
<span style="color: #008000;">##			-Misc &quot;Miscellaneous information you wish to include&quot;</span>
<span style="color: #008000;">##          </span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##  Output: </span>
<span style="color: #008000;">##	SCript is modified with the information. If this script is run multiple times, this </span>
<span style="color: #008000;">##      information will be over-written.</span>
<span style="color: #008000;">##                 </span>
<span style="color: #008000;">##                              </span>
<span style="color: #008000;">##  Assumptions: </span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##  Example:</span>
<span style="color: #008000;">##  	.\Add-ScriptTags.ps1 -Script ..\MyScript.ps1 -Auth &quot;Mark A. Weaver&quot; </span>
<span style="color: #008000;">##            -Tag &quot;Test,Foo,Blah&quot; -Desc &quot;Test Script&quot; -Ver &quot;1.2&quot;              </span>
<span style="color: #008000;">##               </span>
<span style="color: #008000;">#############################</span>
<span style="color: #008000;">## Updates:</span>
<span style="color: #008000;">##    </span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##----------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Script</span><span style="color: pink;">=</span>$<span style="color: #000000;">&#40;</span><span style="color: #0000FF;">throw</span> <span style="color: #800000;">&quot;Script to tag must be specified!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span><span style="color: #800080;">$Tag</span><span style="color: pink;">,</span> <span style="color: #800080;">$Auth</span><span style="color: pink;">,</span> <span style="color: #800080;">$Desc</span><span style="color: pink;">,</span> <span style="color: #800080;">$Date</span><span style="color: pink;">,</span><span style="color: #800080;">$Ver</span><span style="color: pink;">,</span><span style="color: #800080;">$Misc</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #800080;">$Script</span><span style="color: #000000;">&#41;</span> 
<span style="color: #000000;">&#123;</span>
  <span style="color: #800080;">$Contents</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$Script</span> 
  <span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PostMarkup</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Contents</span>
&nbsp;
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Markup</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Null</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;################################&quot;</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _BEGINMARKUP&quot;</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;####&quot;</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _TAG:&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Tag</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _AUTH:&quot;</span><span style="color: pink;">+</span> <span style="color: #800080;">$Auth</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _DESC:&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Desc</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _DATE:&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Date</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _VER:&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Ver</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _MISC:&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Misc</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;####&quot;</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;## _ENDMARKUP&quot;</span>
	<span style="color: #800080;">$Markup</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;################################&quot;</span>
&nbsp;
 <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;_BEGINMARKUP&quot;</span><span style="color: #000000;">&#41;</span> 
  <span style="color: #000000;">&#123;</span>
	  <span style="color: #800080;">$LineCount</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
	  <span style="color: #800080;">$BeginLine</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
	  <span style="color: #800080;">$EndLine</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
	  <span style="color: #0000FF;">Foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Line</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Contents</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #000000;">&#123;</span>
&nbsp;
	    <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Line</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800000;">&quot;_BEGINMARKUP&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #800080;">$BeginLine</span> <span style="color: pink;">=</span> <span style="color: #800080;">$LineCount</span> <span style="color: pink;">-</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Line</span> <span style="color: #FF0000;">-imatch</span> <span style="color: #800000;">&quot;_ENDMARKUP&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$EndLine</span> <span style="color: pink;">=</span> <span style="color: #800080;">$LineCount</span> <span style="color: pink;">+</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#125;</span>
		 <span style="color: #800080;">$LineCount</span> <span style="color: pink;">+=</span> <span style="color: #804000;">1</span>
       <span style="color: #000000;">&#125;</span>
	  <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$BeginLine</span> <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #000000;">&#123;</span>
	    <span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PreMarkup</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Null</span>
	  <span style="color: #000000;">&#125;</span>
	  <span style="color: #0000FF;">else</span>
	  <span style="color: #000000;">&#123;</span>
&nbsp;
&nbsp;
	   <span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PreMarkup</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Contents</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span>..<span style="color: #000000;">&#40;</span><span style="color: #800080;">$BeginLine</span> <span style="color: pink;">-</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	  <span style="color: #000000;">&#125;</span>
&nbsp;
	  <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$EndLine</span> <span style="color: #FF0000;">-eq</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span>.count <span style="color: pink;">-</span><span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	  <span style="color: #000000;">&#123;</span>
         <span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PostMarkup</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Null</span>
	  <span style="color: #000000;">&#125;</span>
	  <span style="color: #0000FF;">else</span>
	  <span style="color: #000000;">&#123;</span>
	     <span style="color: #000000;">&#91;</span><span style="color: #008080;">array</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PostMarkup</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Contents</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$EndLine</span><span style="color: pink;">+</span><span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>..<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Contents</span>.count <span style="color: pink;">-</span><span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	  <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #800080;">$MarkedUpScript</span> <span style="color: pink;">=</span> <span style="color: #800080;">$PreMarkup</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Markup</span> <span style="color: pink;">+</span> <span style="color: #800080;">$PostMarkup</span>
	<span style="color: #800080;">$ScriptObject</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Item</span> <span style="color: #800080;">$Script</span>
	<span style="color: #800080;">$BackupName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Backup_&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$ScriptObject</span>.Name
	<span style="color: #800080;">$BackupScriptPath</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ScriptObject</span>.DirectoryName <span style="color: pink;">+</span><span style="color: #800000;">&quot;\&quot;</span><span style="color: pink;">+</span> <span style="color: #800080;">$BackupName</span>
&nbsp;
	<span style="color: #008080; font-weight: bold;">Copy-Item</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$Script</span> <span style="color: #008080; font-style: italic;">-Destination</span> <span style="color: #800080;">$BackupScriptPath</span> <span style="color: #008080; font-style: italic;">-Force</span>
	<span style="color: #008080; font-weight: bold;">Out<span style="color: #FF0000;">-File</span></span> <span style="color: #008080; font-style: italic;">-FilePath</span> <span style="color: #800080;">$Script</span> <span style="color: #008080; font-style: italic;">-InputObject</span> <span style="color: #800080;">$MarkedupScript</span> <span style="color: #008080; font-style: italic;">-Force</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;--- Markup written to '$($Script)' ---&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Green
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;--- (Backup: '$($BackupName)') ---&quot;</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> DarkYellow
        <span style="color: #800080;">$Markup</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">ForEach-Object</span><span style="color: #000000;">&#123;</span><span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #000080;">$_</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> DarkGreen<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">Throw</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Script file &quot;</span><span style="color: #800000;">&quot;$Script&quot;</span><span style="color: #800000;">&quot; does not exist.&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Hope this makes sense for you.. and stay tuned for the next post which will be on processing these files and searching a repository for scripts.<br />
As always&#8230; Happy Scripting!<br />
&#8212; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2011/07/tag-youre-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Give me some DATA! (with Powershell)</title>
		<link>http://vmweaver.com/index.php/2011/03/sql-data-with-powershell/</link>
		<comments>http://vmweaver.com/index.php/2011/03/sql-data-with-powershell/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 02:44:30 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=252</guid>
		<description><![CDATA[Ah&#8230;wow.. has it really been over a YEAR since I last post? Sorry about that, but it has been an absolutely nutty year. Anyway.. In my new job and new role, I get to have fun showing people the power of automation with Powershell. One of the recent tasks I was helping with is to [...]]]></description>
			<content:encoded><![CDATA[<p>Ah&#8230;wow.. has it really been over a YEAR since I last post?  Sorry about that, but it has been an absolutely nutty year.</p>
<p>Anyway..<br />
In my new job and new role, I get to have fun showing people the power of automation with Powershell.<br />
One of the recent tasks I was helping with is to take a list of users (from AD) and query a database to get some info about these users.</p>
<p>While I had done some work with SQL queries with Powershell, I hadn&#8217;t ever &#8220;functionalized&#8221; it, so I decided to take this opportunity to do so.</p>
<p>While I am sure there are a bazillion examples of this out there, this is what I came up with and here is what it looks like.<br />
Sorry there aren&#8217;t many (any) in-line comments like I normally do, but if you have questions, please let me know!<br />
Thanks and hope you find this helpful.</p>
<p>As always&#8230; Happy Scripting!<br />
&#8211; Mark</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">##-------------------------------------------------------------------</span>
<span style="color: #008000;">## Script: Get-SQLData.ps1</span>
<span style="color: #008000;">## Written by: Mark A. Weaver </span>
<span style="color: #008000;">## Website: vmweaver.com</span>
<span style="color: #008000;">## </span>
<span style="color: #008000;">## Version: 1.0</span>
<span style="color: #008000;">## Creation Date: 3/16/2011</span>
<span style="color: #008000;">## Purpose: This is really a function that you pass 3 parameters to. It will connect to the </span>
<span style="color: #008000;">##          SQL Server you specify, to the Database you specify, and execute the</span>
<span style="color: #008000;">##          query you specify.</span>
<span style="color: #008000;">##          This connects with you existing credentials (integrated).</span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##    </span>
<span style="color: #008000;">##   Input: </span>
<span style="color: #008000;">##                      -SQLServer &quot;Name of your sql server&quot;</span>
<span style="color: #008000;">##                      -Database &quot;Name of your database&quot;</span>
<span style="color: #008000;">##                      -Query &quot;your query&quot;</span>
<span style="color: #008000;">##     *Note if you want to have a query that spans multiple lines, etc, you can pass in a </span>
<span style="color: #008000;">##      'here-string' or construct another multi-line (not array) string.</span>
<span style="color: #008000;">##          </span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##  Output: </span>
<span style="color: #008000;">##      An array is passed back containing the data from your query.</span>
<span style="color: #008000;">##      If no data is returned, the array will be $null</span>
<span style="color: #008000;">##                 </span>
<span style="color: #008000;">##                              </span>
<span style="color: #008000;">##  Assumptions: </span>
<span style="color: #008000;">##               </span>
<span style="color: #008000;">##               </span>
<span style="color: #008000;">#############################</span>
<span style="color: #008000;">## Updates:</span>
<span style="color: #008000;">##    </span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##----------------------------------------------------------------------</span>
<span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>SQLData
<span style="color: #000000;">&#123;</span>
   <span style="color: #0000FF;">param</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$SQLServer</span><span style="color: pink;">,</span>
          <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Database</span><span style="color: pink;">,</span>
          <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Query</span><span style="color: #000000;">&#41;</span>    
&nbsp;
        <span style="color: #800080;">$SQLData</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>     
        <span style="color: #800080;">$SqlConnection</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Data.SqlClient.SqlConnection
        <span style="color: #800080;">$SqlConnection</span>.ConnectionString <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Server = $SqlServer; Database = $Database; Integrated Security = True&quot;</span>
        <span style="color: #800080;">$SqlCmd</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Data.SqlClient.SqlCommand
        <span style="color: #800080;">$SqlCmd</span>.CommandText <span style="color: pink;">=</span> <span style="color: #800080;">$Query</span>
        <span style="color: #800080;">$SqlCmd</span>.Connection <span style="color: pink;">=</span> <span style="color: #800080;">$SqlConnection</span>
        <span style="color: #800080;">$SqlAdapter</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Data.SqlClient.SqlDataAdapter
        <span style="color: #800080;">$SqlAdapter</span>.SelectCommand <span style="color: pink;">=</span> <span style="color: #800080;">$SqlCmd</span>
        <span style="color: #800080;">$DataSet</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Data.DataSet
        <span style="color: #800080;">$SqlAdapter</span>.Fill<span style="color: #000000;">&#40;</span><span style="color: #800080;">$DataSet</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
        <span style="color: #800080;">$SqlConnection</span>.Close<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #800080;">$RecordCount</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$DataSet</span>.tables<span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span><span style="color: #000000;">&#41;</span>.count
        <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$RecordCount</span> <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$SQLData</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Null</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0000FF;">else</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #800080;">$SQLData</span> <span style="color: pink;">=</span> <span style="color: #800080;">$DataSet</span>.tables<span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> 
        <span style="color: #000000;">&#125;</span>
  <span style="color: #0000FF;">return</span> <span style="color: #800080;">$SQLData</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2011/03/sql-data-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell and Unknown User SIDs</title>
		<link>http://vmweaver.com/index.php/2009/10/powershell-and-unknown-user-sids/</link>
		<comments>http://vmweaver.com/index.php/2009/10/powershell-and-unknown-user-sids/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 18:01:19 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[AD]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[User Management]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=204</guid>
		<description><![CDATA[Once again, my apologies for my lack of posting.. Anyway&#8230; An interesting thing came up at work the other day when one of my fellow administrators asked me if I could resolve an unknown SID he was seeing in some logs to see what the heck it belonged to. Since I had been telling him [...]]]></description>
			<content:encoded><![CDATA[<p>Once again, my apologies for my lack of posting..</p>
<p>Anyway&#8230;</p>
<p>An interesting thing came up at work the other day when one of my fellow administrators asked me if I could resolve an unknown SID he was seeing in some logs to see what the heck it belonged to.</p>
<p>Since I had been telling him that Powershell could do ANYTHING (slight exaggeration, I know)&#8230; that it should be able to do this.</p>
<p>Well, it certainly is an interesting notion.</p>
<p>I know that I have run into this in the past where you have file system ACLs set and there are a bunch of SIDs sitting in there that nobody seems to know who they belong to.</p>
<p>While it isn&#8217;t THAT important to resolve them since the user account is most likely no longer around, it IS an interesting thought exercise.</p>
<p>After perusing the web looking for others who have done something similar, I feel I had enough to throw something together..</p>
<p>Basically when an Active Directory object (like a user) is &#8220;deleted&#8221;, it is really just Tombstoned for a period of time and is moved to the hidden container &#8220;Deleted Objects&#8221; and then removed after like 90 days or so.</p>
<p>Here is my solution to &#8220;finding&#8221; those objects.</p>
<p>First you will have to know what Domain you want to look at for this object AND you have know the SID you are looking for.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">function</span> Resolve<span style="color: pink;">-</span>DeletedUserSID<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Domain</span><span style="color: pink;">,</span> <span style="color: #800080;">$UserSID</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;">## This is kind of a mashup of a few different scripts I found online in some forums.</span>
	<span style="color: #008000;">## Unfortunately I don't remember who did them.  If it was you, point me to your post and I will</span>
	<span style="color: #008000;">## give you the credit for your piece.</span>
	<span style="color: #008000;">## </span>
	<span style="color: #008000;">## Returns User information for deleted account with the specified SID and User Domain</span>
&nbsp;
	<span style="color: #800080;">$DomainRoot</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LDAP://&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Domain</span>.trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$DomainDN</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>adsi<span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#40;</span> <span style="color: #800080;">$DomainRoot</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.DistinguishedName
	<span style="color: #800080;">$adspath</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LDAP://&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$DomainDN</span>
	<span style="color: #800080;">$root</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.Directoryentry<span style="color: #000000;">&#93;</span> <span style="color: #800080;">$Adspath</span>
	<span style="color: #800080;">$root</span>.psbase.AuthenticationType <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.authenticationtypes<span style="color: #000000;">&#93;</span>::Fastbind
	<span style="color: #008000;">## We will be looking in the &quot;Deleted Objects&quot; container which is normally hidden, etc.</span>
	<span style="color: #008000;">## You will need to execute this with an account that has DomainAdmin rights to the domain you are</span>
	<span style="color: #008000;">## querying.</span>
	<span style="color: #800080;">$root</span>.psbase.path <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LDAP://cn=Deleted Objects,&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$DomainDN</span>
	<span style="color: #800080;">$search</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.directorysearcher<span style="color: #000000;">&#93;</span> <span style="color: #800080;">$root</span>
	<span style="color: #800080;">$search</span>.<span style="color: #0000FF;">filter</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;(&amp;(isDeleted=TRUE)(!(objectClass=computer))(objectclass=user))&quot;</span>
	<span style="color: #800080;">$search</span>.Tombstone <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
&nbsp;
	<span style="color: #008000;"># If you have more than 1000 users, you must NOT define SizeLimit (we haven't)</span>
	<span style="color: #008000;"># and PageSize must be less than the default value (of 1000). </span>
	<span style="color: #008000;"># I found this a bit strange...but as long as we understand it, I guess it is okay</span>
	<span style="color: #800080;">$Search</span>.PageSize <span style="color: pink;">=</span> <span style="color: #804000;">500</span>
&nbsp;
	<span style="color: #008000;"># Only look in the top level of the Deleted Objects container.</span>
	<span style="color: #800080;">$search</span>.SearchScope <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.directoryservices.searchscope<span style="color: #000000;">&#93;</span>::OneLevel
	<span style="color: #800080;">$result</span> <span style="color: pink;">=</span> <span style="color: #800080;">$search</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;"># If the SID isn't found, you will get nothing returned.</span>
	<span style="color: #800080;">$result</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-Object</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Name&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Name&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `
	<span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;SAMAccountName&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;SAMAccountName&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `
	<span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;SID&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Security.Principal.SecurityIdentifier<span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;ObjectSID&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `
	<span style="color: pink;">@</span><span style="color: #000000;">&#123;</span> Name <span style="color: pink;">=</span> <span style="color: #800000;">&quot;WhenChanged&quot;</span> ; Expression <span style="color: pink;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.Properties.Item<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;WhenChanged&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span> `
	<span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">where-Object</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.SID <span style="color: #FF0000;">-ieq</span> <span style="color: #800080;">$UserSid</span>.Trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>As always&#8230;</p>
<p>Happy Scripting!!!! and let me know if you have questions or problems.</p>
<p>&#8211; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2009/10/powershell-and-unknown-user-sids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

