<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>CodeKeep PowerShell Feed</title>
    <description>The latest and greatest PowerShell code snippets publicly available</description>
    <link>http://www.codekeep.net/feeds.aspx</link>
    <lastBuildDate>Wed, 13 Jun 2012 14:37:16 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>RSS.NET: http://www.rssdotnet.com/</generator>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CodeKeepPowerShell" /><feedburner:info uri="codekeeppowershell" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>Killing a Hanging Service</title>
      <description>Description: Commands to kill a Hung / Hanging windows Service&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/a317fda1-0b93-47d4-bdbf-e1e8661294d9.aspx'&gt;http://www.codekeep.net/snippets/a317fda1-0b93-47d4-bdbf-e1e8661294d9.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;C:\Documents and Settings\Administrator&amp;gt;sc queryex ServiceName

SERVICE_NAME: ServiceName
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 2  START_PENDING
                                (STOPPABLE,NOT_PAUSABLE,ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 2364
        FLAGS              :

C:\Documents and Settings\Administrator&amp;gt;taskkill /F  /PID 2364
SUCCESS: The process with PID 2364 has been terminated.&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/Us3hV7qVkpc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/Us3hV7qVkpc/a317fda1-0b93-47d4-bdbf-e1e8661294d9.aspx</link>
      <pubDate>Wed, 13 Jun 2012 14:37:16 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/a317fda1-0b93-47d4-bdbf-e1e8661294d9.aspx</feedburner:origLink></item>
    <item>
      <title>GetInstalledPrograms</title>
      <description>Description: get a list of all installed programs&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/dd48dff8-b1da-4120-919a-9b17bde06075.aspx'&gt;http://www.codekeep.net/snippets/dd48dff8-b1da-4120-919a-9b17bde06075.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;    function Get-InstalledPrograms($computer = '.') { $programs_installed = @{}; $win32_product = @(get-wmiobject -class 'Win32_Product' -computer $computer); foreach ($product in $win32_product) { $name = $product.Name; $version = $product.Version; if ($name -ne $null) { $programs_installed.$name = $version; } } return $programs_installed; } 
&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/xmlEq9XmE8o" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/xmlEq9XmE8o/dd48dff8-b1da-4120-919a-9b17bde06075.aspx</link>
      <pubDate>Fri, 27 Jan 2012 14:29:32 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/dd48dff8-b1da-4120-919a-9b17bde06075.aspx</feedburner:origLink></item>
    <item>
      <title>Create Event Source</title>
      <description>Description: Create Event Source&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/bb33c747-36d9-42ed-aff5-8cafd4d1bc34.aspx'&gt;http://www.codekeep.net/snippets/bb33c747-36d9-42ed-aff5-8cafd4d1bc34.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;new-eventlog -source ScheduledTasks -logname Application
write-eventlog -logname Application -source ScheduledTasks -eventID 1000 -entrytype Information -message &amp;quot;Test&amp;quot;&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/Ib0AChClPwU" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/Ib0AChClPwU/bb33c747-36d9-42ed-aff5-8cafd4d1bc34.aspx</link>
      <pubDate>Mon, 16 Jan 2012 00:48:01 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/bb33c747-36d9-42ed-aff5-8cafd4d1bc34.aspx</feedburner:origLink></item>
    <item>
      <title>Reset FireFox Profile </title>
      <description>Description: Helps if FireBug wacks out...&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/ff85a954-c540-4062-9f4d-7f715397a58a.aspx'&gt;http://www.codekeep.net/snippets/ff85a954-c540-4062-9f4d-7f715397a58a.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;Installing in a clean profile

To test for bugs regarding interactions with other extensions or corrupted profiles, you should do the following.

Firefox and Firebug re-install rarely fixes problems because the configuration files are not altered on reinstall. So to clear out the configuration files you need to create a new Firefox profile:
[edit] Linux Way

    Exit Firefox
    Get to a command line
    Run Firefox with -ProfileManager 

 $ firefox -ProfileManager

    Create New Profile
    Start Firefox with your new profile
    Load Firebug into this clean profile. 

[edit] Windows Way

    Exit Firefox
    Get to a command line
        Windows: Start-&amp;gt;Run-&amp;gt;&amp;quot;cmd&amp;quot; enter 
    Run Firefox with -ProfileManager (use quotes around the file name because of the spaces) 

 &amp;quot;C:\Program Files\Mozilla Firefox\firefox.exe&amp;quot; -ProfileManager

    Create New Profile
    Start Firefox with your new profile
    Load Firebug into this clean profile. &lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/ROQdUD6POZY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/ROQdUD6POZY/ff85a954-c540-4062-9f4d-7f715397a58a.aspx</link>
      <pubDate>Sat, 19 Nov 2011 13:11:30 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/ff85a954-c540-4062-9f4d-7f715397a58a.aspx</feedburner:origLink></item>
    <item>
      <title>Scheduling a Powershell Script</title>
      <description>Description: Setting the "Action" for Scheduling a Powershell Script with arguments&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/cf09585a-bf13-429d-a481-8b36b5f14144.aspx'&gt;http://www.codekeep.net/snippets/cf09585a-bf13-429d-a481-8b36b5f14144.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;#Assumptions
#-Arg1 is a file path

#Program  : 
Powershell.exe
#Arguments: 
-nolog -command &amp;quot;&amp;amp;{.\myPSScript.ps1 -Arg1 &amp;quot;.\myfilepath&amp;quot;}&amp;quot;&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/3o46N9eQ7FQ" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/3o46N9eQ7FQ/cf09585a-bf13-429d-a481-8b36b5f14144.aspx</link>
      <pubDate>Wed, 02 Nov 2011 14:32:57 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/cf09585a-bf13-429d-a481-8b36b5f14144.aspx</feedburner:origLink></item>
    <item>
      <title>Load vs2010 environment variables</title>
      <description>Description: run the vs2010 command prompt batch file to add those values to the local ps environment&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/9ee3f3a2-2d7c-4b69-a711-516ff2531ce6.aspx'&gt;http://www.codekeep.net/snippets/9ee3f3a2-2d7c-4b69-a711-516ff2531ce6.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;#remove-item alias:\devenv -force
$private:defaultvs2010path=&amp;quot;D:\Program Files (x86)\Microsoft Visual Studio 10.0&amp;quot;
if(test-path $defaultvs2010path){
    $vs2010path=$defaultvs2010path 
    if(join-path $vs2010path &amp;quot;vc\vcvarsall.bat&amp;quot; | test-path)
    {
        function VS-CmdPrompt()
        {
            #%comspec% /k &amp;quot;&amp;quot;D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat&amp;quot;&amp;quot;
            $private:vsvarsallbatPath=join-path $vs2010path &amp;quot;\VC\vcvarsall.bat&amp;quot;
            if(!(test-path $vsvarsallbatPath)){
                $(throw &amp;quot;Vsvarsall.bat not found at :&amp;quot;+$vsvarsallbatPath)
            } else {
                &amp;amp; ($vsvarsallbatPath)
            }
    }
    }    
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/lmcQSJQwcuA" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/lmcQSJQwcuA/9ee3f3a2-2d7c-4b69-a711-516ff2531ce6.aspx</link>
      <pubDate>Tue, 04 Oct 2011 15:30:06 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/9ee3f3a2-2d7c-4b69-a711-516ff2531ce6.aspx</feedburner:origLink></item>
    <item>
      <title>Launch VS2010</title>
      <description>Description: different options for opening VS2010 with flags&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/ac3da136-e1b9-4784-baeb-3cb0f19a73a4.aspx'&gt;http://www.codekeep.net/snippets/ac3da136-e1b9-4784-baeb-3cb0f19a73a4.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;$private:defaultvs2010path=&amp;quot;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE&amp;quot;

#remove-item alias:\devenv -force

if(test-path $defaultvs2010path){
    $vs2010=$defaultvs2010path
}

if(!(get-alias | where-object {$_.Name -match &amp;quot;devenv&amp;quot;}) -and (Join-Path $vs2010 &amp;quot;devenv.exe&amp;quot; | test-path))
{
    set-alias devenv (Join-Path $vs2010 &amp;quot;devenv.exe&amp;quot;) -option readonly
}
if(!(get-alias devenv))
{
    set-alias devenv = $(throw &amp;quot;devenv.exe was not found&amp;quot;)
}

function VS-DevEnv([Parameter(Position=0)][string] $fileToOpen=((gci alias:\devenv).definition),[switch]$safemode,[switch]$frameworkDebug,[switch] $WhatIf,
[Parameter(Position=1,ParameterSetName=&amp;quot;log&amp;quot;)]$log=$false) 
{
    [string[]]$private:args2 = @()
    if($frameworkDebug -and $env.COMPLUS_ZapDisable -and ($env.COMPLUS_ZapDisable -ne 1))
    {
    write-host &amp;quot;setting frameworkdebug&amp;quot;
        #http://blogs.msdn.com/b/kirillosenkov/archive/2009/01/27/how-to-disable-optimizations-during-debugging.aspx
        #http://www.cplotts.com/2009/01/07/disabling-optimizations-when-debugging-net-framework-source-code/
        if($WhatIf -eq $false)
        {
           $env.COMPLUS_ZapDisable=1
           write-host &amp;quot;You must disable the Visual Studio Hosting process in the project&amp;quot;
        } else {
             write-host '$env.COMPLUS_ZapDisable=1'
        }
        
    }
    if($safemode)
    {
        $args2+=&amp;quot;/safemode&amp;quot;
        write-host &amp;quot;set safemode&amp;quot;
    }
    
    #$logCmd=&amp;quot;&amp;quot;
    if($PSCmdlet.ParameterSetName -eq &amp;quot;log&amp;quot; -and $log -ne $false)
    {
        write-host &amp;quot;set logging&amp;quot;
        #$args2 +=@(&amp;quot;/log&amp;quot;, &amp;quot;&amp;quot;&amp;quot;C:\temp\vs2010log.xml&amp;quot;&amp;quot;&amp;quot;)
    
    
        $private:stamp=get-date -f &amp;quot;yyyyMMdd.hhmmss&amp;quot; 
        $logPath=&amp;quot;C:\temp\devenv&amp;quot;+$stamp+&amp;quot;.xml&amp;quot;
        $args2 +=@(&amp;quot;/log&amp;quot;, &amp;quot;&amp;quot;&amp;quot;$logPath&amp;quot;&amp;quot;&amp;quot;)
    #    $logCmd=&amp;quot;/log &amp;quot;+$logPath
        write-host &amp;quot;Writing to $logPath&amp;quot;
    }
    
   
    if($WhatIf)
    {
     echo $filetoOpen @args2
    #    write-host &amp;quot;$filetoopen&amp;quot; @args
    } else {
     &amp;amp; $filetoopen @args2  
    }
    
    
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/R4EV7EqCUWI" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/R4EV7EqCUWI/ac3da136-e1b9-4784-baeb-3cb0f19a73a4.aspx</link>
      <pubDate>Tue, 04 Oct 2011 14:55:45 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/ac3da136-e1b9-4784-baeb-3cb0f19a73a4.aspx</feedburner:origLink></item>
    <item>
      <title>CreateZipFile</title>
      <description>Description: Creates a zip file, that is ready for files to be copied into&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/3eab9dec-378b-4d60-9c84-153a4c298e98.aspx'&gt;http://www.codekeep.net/snippets/3eab9dec-378b-4d60-9c84-153a4c298e98.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function CreateNewZip{
#http://blogs.msdn.com/b/stuartleeks/archive/2009/08/13/powershell-script-to-clean-and-zip-a-directory.aspx
param (
     [Parameter(Mandatory=$true)]
     [string] $zipPath
    )
    if(test-path $zipPath) {$(throw &amp;quot;Zip file already exists at &amp;quot;+$zipPath); return}
    set-content $zipPath (&amp;quot;PK&amp;quot; + [char]5 + [char]6 + (&amp;quot;$([char]0)&amp;quot; * 18))
    (dir $Zippath).IsReadOnly= $false
    #if((dir $zipfi
    return (new-object -com shell.application).NameSpace($zipPath)
    }&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/5_vhYj18vsE" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/5_vhYj18vsE/3eab9dec-378b-4d60-9c84-153a4c298e98.aspx</link>
      <pubDate>Thu, 22 Sep 2011 23:01:38 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/3eab9dec-378b-4d60-9c84-153a4c298e98.aspx</feedburner:origLink></item>
    <item>
      <title>Get-NewestDirectory</title>
      <description>Description: get the directory with the newest modified date&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/42095253-6882-43ee-a0d6-5848a55a2423.aspx'&gt;http://www.codekeep.net/snippets/42095253-6882-43ee-a0d6-5848a55a2423.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function Get-NewestDirectory{
param (
    [string] $path = $(throw &amp;quot;Path is required&amp;quot;)
)
    gci $path `
    | ? {$_.PSIsContainer} `
    | select Name,LastWriteTime `
    | sort-object lastwriteTime -descending `
    | select-object -first 1
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/L4MbxdKzPsk" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/L4MbxdKzPsk/42095253-6882-43ee-a0d6-5848a55a2423.aspx</link>
      <pubDate>Thu, 22 Sep 2011 23:00:54 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/42095253-6882-43ee-a0d6-5848a55a2423.aspx</feedburner:origLink></item>
    <item>
      <title>PSUsing</title>
      <description>Description: a .net style using clause&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/b287e788-3a2e-4105-9131-1c33f2e282db.aspx'&gt;http://www.codekeep.net/snippets/b287e788-3a2e-4105-9131-1c33f2e282db.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function PSUsing {
    param (
        [System.IDisposable] $inputObject = $(throw &amp;quot;The parameter -inputObject is required.&amp;quot;),
        [ScriptBlock] $scriptBlock = $(throw &amp;quot;The parameter -scriptBlock is required.&amp;quot;)
    )
    
    Try {
        &amp;amp;$scriptBlock
    } Finally {
        if ($inputObject -ne $null) {
            if ($inputObject.psbase -eq $null) {
                $inputObject.Dispose()
            } else {
                $inputObject.psbase.Dispose()
            }
        }
    }
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/Z347JIbywi4" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/Z347JIbywi4/b287e788-3a2e-4105-9131-1c33f2e282db.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:35:27 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/b287e788-3a2e-4105-9131-1c33f2e282db.aspx</feedburner:origLink></item>
    <item>
      <title>DataRowToCompareableObject</title>
      <description>Description: http://podcast.acoupleofadmins.com/media/Scripts/Compare-QueryResults.ps1
This function breaks each data row up into an object for each field in the row.
the name property is the column name and the value property is the field value&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/262baf7a-1d22-48ee-bf69-9a642b57d12a.aspx'&gt;http://www.codekeep.net/snippets/262baf7a-1d22-48ee-bf69-9a642b57d12a.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function DataRowToCompareableObject()
{
	Process
	{
		$_.psobject.properties | select name, value  
	}
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/MeJgU_osJVI" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/MeJgU_osJVI/262baf7a-1d22-48ee-bf69-9a642b57d12a.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:34:55 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/262baf7a-1d22-48ee-bf69-9a642b57d12a.aspx</feedburner:origLink></item>
    <item>
      <title>SaveDatasetToTempFile</title>
      <description>Description: Save a dataset off to a temp file, for WinMerge to come and compare it with something else&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/2f31f9ac-f600-4707-a795-f9a69e927c06.aspx'&gt;http://www.codekeep.net/snippets/2f31f9ac-f600-4707-a795-f9a69e927c06.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function SaveAsTempFile([System.Data.DataSet] $item) {
    $tmp1=[System.IO.Path]::GetTempFileName()
    Write-progress -activity &amp;quot;SaveAsTempFile&amp;quot; -status &amp;quot;GotTempFileName&amp;quot;
     $item.WriteXML($tmp1)
    Write-progress -activity &amp;quot;SaveAsTempFile&amp;quot; -status &amp;quot;WroteContent&amp;quot;
    return $tmp1
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/jUaV-6VGAw0" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/jUaV-6VGAw0/2f31f9ac-f600-4707-a795-f9a69e927c06.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:33:26 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/2f31f9ac-f600-4707-a795-f9a69e927c06.aspx</feedburner:origLink></item>
    <item>
      <title>LoadAssemblyWithNoLocking</title>
      <description>Description: load an assembly into memory without locking the file&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/49df20da-7fe6-49e4-960d-4c9f9ae7342b.aspx'&gt;http://www.codekeep.net/snippets/49df20da-7fe6-49e4-960d-4c9f9ae7342b.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function LoadAssemblyWithNoLock{
    param(
        [string] $path= $(throw &amp;quot;The parameter -path is required.&amp;quot;)
        )

    $Private:fileStream=([System.IO.FileInfo] (Get-Item $path)).OpenRead()
    $Private:assemblyBytes=new-object byte[] $fileStream.Length
    $fileStream.Read($assemblyBytes, 0, $fileStream.Length)
    $fileStream.Close()
    [System.Reflection.Assembly]::Load($assemblyBytes);
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/ODXBsykWYqo" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/ODXBsykWYqo/49df20da-7fe6-49e4-960d-4c9f9ae7342b.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:32:28 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/49df20da-7fe6-49e4-960d-4c9f9ae7342b.aspx</feedburner:origLink></item>
    <item>
      <title>Serialize to JSon</title>
      <description>Description: failed on datatable/dataset recursive reference, but works for other types&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/fbb42125-555c-4eb9-ba0c-8b5a3a06acde.aspx'&gt;http://www.codekeep.net/snippets/fbb42125-555c-4eb9-ba0c-8b5a3a06acde.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function ConvertTo-Json([object] $item)
{
    
    Process
    {
        add-type -assembly system.web.extensions
        $js=new-object system.web.script.serialization.javascriptSerializer
        $js.Serialize($item)
    }
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/HF5pDJv6tP8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/HF5pDJv6tP8/fbb42125-555c-4eb9-ba0c-8b5a3a06acde.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:31:42 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/fbb42125-555c-4eb9-ba0c-8b5a3a06acde.aspx</feedburner:origLink></item>
    <item>
      <title>script WinMerge</title>
      <description>Description: call winmerge&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/46a62aaf-bce3-4c84-9eec-dbeef4d5ebae.aspx'&gt;http://www.codekeep.net/snippets/46a62aaf-bce3-4c84-9eec-dbeef4d5ebae.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;$winMerge=&amp;quot;C:\Program Files (x86)\WinMerge\WinMergeU.exe&amp;quot;
function WinMergeCompareFiles ( [string] $path1, [string] $path2)
{
    &amp;amp; $winMerge /u /wl /wr  $path1 $path2
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/m_L-hs6duPg" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/m_L-hs6duPg/46a62aaf-bce3-4c84-9eec-dbeef4d5ebae.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:30:49 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/46a62aaf-bce3-4c84-9eec-dbeef4d5ebae.aspx</feedburner:origLink></item>
    <item>
      <title>run Sql Query</title>
      <description>Description: Run a sql query and return a dataset&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/213bd54e-8fb1-4e77-b8c2-afd06de80dec.aspx'&gt;http://www.codekeep.net/snippets/213bd54e-8fb1-4e77-b8c2-afd06de80dec.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function Run-Query()
{
	param (
	$SqlQuery,
	$SqlServer,
	$SqlCatalog
	)
	
	$SqlConnString = &amp;quot;Server = $SqlServer; Database = $SqlCatalog; Integrated Security =SSPI;&amp;quot;
	$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
	$SqlConnection.ConnectionString = $SqlConnString
	
	$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
	$SqlCmd.CommandText = $SqlQuery
	$SqlCmd.Connection = $SqlConnection
	
	$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
	$SqlAdapter.SelectCommand = $SqlCmd
	
	$DataSet = New-Object System.Data.DataSet
	$Private:a = $SqlAdapter.Fill($DataSet)
	
	$SqlConnection.Close()
	
	return $DataSet
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/T3OeUgAZiwU" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/T3OeUgAZiwU/213bd54e-8fb1-4e77-b8c2-afd06de80dec.aspx</link>
      <pubDate>Thu, 22 Sep 2011 15:27:30 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/213bd54e-8fb1-4e77-b8c2-afd06de80dec.aspx</feedburner:origLink></item>
    <item>
      <title>Delete all event log entries</title>
      <description>Description: Batch file and Powershell Script to delete the event long entries&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/beb5e606-0e63-4815-9c06-c16216993882.aspx'&gt;http://www.codekeep.net/snippets/beb5e606-0e63-4815-9c06-c16216993882.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;REM Batch File to delete all event long entries
powershell Set-ExecutionPolicy unrestricted
powershell -file &amp;quot;C:\DevTools\PowerShell Scripts\clearEventLog.ps1&amp;quot;
@pause Press [Enter] to continue

----------------------------------------------------------------------------------

Write-Host &amp;quot;Clearing Application, System, Powershell, Security, and Tumbleweed event logs&amp;quot;
$log=get-eventlog -list|?{$_.log -eq &amp;quot;Application&amp;quot;}
$log.clear()
Write-Host &amp;quot;     Application Log Cleared&amp;quot;
$log=get-eventlog -list|?{$_.log -eq &amp;quot;System&amp;quot;}
$log.clear()
Write-Host &amp;quot;     System Log Cleared&amp;quot;
$log=get-eventlog -list|?{$_.log -eq &amp;quot;Tumbleweed&amp;quot;}
$log.clear()
Write-Host &amp;quot;     Tumbleweed Log Cleared&amp;quot;
$log=get-eventlog -list|?{$_.log -eq &amp;quot;Security&amp;quot;}
$log.clear()
Write-Host &amp;quot;     Security Log Cleared&amp;quot;

$log=get-eventlog -list|?{$_.log -eq &amp;quot;Windows PowerShell&amp;quot;}
$log.clear()
Write-Host &amp;quot;     Powershell Log Cleared&amp;quot;
Write-Host | Get-EventLog -List
&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/qvO51WezEXs" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/qvO51WezEXs/beb5e606-0e63-4815-9c06-c16216993882.aspx</link>
      <pubDate>Thu, 28 Jul 2011 07:41:23 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/beb5e606-0e63-4815-9c06-c16216993882.aspx</feedburner:origLink></item>
    <item>
      <title>Delete All Temp Files</title>
      <description>Description: Batch File and Powershell script to delete all temp files&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/69dc3aa6-6ce4-4fb2-8baa-916b31fe3580.aspx'&gt;http://www.codekeep.net/snippets/69dc3aa6-6ce4-4fb2-8baa-916b31fe3580.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;REM Batch File to Start Powershell Script
@echo off
@Echo Deleting Temp Files
powershell Set-ExecutionPolicy unrestricted
powershell -file &amp;quot;C:\DevTools\PowerShell Scripts\DeleteAllTempFiles.ps1&amp;quot;
@pause Press any key to continue..

----------------------------------------------------------------------------------
#==================================================================================
# Delete_Temp_Files_W7.ps1
#
# Author: Bill Clark (http://bitsoftech.net/)
#
# This script deletes all files in all users' Temp and Temporary Internet Files
# folders on a Windows Vista or Windows 7 machine.
#
#==================================================================================
 
&amp;lt;#
 
.SYNOPSIS
 
Deletes all files and subdirectories in %UserProfile%\AppData\Local\Temp and
%UserProfile%\AppData\Local\Microsoft\Windows\Temporary Internet Files for all user
profiles on the machine.
 
.PARAMETER
 
No parameters are accepted by this script.
 
.EXAMPLE
 
Delete_Temp_Files_W7.ps1
 
.NOTES
 
The script will not remove any files that are in use by other processes, and will
throw an error upon encountering any in use files.
 
#&amp;gt;
 
# Create array containing all user profile folders
$colProfiles = Get-ChildItem &amp;quot;C:\Users\&amp;quot; -Name
# Remove the All Users profile from the array
$colProfiles = $colProfiles -ne &amp;quot;Public&amp;quot;
 
# Removes temporary files from each user profile folder
ForEach ( $objProfile in $colProfiles ) {
    # Remove all files and folders in user's Temp folder
    Get-ChildItem &amp;quot;C:\Users\$objProfile\AppData\Local\Temp\*&amp;quot; -recurse | remove-item -force -recurse
    # Remove all files and folders in user's Temporary Internet Files. The -force switch on Get-ChildItem gets hidden directories as well.
    Get-ChildItem &amp;quot;C:\Users\$objProfile\AppData\Local\Microsoft\Windows\Temporary Internet Files\*&amp;quot; -recurse -force | remove-item -force -recurse
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/sUVHCkhkFvY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/sUVHCkhkFvY/69dc3aa6-6ce4-4fb2-8baa-916b31fe3580.aspx</link>
      <pubDate>Thu, 28 Jul 2011 07:37:58 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/69dc3aa6-6ce4-4fb2-8baa-916b31fe3580.aspx</feedburner:origLink></item>
    <item>
      <title>Wait-UntilQueueEmpty</title>
      <description>Description: Monitors a queue on a box until it becomes empty, or an allotted time elapses.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/3e84e722-bc7a-465c-a2d5-306e622c57d6.aspx'&gt;http://www.codekeep.net/snippets/3e84e722-bc7a-465c-a2d5-306e622c57d6.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function Wait-UntilQueueEmpty([string]$ServerName, [string]$QueueName, [int]$waitTimeInSeconds)
{
	$queuePollingIntervalInSeconds = 5
	$waitTimeLimit = [DateTime]::Now.AddSeconds($waitTimeInSeconds)
	while ($true)
	{
		$queueReference = gwmi -class Win32_PerfRawData_MSMQ_MSMQQueue -computerName $ServerName | where-object {$_.Name -like &amp;quot;*\$QueueName&amp;quot;}
		if ($queueReference) 
		{
			$count = $queueReference.MessagesInQueue
			if ($count -eq 0)
			{
				Write-Verbose &amp;quot;The $QueueName queue on $ServerName is empty.&amp;quot;
				break
			}
			else {
				Write-Verbose &amp;quot;The $QueueName queue on $ServerName has $count messages remaining, sleeping $queuePollingIntervalInSeconds seconds ....&amp;quot;
				Start-Sleep -Seconds $queuePollingIntervalInSeconds
			}
			if ([DateTime]::Now -gt $waitTimeLimit){
				Write-Error &amp;quot;The $QueueName queue on $ServerName did not completely empty in the wait time allocated ($waitTimeInSeconds seconds).&amp;quot;
				break;
			}
		}else {
			# If we can't get the queue reference it means the queue isn't active or isn't on that box.
			Write-Warning &amp;quot;The $QueueName was not found on the server $ServerName&amp;quot;
			break
		}
	}
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/tpTzoReci34" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/tpTzoReci34/3e84e722-bc7a-465c-a2d5-306e622c57d6.aspx</link>
      <pubDate>Wed, 03 Nov 2010 11:27:07 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/3e84e722-bc7a-465c-a2d5-306e622c57d6.aspx</feedburner:origLink></item>
    <item>
      <title>List MSMQ queues and message count</title>
      <description>Description: Get's the MSMQ queues and messages counts for a machine.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/7c504c35-e5a9-4380-b0cb-81caa1dcb45f.aspx'&gt;http://www.codekeep.net/snippets/7c504c35-e5a9-4380-b0cb-81caa1dcb45f.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;gwmi -class Win32_PerfRawData_MSMQ_MSMQQueue -computerName $computerName | ft -prop Name, MessagesInQueue&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/5rjQAU0cdTY" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/5rjQAU0cdTY/7c504c35-e5a9-4380-b0cb-81caa1dcb45f.aspx</link>
      <pubDate>Wed, 03 Nov 2010 09:52:30 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/7c504c35-e5a9-4380-b0cb-81caa1dcb45f.aspx</feedburner:origLink></item>
    <item>
      <title>Send All Process To OneNote</title>
      <description>Description: Send all processes to OneNote or other installed printer&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/aaaf544c-1e96-4114-bb31-ab510cc42d81.aspx'&gt;http://www.codekeep.net/snippets/aaaf544c-1e96-4114-bb31-ab510cc42d81.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;PS C:\Windows\system32&amp;gt; Get-Process | Out-Printer -Name &amp;quot;Send To OneNote 2007&amp;quot;
PS C:\Windows\system32&amp;gt; Get-Process | Out-Printer -Name &amp;quot;FreePdf&amp;quot;
PS C:\Windows\system32&amp;gt; Get-Process | Out-Printer -Name &amp;quot;PdfCreator&amp;quot;
PS C:\Windows\system32&amp;gt; Get-Process | Out-Printer -Name &amp;quot;Canon PIXMA iP3000&amp;quot;&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/-ga-mimLE_o" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/-ga-mimLE_o/aaaf544c-1e96-4114-bb31-ab510cc42d81.aspx</link>
      <pubDate>Mon, 14 Dec 2009 14:20:14 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/aaaf544c-1e96-4114-bb31-ab510cc42d81.aspx</feedburner:origLink></item>
    <item>
      <title>Recursively Copy Folder (with excludes) in PowerShell</title>
      <description>Description: This function recursively copies a folder and all subfolders while allowing you to properly exclude certain items.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/4e793354-dedb-4f03-9f89-fbd86b580856.aspx'&gt;http://www.codekeep.net/snippets/4e793354-dedb-4f03-9f89-fbd86b580856.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function CopyFolder($source, $destination, $excludes)
{
    $items = get-childitem $source -recurse -exclude $excludes
    foreach ($item in $items)
    {
        $target = join-path $destination $item.FullName.Substring($source.Length)
        if (-not($item.PSIsContainer -and (test-path($target))))
        {
            copy-item -path $item.FullName -destination $target
        }
    }
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/2jNYgHo7S-g" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/2jNYgHo7S-g/4e793354-dedb-4f03-9f89-fbd86b580856.aspx</link>
      <pubDate>Tue, 01 Dec 2009 12:25:40 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/4e793354-dedb-4f03-9f89-fbd86b580856.aspx</feedburner:origLink></item>
    <item>
      <title>Recursively Delete Item in PowerShell</title>
      <description>Description: This function recursively deletes an item from the current location. The item can be a file or folder, and can be specified with or without wildcards.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/6fc67263-d4fc-4d9c-9946-4a6015d2a7ee.aspx'&gt;http://www.codekeep.net/snippets/6fc67263-d4fc-4d9c-9946-4a6015d2a7ee.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function CleanupItem([string]$item)
{
    if (($item.StartsWith(&amp;quot;*&amp;quot;) -eq $true) -or ($item.EndsWith(&amp;quot;*&amp;quot;) -eq $true))
    {
        get-childitem -recurse -force | where {$_.name -like $item} | foreach ($_) {remove-item $_.fullname -recurse -force}
    }
    else
    {
        get-childitem -recurse -force | where {$_.name -eq $item} | foreach ($_) {remove-item $_.fullname -recurse -force}
    }
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/_lAXRZ7buMc" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/_lAXRZ7buMc/6fc67263-d4fc-4d9c-9946-4a6015d2a7ee.aspx</link>
      <pubDate>Tue, 01 Dec 2009 08:47:36 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/6fc67263-d4fc-4d9c-9946-4a6015d2a7ee.aspx</feedburner:origLink></item>
    <item>
      <title>Create Folder in PowerShell</title>
      <description>Description: Creates a folder in the current location. If the folder already exists, it will be deleted and then re-created.&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/a423f583-0a72-4cac-b7fb-64eff3bff70e.aspx'&gt;http://www.codekeep.net/snippets/a423f583-0a72-4cac-b7fb-64eff3bff70e.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;function CreateFolder([string]$name)
{
    if ((test-path $name) -eq $true)
    {
        remove-item $name -recurse -force
    }
    
    new-item -name $name -itemType &amp;quot;Directory&amp;quot;
}&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/4GVjhdMGcXQ" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/4GVjhdMGcXQ/a423f583-0a72-4cac-b7fb-64eff3bff70e.aspx</link>
      <pubDate>Tue, 01 Dec 2009 08:34:02 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/a423f583-0a72-4cac-b7fb-64eff3bff70e.aspx</feedburner:origLink></item>
    <item>
      <title>DOS .bat file to synch backup copy with SVN repository</title>
      <description>Description: DOS .bat file used to  synch backup copy on same server with with SVN repository&lt;br /&gt;&lt;br /&gt;Link: &lt;a href='http://www.codekeep.net/snippets/8839235d-2ff6-40f0-945e-c037ebb95006.aspx'&gt;http://www.codekeep.net/snippets/8839235d-2ff6-40f0-945e-c037ebb95006.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style='font-size: 9pt;'&gt;SET SVN=C:\Progra~1\Subversion\bin\svn.exe
SET WORKING_COPY= [location ex: D:\EventsRegistration]
SET ASPNET_USERNAME= [uname]
SET ASPNET_PASSWORD= [pass]
SET CONFIG_DIR=D:\SVNRepo\CteSVN\conf

%SVN% update %WORKING_COPY% --non-interactive --config-dir %CONFIG_DIR% --username %ASPNET_USERNAME% --password %ASPNET_PASSWORD% 

::In case there are conflicts, revert all changes
%SVN% revert --recursive %WORKING_COPY%&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/CodeKeepPowerShell/~4/tk-XDMnJsl8" height="1" width="1"/&gt;</description>
      <link>http://feedproxy.google.com/~r/CodeKeepPowerShell/~3/tk-XDMnJsl8/8839235d-2ff6-40f0-945e-c037ebb95006.aspx</link>
      <pubDate>Wed, 21 Oct 2009 14:39:07 GMT</pubDate>
    <feedburner:origLink>http://www.codekeep.net/snippets/8839235d-2ff6-40f0-945e-c037ebb95006.aspx</feedburner:origLink></item>
  </channel>
</rss>
