<?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>dustinberube.com</title>
	<atom:link href="http://dustinberube.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dustinberube.com</link>
	<description>You will probably want some waders, a pick axe, and one of those hats with a light on it before you go in here.</description>
	<lastBuildDate>Mon, 30 May 2011 03:41:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Scheduling Powershell scripts in Windows Task Scheduler</title>
		<link>http://dustinberube.com/2011/05/scheduling-powershell-scripts-in-windows-task-scheduler/</link>
		<comments>http://dustinberube.com/2011/05/scheduling-powershell-scripts-in-windows-task-scheduler/#comments</comments>
		<pubDate>Mon, 30 May 2011 03:41:05 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=138</guid>
		<description><![CDATA[In order to schedule a PowerShell script to run as a scheduled task in Windows Server 2003 you will need to use the following command syntax. I also set the &#8220;Start In&#8221; directive to the directory that contains the .ps1 file. The command below will cause the script to run in the background and not [...]]]></description>
			<content:encoded><![CDATA[<p>In order to schedule a PowerShell script to run as a scheduled task in Windows Server 2003 you will need to use the following command syntax. I also set the &#8220;Start In&#8221; directive to the directory that contains the .ps1 file. The command below will cause the script to run in the background and not generate a window while it is running.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe <span style="color: pink;">-</span>nologo <span style="color: #008080; font-style: italic;">-command</span> <span style="color: #800000;">&quot;&amp; {path\to\script.ps1}&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2011/05/scheduling-powershell-scripts-in-windows-task-scheduler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Junos Olive in VMware</title>
		<link>http://dustinberube.com/2011/05/creating-a-junos-olive-in-vmware/</link>
		<comments>http://dustinberube.com/2011/05/creating-a-junos-olive-in-vmware/#comments</comments>
		<pubDate>Mon, 30 May 2011 02:36:49 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[juniper]]></category>
		<category><![CDATA[junos olive]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=120</guid>
		<description><![CDATA[The term  &#8220;Olive&#8221; is given to any virtual machine or PC based hardware platform that is running the Junos operating system on it. Juniper does not support these types of installations. Below is the walk through of how I got the Junos Olive created for my lab environment. You will need a copy of the [...]]]></description>
			<content:encoded><![CDATA[<p>The term  &#8220;Olive&#8221; is given to any virtual machine or PC based hardware platform that is running the Junos operating system on it. Juniper does not support these types of installations. Below is the walk through of how I got the Junos Olive created for my lab environment. You will need a copy of the FreeBSD 4.11 Mini Installation ISO image (available <a href="ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/i386/ISO-IMAGES/4.11/4.11-RELEASE-i386-miniinst.iso">here</a>)and a Junos software package. I&#8217;m using Junos 10.4R3.4 for the M/MX/T series routers. <strong>I will not provide the Junos image for download</strong>, you will need a valid J-Care contract to download the software from Juniper.</p>
<p>Create a virtual machine with the following settings (I&#8217;m using VMware Workstation).</p>
<ul>
<li>1 Processor</li>
<li>512 MB Memory</li>
<li>CD-ROM Drive (for FreeBSD install)</li>
<li>Remove the USB Adapter &#038; Sound Card</li>
<li>8 GB Hard Drive (I used the default drive size)</li>
<li>Add as many network adapters as necessary (you can always add or remove network interfaces later)</li>
</ul>
<p>Once you have created the virtual machine, edit the virtual machine configuration file (.vmx) file and make the following changes.</p>
<p>Change the below entry to FALSE</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">scsi0.present = <span style="color: #ff0000;">&quot;FALSE&quot;</span></pre></div></div>

<p>Make sure the network adapters are set to &#8220;e1000&#8243;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ethernet0.virtualDev = <span style="color: #ff0000;">&quot;e1000&quot;</span></pre></div></div>

<p>Next install FreeBSD 4.11 with the following settings:</p>
<ul>
<li>Standard installation</li>
<li>FDisk &#8211; Use entire disk</li>
<li>BootMgr &#8211; default FreeBSD Boot Manager</li>
<li>Create the following partition structure:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Part        Mount           Size
<span style="color: #660033;">-----</span>     <span style="color: #660033;">---------</span>        <span style="color: #660033;">------</span>
ad0s1a     <span style="color: #000000; font-weight: bold;">/</span>                512M
ad0s1b     swap            1024M
ad0s1e     <span style="color: #000000; font-weight: bold;">/</span>config           24M
ad0s1f     <span style="color: #000000; font-weight: bold;">/</span>var          use rest of space</pre></div></div>

</li>
<li>Average User install</li>
<li>Do not install the ports collection</li>
<li>Installation Media &#8211; CD/DVD</li>
<li>Choose Yes on the final warning message</li>
<li>Would you like to configure any Ethernet or SLIP/PPP network devices? <strong>Yes</strong></li>
<li>Configure em0 with no IPv6 support and enable DHCP</li>
<li>Do you want this machine to function as a network gateway? <strong>No</strong></li>
<li>Do you want to configure inetd and the network services that it provides? <strong>No</strong></li>
<li>Do you want to have anonymous FTP access to this machine? <strong>No</strong></li>
<li>Do you want to configure this machine as an NFS server? <strong>No</strong></li>
<li>Do you want to select a default security profile for this host? <strong>No</strong></li>
<li>Would you like to customize your system console settings? <strong>No</strong></li>
<li>Would you like to set this machine&#8217;s time zone now? <strong>No</strong></li>
<li>Would you like to enable Linux binary compatibility? <strong>No</strong></li>
<li>Does this system have a non-USB mouse attached to it? <strong>No</strong></li>
<li>Package collection &#8211; Would you like to browse the collection now? <strong>No</strong></li>
<li>Any additional user accounts? <strong>No</strong></li>
<li>Set the root password</li>
<li>Visit the general configuration menu for a chance to set any last options? <strong>No</strong></li>
<li>Exit the installation and let the system reboot</li>
</ul>
<p>Log into the virtual machine as root and place the jinstall-*-domestic-signed.tgz file in /var/tmp. Since this is not a Juniper device you will need to modify the contents of the package to get it to install on FreeBSD. Replace the asterisk&#8217;s in the jinstall file names with the version you downloaded.</p>
<ol>
<li>Create a jinstall directory and extract the contents of jinstall-*-domestic-signed.tgz into it.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> jinstall <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-C</span> jinstall <span style="color: #660033;">-zxf</span> jinstall-<span style="color: #000000; font-weight: bold;">*</span>-domestic-signed.tgz</pre></div></div>

</li>
<li>Edit the +INSTALL file in the jinstall directory and change the check_arch function to match below.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #660033;">--</span> +INSTALL
&nbsp;
check_arch_compatibility<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># re_name=`/sbin/sysctl -n hw.re.name 2&gt;/dev/null`</span>
    <span style="color: #007800;">re_name</span>=<span style="color: #ff0000;">&quot;olive&quot;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$re_name</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        Error <span style="color: #ff0000;">&quot;hw.re.name sysctl not supported.&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

</li>
<li>Extract the contents of jinstall-*-domestic.tgz to /var/tmp/jinst-dom

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>jinst-dom <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>jinst-dom <span style="color: #660033;">-zxf</span> jinstall-<span style="color: #000000; font-weight: bold;">*</span>-domestic.tgz</pre></div></div>

</li>
<li>Change directories to /var/tmp/jinst-dom and make the same change to both the +INSTALL and +REQUIRE files in this directory.</li>
<li>Extract the contents of /var/tmp/jinst-dom/pkgtools.tgz and replace the program checkpic with /usr/bin/true.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>pkgtools <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>pkgtools <span style="color: #660033;">-zxf</span> pkgtools.tgz
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>pkgtools<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>checkpic</pre></div></div>

</li>
<li>Change directory to the pkgtools directory and create a gzipped tar file of the contents. Then move the pkgtools.tgz file to /var/tmp/jinst-dom.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> czf pkgtools.tgz <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> pkgtools.tgz <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>jinst-dom<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Change directory to the jinst-dom directory and create a gzipped tar file of the contents. Then move the jinstall-*-domestic.tgz to /var/tmp/jinstall.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> czf jinstall-<span style="color: #000000; font-weight: bold;">*</span>-domestic.tgz <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> jinstall-<span style="color: #000000; font-weight: bold;">*</span>-domestic.tgz <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>jinstall<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Change directory to /var/tmp/jinstall. Before creating the tar file you will need to delete the signature files as the check-sums will no longer match.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">*</span>.md5 <span style="color: #000000; font-weight: bold;">*</span>.sha1 <span style="color: #000000; font-weight: bold;">*</span>.sig
<span style="color: #c20cb9; font-weight: bold;">tar</span> czf <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>jinstall-<span style="color: #000000; font-weight: bold;">*</span>-olive.tgz <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

</li>
<li>Install the package we just created with pkg_add. You will receive some warning messages which are to be expected.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pkg_add jinstall-<span style="color: #000000; font-weight: bold;">*</span>-olive.tgz</pre></div></div>

</li>
</ol>
<p>Once the install is completed reboot the virtual machine, after a few minutes you should be presented a login prompt. The default username is root and there is no password. At this time you are now able to type &#8216;cli&#8217; and enter the Junos command line. Now you can copy this virtual machine to create the number of Olive&#8217;s you need for your lab.</p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2011/05/creating-a-junos-olive-in-vmware/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell &#8211; Downloading and extracting Zip files from FTP</title>
		<link>http://dustinberube.com/2010/12/powershell-downloading-and-extracting-zip-files-from-ftp/</link>
		<comments>http://dustinberube.com/2010/12/powershell-downloading-and-extracting-zip-files-from-ftp/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 16:14:42 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Indy Sockets Library]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=98</guid>
		<description><![CDATA[Recently I had the need to routinely check for zip files on a remote FTP server, if there were new files download them and extract them into a particular directory. Dreading the addition of yet another manual process I set out to build a Powershell script to accomplish this task for me. I had become quickly frustrated with the lack of native FTP support in the .Net framework, I know you could pass the ftp credentials as a parametrized URL and download single files. However, I needed to perform a directory listing to see which files existed and had not been downloaded previously. In my search I came across the <a href="http://www.indyproject.org/index.en.aspx">Indy Project</a> an Open Source group that wrote and maintains the Indy Sockets library which includes and FTP client socket among other things. I will also distribute the Indy.Sockets library with my script. ]]></description>
			<content:encoded><![CDATA[<p>Recently I had the need to routinely check for zip files on a remote FTP server, if there were new files download them and extract them into a particular directory. Dreading the addition of yet another manual process I set out to build a Powershell script to accomplish this task for me. I had become quickly frustrated with the lack of native FTP support in the .Net framework, I know you could pass the ftp credentials as a parametrized URL and download single files. However, I needed to perform a directory listing to see which files existed and had not been downloaded previously. In my search I came across the <a href="http://www.indyproject.org/index.en.aspx">Indy Project</a> an Open Source group that wrote and maintains the Indy Sockets library which includes and FTP client socket among other things. I will also distribute the Indy.Sockets library with my script. </p>
<p>In this script the $workingPath refers to the location that you want to store the files after downloading and extracting them. This script provides some basic logging functionality, the log file will be written to C:\FTPUtil\FTPUtil.log.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Downloads files from an FTP server and unzips them.</span>
<span style="color: #008000;"># The script will only download new files that have not</span>
<span style="color: #008000;"># been previously downloaded and extracted into the</span>
<span style="color: #008000;"># working directory. This can be setup as a scheduled</span>
<span style="color: #008000;"># task to automate script run-time. Basic logging is</span>
<span style="color: #008000;"># is written into the FTPUtil.log text file in the </span>
<span style="color: #008000;"># application directory.</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Created by Dustin Berube on 11/16/2010.</span>
<span style="color: #008000;"># Requires Indy.Sockets.dll and Mono.Security.dll version=1.0.5000.0</span>
&nbsp;
<span style="color: #008000;"># Base Location of Files to work with</span>
<span style="color: #800080;">$workingPath</span> <span style="color: pink;">=</span> <span style="color: #800000;">'x:\path\to\your\file\location'</span>
&nbsp;
<span style="color: #008000;"># File Extension</span>
<span style="color: #800080;">$fileExt</span> <span style="color: pink;">=</span> <span style="color: #800000;">'.ZIP'</span> <span style="color: #008000;"># File extension of file you are downloading.</span>
&nbsp;
<span style="color: #008000;"># FTP Information</span>
<span style="color: #800080;">$ftpDir</span> 	<span style="color: pink;">=</span> <span style="color: #800000;">&quot;/directory&quot;</span>  			<span style="color: #008000;"># Directory path to folder on ftp server</span>
<span style="color: #800080;">$ftpServer</span> 	<span style="color: pink;">=</span> <span style="color: #800000;">&quot;ftp.yourserver.com&quot;</span>		<span style="color: #008000;"># FTP Server address</span>
<span style="color: #800080;">$ftpUser</span> 	<span style="color: pink;">=</span> <span style="color: #800000;">&quot;username&quot;</span> 				<span style="color: #008000;"># FTP Username</span>
<span style="color: #800080;">$ftpPass</span> 	<span style="color: pink;">=</span> <span style="color: #800000;">&quot;password&quot;</span> 				<span style="color: #008000;"># FTP Password</span>
&nbsp;
<span style="color: #008000;"># Application Directory - Usually C:\FTPUtil unless installed to different directory</span>
<span style="color: #800080;">$appDir</span> <span style="color: pink;">=</span> <span style="color: #800000;">'C:\FTPUtil'</span>
&nbsp;
<span style="color: #008000;">#</span>
<span style="color: #008000;"># DO NOT CHANGE ANYTHING BELOW THIS LINE</span>
<span style="color: #008000;">#</span>
&nbsp;
<span style="color: #008080; font-weight: bold;">set-location</span> <span style="color: #800080;">$workingPath</span>
<span style="color: #800080;">$shell</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> <span style="color: pink;">-</span>com shell.application
&nbsp;
<span style="color: #0000FF;">function</span> unzip<span style="color: pink;">-</span>Files <span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$location</span> <span style="color: pink;">=</span> <span style="color: #800080;">$shell</span>.namespace<span style="color: #000000;">&#40;</span><span style="color: #800080;">$workingPath</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$zipFiles</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">get-childitem</span> <span style="color: pink;">*</span>.zip
&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: #000000;">&#40;</span><span style="color: #800080;">$workingPath</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\*$fileExt&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$zipFile</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$ZipFiles</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$destDirectory</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$workingPath</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$zipFile</span>.name.Trim<span style="color: #000000;">&#40;</span><span style="color: #800080;">$fileExt</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #008080; font-style: italic;">-path</span> <span style="color: #800080;">$destDirectory</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>IO.Directory<span style="color: #000000;">&#93;</span>::CreateDirectory<span style="color: #000000;">&#40;</span><span style="color: #800080;">$destDirectory</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;">$location</span> <span style="color: pink;">=</span> <span style="color: #800080;">$shell</span>.namespace<span style="color: #000000;">&#40;</span><span style="color: #800080;">$destDirectory</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$zipFolder</span> <span style="color: pink;">=</span> <span style="color: #800080;">$shell</span>.namespace<span style="color: #000000;">&#40;</span><span style="color: #800080;">$zipFile</span>.fullname<span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #800080;">$location</span>.copyhere<span style="color: #000000;">&#40;</span><span style="color: #800080;">$zipFolder</span>.items<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span><span style="color: #000000;">&#41;</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; --- &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$zipFile</span>.name <span style="color: pink;">+</span> <span style="color: #800000;">&quot; extracted to $destDirectory&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">out<span style="color: #FF0000;">-file</span></span> <span style="color: #800000;">&quot;$appDir\FTPUtil.log&quot;</span> <span style="color: #008080; font-style: italic;">-append</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
	Remove<span style="color: pink;">-</span>ZipFiles
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">else</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span><span style="color: #000000;">&#41;</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; --- NO FILES DOWNLOADED AND UNZIPPED&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">out<span style="color: #FF0000;">-file</span></span> <span style="color: #800000;">&quot;$appDir\FTPUtil.log&quot;</span> <span style="color: #008080; font-style: italic;">-append</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>	
&nbsp;
<span style="color: #0000FF;">function</span> Remove<span style="color: pink;">-</span>ZipFiles <span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">set-location</span> <span style="color: #800080;">$workingPath</span>
	<span style="color: #800080;">$location</span> <span style="color: pink;">=</span> <span style="color: #800080;">$shell</span>.namespace<span style="color: #000000;">&#40;</span><span style="color: #800080;">$workingPath</span><span style="color: #000000;">&#41;</span>
	<span style="color: #008080; font-weight: bold;">remove-item</span> <span style="color: #800000;">&quot;*$fileExt&quot;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">function</span> Open<span style="color: pink;">-</span>FTPConnection <span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Load Indy Sockets Library</span>
	<span style="color: #000000;">&#91;</span>Reflection.Assembly<span style="color: #000000;">&#93;</span>::<span style="color: #800000;">LoadFrom</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;C:\ftputil\Indy.Sockets.dll&quot;</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: #800080;">$ftp</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> Indy.Sockets.FTP
	<span style="color: #800080;">$ftp</span>.Disconnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;"># Connect to FTP Server</span>
	<span style="color: #800080;">$ftp</span>.Host <span style="color: pink;">=</span> <span style="color: #800080;">$ftpServer</span>
	<span style="color: #800080;">$ftp</span>.Username <span style="color: pink;">=</span> <span style="color: #800080;">$ftpUser</span>
	<span style="color: #800080;">$ftp</span>.Password <span style="color: pink;">=</span> <span style="color: #800080;">$ftpPass</span>
	<span style="color: #800080;">$ftp</span>.Connect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;"># Set PASV mode</span>
	<span style="color: #800080;">$ftp</span>.Passive <span style="color: pink;">=</span> <span style="color: #800080;">$true</span>
&nbsp;
	<span style="color: #0000FF;">return</span> <span style="color: #800080;">$ftp</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">function</span> Close<span style="color: pink;">-</span>FTPConnection<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ftp</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$ftp</span>.Disconnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">function</span> Download<span style="color: pink;">-</span>FTPFile<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ftp</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$ls</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> System.Collections.Specialized.StringCollection
	<span style="color: #800080;">$ftp</span>.List<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ls</span><span style="color: pink;">,</span> <span style="color: #800080;">$ftpDir</span><span style="color: pink;">,</span> <span style="color: #800080;">$false</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$file</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$ls</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$fileName</span> <span style="color: pink;">=</span> <span style="color: #800080;">$file</span>.Trim<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;$ftpDir/&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #008080; font-style: italic;">-path</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$workingPath</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\&quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$fileName</span>.Trim<span style="color: #000000;">&#40;</span><span style="color: #800080;">$fileExt</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			 <span style="color: #800080;">$ftp</span>.Get<span style="color: #000000;">&#40;</span><span style="color: #800080;">$file</span><span style="color: pink;">,</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$workingPath</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot;\$fileName&quot;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> <span style="color: #800080;">$true</span><span style="color: pink;">,</span> <span style="color: #800080;">$false</span><span style="color: #000000;">&#41;</span>
			 <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span><span style="color: #000000;">&#41;</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800000;">&quot; --- $fileName Downloaded and saved to $workingPath&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">out<span style="color: #FF0000;">-file</span></span> <span style="color: #800000;">&quot;$appDir\FTPUtil.log&quot;</span> <span style="color: #008080; font-style: italic;">-append</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$f</span> <span style="color: pink;">=</span> Open<span style="color: pink;">-</span>FTPConnection
Download<span style="color: pink;">-</span>FTPFile <span style="color: #800080;">$f</span> 
Close<span style="color: pink;">-</span>FTPConnection <span style="color: #800080;">$f</span>
unzip<span style="color: pink;">-</span>Files</pre></div></div>

<p>After downloading this script, extract the contents to C:\FTPUtil. You can download the FTPUtil script from here <a href="http://www.dustinberube.com/files/FTPUtil.zip">http://www.dustinberube.com/files/FTPUtil.zip</a>. As always I take no responsibility for any problems that arise from the use of this script, it has been tested and used in my development and production environments without issue. </p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/12/powershell-downloading-and-extracting-zip-files-from-ftp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Remove Network Printers via WMI</title>
		<link>http://dustinberube.com/2010/11/remove-network-printers-via-wmi/</link>
		<comments>http://dustinberube.com/2010/11/remove-network-printers-via-wmi/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 10:53:58 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[VB Script]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=92</guid>
		<description><![CDATA[Earlier this year I needed to migrate all of my users to a new print server. I essentially had two options for removing the old printers. Option one included visiting each workstation and removing the printers manually. The second option, which is the road that I chose was to script the removal of these old [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this year I needed to migrate all of my users to a new print server. I essentially had two options for removing the old printers. Option one included visiting each workstation and removing the printers manually. The second option, which is the road that I chose was to script the removal of these old printers. I came up with this quick VB Script to accomplish this mundane task.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'Created by Dustin Berube on 3/22/2010 Version 2.0
</span><span style="color: #008000;">'Documented on 3/22/2010
</span>
<span style="color: #008000;">' This script will loops through all installed
</span><span style="color: #008000;">' network printers on a workstation and removes
</span><span style="color: #008000;">' them. Recommend running this as a Logoff script.
</span>
strComputer = <span style="color: #800000;">&quot;.&quot;</span>
<span style="color: #151B8D; font-weight: bold;">Set</span> objWMIService = <span style="color: #E56717; font-weight: bold;">GetObject</span>(<span style="color: #800000;">&quot;winmgmts:\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Set</span> colInstalledPrinters =  objWMIService.ExecQuery _
    (<span style="color: #800000;">&quot;Select * from Win32_Printer Where Network = TRUE&quot;</span>)
&nbsp;
<span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> objPrinter <span style="color: #8D38C9; font-weight: bold;">in</span> colInstalledPrinters
    objPrinter.Delete_
<span style="color: #8D38C9; font-weight: bold;">Next</span></pre></div></div>

<p>In my case I ran the script through Group Policy as a log off script. The reasoning for that was at the end of the day  I had all my users log off of their workstations (which triggered this script to remove all network printers from their workstations). The next time they logged onto their workstations the new printers were pushed through a different script to map the printers. This script utilizes WMI to query the local workstation and select all network printers from the Win32_Printer object. Once it retrieves a list of printers this script will loop through the printers and delete them one at a time.</p>
<p>As always, I have provided this script &#8220;AS-IS&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/11/remove-network-printers-via-wmi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Procmail to route messages to Request Tracker (RT) queue&#8217;s</title>
		<link>http://dustinberube.com/2010/11/procmail-rt-queues/</link>
		<comments>http://dustinberube.com/2010/11/procmail-rt-queues/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 15:28:01 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Procmail]]></category>
		<category><![CDATA[Request Tracker]]></category>
		<category><![CDATA[RT]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=85</guid>
		<description><![CDATA[At work we use Request Tracker (RT) by Best Practical to handle our help desk e-mail and public correspondence e-mail queue&#8217;s. When setting up RT you would typically provide different e-mail addresses for each queue and have people e-mail the appropriate address to submit a question or trouble ticket. In some organizations such as ours [...]]]></description>
			<content:encoded><![CDATA[<p>At work we use Request Tracker (RT) by Best Practical to handle our help desk e-mail and public correspondence e-mail queue&#8217;s. When setting up RT you would typically provide different e-mail addresses for each queue and have people e-mail the appropriate address to submit a question or trouble ticket. In some organizations such as ours your support base is already use to a mechanism that was put in place of everyone emailing a single address such as support@yourcompany.com. In my situation it would have been very difficult to change this because of all the outside agencies that also use this support address. Good news is there is an answer to this problem called Procmail. </p>
<p>This guide is based off of CentOS 5.5 with Postfix as the MTA and the latest Procmail available via &#8216;yum&#8217;. The location of the configuration files may be different in your Linux distribution of choice. </p>
<p>First we need to tell Postfix to pass the mail to an external command for further processing Add this command to your /etc/postfix/main.cf configuration file.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>dberube<span style="color: #000000; font-weight: bold;">@</span>itsupport ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>main.cf
&nbsp;
<span style="color: #666666; font-style: italic;"># The mailbox_command parameter specifies the optional external</span>
<span style="color: #666666; font-style: italic;"># command to use instead of mailbox delivery. The command is run as</span>
<span style="color: #666666; font-style: italic;"># the recipient with proper HOME, SHELL and LOGNAME environment settings.</span>
<span style="color: #666666; font-style: italic;"># Exception:  delivery for root is done as $default_user.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Other environment variables of interest: USER (recipient username),</span>
<span style="color: #666666; font-style: italic;"># EXTENSION (address extension), DOMAIN (domain part of address),</span>
<span style="color: #666666; font-style: italic;"># and LOCAL (the address localpart).</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Unlike other Postfix configuration parameters, the mailbox_command</span>
<span style="color: #666666; font-style: italic;"># parameter is not subjected to $parameter substitutions. This is to</span>
<span style="color: #666666; font-style: italic;"># make it easier to specify shell syntax (see example below).</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Avoid shell meta characters because they will force Postfix to run</span>
<span style="color: #666666; font-style: italic;"># an expensive shell process. Procmail alone is expensive enough.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN</span>
<span style="color: #666666; font-style: italic;"># ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER.</span>
<span style="color: #666666; font-style: italic;">#</span>
mailbox_command = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">procmail</span></pre></div></div>

<p>After modifying the Postfix main.cf file we need to create our Procmail ruleset which will be saved in this file /etc/procmailrc.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>dberube<span style="color: #000000; font-weight: bold;">@</span>itsupport ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>procmailrc
&nbsp;
<span style="color: #666666; font-style: italic;"># Set Variables</span>
<span style="color: #007800;">SHELL</span>=<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span>
<span style="color: #007800;">LOGFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>procmail_log
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;--- Logging <span style="color: #007800;">${LOGFILE}</span> for <span style="color: #007800;">${LOGNAME}</span> ---\<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #007800;">VERBOSE</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #007800;">RT_MAILGATE</span>=<span style="color: #ff0000;">&quot;/opt/rt3/bin/rt-mailgate&quot;</span>
<span style="color: #007800;">RT_URI</span>=<span style="color: #ff0000;">&quot;http://itsupport.domain1.local/ticket&quot;</span>
&nbsp;
<span style="color: #007800;">LOGABSTRACT</span>=no
&nbsp;
<span style="color: #666666; font-style: italic;"># Accounts Payable</span>
:<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">*</span> ^TO_.<span style="color: #000000; font-weight: bold;">*</span>rt-ap<span style="color: #000000; font-weight: bold;">@</span>
<span style="color: #000000; font-weight: bold;">|/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">-queue</span> <span style="color: #ff0000;">&quot;Accounts Payable&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Value Adjustment Board</span>
:<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">*</span> ^TO_.<span style="color: #000000; font-weight: bold;">*</span>rt-vab<span style="color: #000000; font-weight: bold;">@</span>
<span style="color: #000000; font-weight: bold;">*</span> ^TO_.<span style="color: #000000; font-weight: bold;">*</span>vab<span style="color: #000000; font-weight: bold;">@</span>
<span style="color: #000000; font-weight: bold;">|/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">-queue</span> <span style="color: #ff0000;">&quot;Value Adjustment Board&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Domain 1</span>
:<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">*</span> ^From: .<span style="color: #000000; font-weight: bold;">*@</span>domain1.com
 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        :<span style="color: #000000;">0</span>
        <span style="color: #000000; font-weight: bold;">*</span> ^Subject:.<span style="color: #000000; font-weight: bold;">*</span>benchmark
        <span style="color: #000000; font-weight: bold;">|/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">-queue</span> <span style="color: #ff0000;">&quot;Benchmark&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span>
&nbsp;
        :<span style="color: #000000;">0</span>
        <span style="color: #000000; font-weight: bold;">|/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">-queue</span> <span style="color: #ff0000;">&quot;Office Queue&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Domain 2</span>
:<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">*</span> ^From: .<span style="color: #000000; font-weight: bold;">*@</span>domain2.com
<span style="color: #000000; font-weight: bold;">|/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">--queue</span> <span style="color: #ff0000;">&quot;Domain 2&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Domain 3</span>
:<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">*</span> ^From: .<span style="color: #000000; font-weight: bold;">*@</span>domain3.com
<span style="color: #000000; font-weight: bold;">|/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">--queue</span> <span style="color: #ff0000;">&quot;Domain 3&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># All Others</span>
:<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">!</span>^From: .<span style="color: #000000; font-weight: bold;">*@</span>domain1.com<span style="color: #000000; font-weight: bold;">|</span>.<span style="color: #000000; font-weight: bold;">*@</span>domain2.com<span style="color: #000000; font-weight: bold;">|</span>.<span style="color: #000000; font-weight: bold;">*@</span>domain3.com
<span style="color: #000000; font-weight: bold;">|</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$RT_MAILGATE</span> <span style="color: #660033;">--queue</span> <span style="color: #ff0000;">&quot;External Users&quot;</span> <span style="color: #660033;">--action</span> correspond <span style="color: #660033;">--url</span> <span style="color: #007800;">$RT_URI</span></pre></div></div>

<p>You will notice that the rule set for Domain 1 looks a little different than the other rules. For messages that are arriving to my RT server from @domain1.com I am checking for the subject line as well. If any message arrives from domain1.com that has the word &#8220;benchmark&#8221; in the subject line send it to the &#8220;Benchmark&#8221; queue. If that check does not match the email will be placed in the &#8220;Office Queue&#8221;. Most of these rules are self-explanatory so I won&#8217;t go into the details of every rule, the one other rule that I believe is worth talking about is the last one in the rule set. My &#8220;All Others&#8221; rule says that is an incoming email message to my support email address does not match domain1, domain2 or domain3 place it in the &#8220;External Users&#8221; queue.</p>
<p>I hope this helps you find alternative ways to handle e-mail processing with RT. In the future I will be posting more guides on how to configure RT in an Microsoft Active Directory and Exchange Server environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/11/procmail-rt-queues/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reset Home Folder Permissions</title>
		<link>http://dustinberube.com/2010/09/reset-home-folder-permissions/</link>
		<comments>http://dustinberube.com/2010/09/reset-home-folder-permissions/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 01:59:13 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[NTFS]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=80</guid>
		<description><![CDATA[This week we had an incident occur at work that required all the home directory permissions reset for all users in Active Directory. You basically have two options to reset the permissions do it manually or write a script. Have you thought about which option you would take? Of course you have, a good Systems [...]]]></description>
			<content:encoded><![CDATA[<p>This week we had an incident occur at work that required all the home directory permissions reset for all users in Active Directory. You basically have two options to reset the permissions do it manually or write a script. Have you thought about which option you would take? Of course you have, a good Systems Administrator would rather write a script to conduct this mundane task. Below is my PowerShell script to add the user back with rights to their directory. It will not overwrite permissions as it uses the default behavior of Windows Server 2003 and Active Directory, which is to have home directories inherit the parent folders NTFS rights. </p>
<p>This script also requires the Active Directory Management pack from Quest Software (free download).</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Load Quest Active Directory Snap-in</span>
<span style="color: #008080; font-weight: bold;">add-pssnapin</span> quest.activeroles.admanagement
&nbsp;
<span style="color: #008000;"># Get list of users that have home folders on the SAN. Creates an array of objects</span>
<span style="color: #800080;">$users</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>qaduser <span style="color: pink;">-</span>size <span style="color: #804000;">1000</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">select</span> logonName<span style="color: pink;">,</span>homeDirectory <span style="color: pink;">|</span> <span style="color: #0000FF;">where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.homeDirectory <span style="color: #FF0000;">-like</span> <span style="color: #800000;">'\\path\to\users\*'</span><span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Loop through $users array</span>
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$x</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$users</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #008000;"># Check to see if directory exists. If not write error message to console.</span>
    <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;">$x</span>.homeDirectory<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #008000;"># Build ACL and grant user modify rights to their respective folder. Also propagates the access rule to subfolder and files.</span>
        <span style="color: #800080;">$acl</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">get-acl</span> <span style="color: #800080;">$x</span>.homeDirectory
        <span style="color: #800080;">$inherit</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>System.Security.AccessControl.InheritanceFlags<span style="color: #000000;">&#93;</span><span style="color: #800000;">&quot;ContainerInherit&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;ObjectInherit&quot;</span>
        <span style="color: #800080;">$prop</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>system.security.accesscontrol.PropagationFlags<span style="color: #000000;">&#93;</span><span style="color: #800000;">&quot;InheritOnly&quot;</span>
        <span style="color: #800080;">$ar</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> system.security.accesscontrol.filesystemaccessrule<span style="color: #000000;">&#40;</span><span style="color: #800080;">$x</span>.LogonName<span style="color: pink;">,</span><span style="color: #800000;">&quot;Modify&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$inherit</span><span style="color: pink;">,</span> <span style="color: #800080;">$prop</span><span style="color: pink;">,</span> <span style="color: #800000;">&quot;Allow&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #800080;">$acl</span>.SetAccessRule<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ar</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #008000;"># Set ACL on directory</span>
        <span style="color: #008080; font-weight: bold;">set-acl</span> <span style="color: #800080;">$x</span>.homeDirectory <span style="color: #800080;">$acl</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: #800080;">$x</span>.homeDirectory <span style="color: #800000;">&quot;does not exist.&quot;</span>
    <span style="color: #000000;">&#125;</span>    
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;All folder permissions have been changed. Any errors have been listed above.&quot;</span></pre></div></div>

<p>I hope this script will help someone else accomplish this task.</p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/09/reset-home-folder-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Computer Accounts in Active Directory from text file</title>
		<link>http://dustinberube.com/2010/09/create-computer-accounts-in-active-directory-from-text-file/</link>
		<comments>http://dustinberube.com/2010/09/create-computer-accounts-in-active-directory-from-text-file/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 14:19:52 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Quest Software]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=69</guid>
		<description><![CDATA[At work we have a computer deployment coming up where we will need to add computers to the domain. The way our Active Directory structure is based is that all objects (computers, users, printers, and distribution groups) are separated into operational departments. This makes joining computers to the domain and auto-creating the accounts a pain [...]]]></description>
			<content:encoded><![CDATA[<p>At work we have a computer deployment coming up where we will need to add computers to the domain. The way our Active Directory structure is based is that all objects (computers, users, printers, and distribution groups) are separated into operational departments. This makes joining computers to the domain and auto-creating the accounts a pain because you constantly have to put the janitor hat on and move the accounts to the proper OU. This script is written in Powershell and requires the Quest Powershell Commands for Active Directory which you can download from <a href="http://www.quest.com/powershell/">here</a> for free.</p>
<p>This script will first check to see if the computer accounts in the text file are located anywhere in the domain, if so it will throw and error and exit. If everything checks out Ok it will create the computer accounts in the specified OU. You will need to run this from an account that has Domain Admin rights or the &#8220;Add computers to the domain right&#8221;. There are three pieces of information you are prompted for and they are: </p>
<ul>
<li> Path to text-file &#8211; needs to be the full path (ie. c:\scripts\computers.txt)</li>
<li>Desired OU that you want to create the accounts: input in the format of domain.suffix/path/to/ou</li>
<li>Location: Optional, this will fill in the location meta-data for this object. Convenient for indicating the physical location where the computer is located.</li>
</ul>
<p><strong>As always this script is provided as-is and I am not responsible for any damages or injuries that may result from using this script.</strong></p>
<p><a href="http://dustinberube.com/images/addComputerSuccess.png" rel="lightbox[69]"><img src="http://dustinberube.com/images/addComputerSuccessThumb.png" alt="Add Computers to AD success" /></a> <a href="http://dustinberube.com/images/addComputerError.png" rel="lightbox[69]"><img src="http://dustinberube.com/images/addComputerErrorThumb.png" alt="Add Computer to AD error" /></a> <a href="http://dustinberube.com/images/adComputers.png" rel="lightbox[69]"><img src="http://dustinberube.com/images/adComputersThumb.png" alt="AD Computers in OU" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Creates Active Directory Computers Accounts in the</span>
<span style="color: #008000;"># specified OU. Reads computer names from a text file</span>
<span style="color: #008000;"># with one computer name per line. Requires an account</span>
<span style="color: #008000;"># with Domain Admin  credentials. </span>
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Created by Dustin Berube on 9/18/2010.</span>
<span style="color: #008000;"># Requires the Quest ActiveRoles Management tools for AD</span>
&nbsp;
<span style="color: #008000;"># Load Quest Powershell Snap-in</span>
<span style="color: #008080; font-weight: bold;">add-pssnapin</span> quest.activeroles.admanagement
&nbsp;
<span style="color: #008000;"># Create pause function to hold the display on screen</span>
<span style="color: #0000FF;">function</span> Pause <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Message</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;Press any key to continue...&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #008080; font-style: italic;">-NoNewLine</span> <span style="color: #800080;">$Message</span>
    <span style="color: #800080;">$null</span> <span style="color: pink;">=</span> <span style="color: #000080;">$Host</span>.UI.RawUI.ReadKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;NoEcho,IncludeKeyDown&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;&quot;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Obtain import file, OU, and Computer location</span>
<span style="color: #800080;">$textFile</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">read-host</span> <span style="color: #800000;">&quot;Path to text file cotaining computer names&quot;</span>
<span style="color: #800080;">$ou</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">read-host</span> <span style="color: #800000;">&quot;Please enter the OU (Format of domain.suffix/ou/ou)&quot;</span>
<span style="color: #800080;">$location</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">read-host</span> <span style="color: #800000;">&quot;Please Enter the Location&quot;</span>
&nbsp;
<span style="color: #008000;"># Load the contents of the text file to an array</span>
<span style="color: #800080;">$computer</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">gc</span> <span style="color: #800080;">$textFile</span>
&nbsp;
<span style="color: #008000;"># first check to see if computer accounts already exist with</span>
<span style="color: #008000;"># the specified name. If not create the account.</span>
<span style="color: #800080;">$compCheck</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>qadcomputer <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$computer</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">select</span> name<span style="color: pink;">,</span> dn
<span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$compCheck</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: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>ERROR: The following Computer Accounts already exist.<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span>
    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$x</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$compCheck</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$obj</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> psobject
        <span style="color: #800080;">$obj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">add-member</span> noteproperty ComputerAccount <span style="color: #800080;">$x</span>.name
        <span style="color: #800080;">$obj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">add-member</span> noteproperty DN <span style="color: #800080;">$x</span>.DN
        <span style="color: #008080; font-weight: bold;">write-output</span> <span style="color: #800080;">$obj</span>;$i<span style="color: pink;">++</span>;
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>Please correct the error and run the import script again.<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span>
    pause
<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;<span style="color: #008080; font-weight: bold;">`n</span>SUCCESS: Added the following computer account(s) to this OU<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: #800080;">$ou</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span>
    <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$x</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$computer</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        new<span style="color: pink;">-</span>qadcomputer <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$x</span> <span style="color: pink;">-</span>SamAccountName <span style="color: #800080;">$x</span> <span style="color: pink;">-</span>ParentContainer <span style="color: #800080;">$ou</span> <span style="color: pink;">-</span>Location <span style="color: #800080;">$location</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;<span style="color: #008080; font-weight: bold;">`n</span>&quot;</span> <span style="color: #008000;"># Add blank line before pause</span>
    pause
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/09/create-computer-accounts-in-active-directory-from-text-file/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Powershell &#8211; Error Querying Win32_Product</title>
		<link>http://dustinberube.com/2010/09/powershell-error-querying-win32_product/</link>
		<comments>http://dustinberube.com/2010/09/powershell-error-querying-win32_product/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 02:34:05 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[error Win32_Product]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=59</guid>
		<description><![CDATA[Yesterday while writing a Powershell script to enumerate a specific set of software in our domain I ran into an interesting problem. It appears that after installing Windows Installer 4.5 on a Windows XP Service Pack 3 workstation the Win32_Product class becomes inaccessible. In order to generate this error all you need to do is [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday while writing a Powershell script to enumerate a specific set of software in our domain I ran into an interesting problem. It appears that after installing Windows Installer 4.5 on a Windows XP Service Pack 3 workstation the Win32_Product class becomes inaccessible. In order to generate this error all you need to do is run a WMI Object query for the Win32_Product class, sample code below.<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-WmiObject</span> Win32_Product
Error
Number: 0x80041001
Facility: WMI
Description: Generic failure</pre></div></div>

<p>
This error does not exist for Windows Installer 3.1. Another note is that this only becomes an issue if you an installed an application with per-user settings. If you go to this MS knowledge base article you can download the hotfix to resolve the error (email registration required to download hotfix). <a href="http://support.microsoft.com/kb/970553">http://support.microsoft.com/kb/970553</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/09/powershell-error-querying-win32_product/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Home Sweet Home</title>
		<link>http://dustinberube.com/2010/03/home-sweet-home/</link>
		<comments>http://dustinberube.com/2010/03/home-sweet-home/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 02:49:35 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=56</guid>
		<description><![CDATA[After a year of using a VPS and having intermittent network issues, primarily with DNS resolution and packet loss. I have moved all my sites to a new server from Serverloft. Until now my sites have either been hosted in a shared hosting environment or on a VPS. Currently the site is running on a [...]]]></description>
			<content:encoded><![CDATA[<p>After a year of using a VPS and having intermittent network issues, primarily with DNS resolution and packet loss. I have moved all my sites to a new server from Serverloft. Until now my sites have either been hosted in a shared hosting environment or on a VPS. Currently the site is running on a dedicated server with a quad-core Xeon and 4GB of RAM, network connectivity is provided through a 100Mbps switch port. This is a vast improvement over the previous server.</p>
<p>I look forward to providing more content on this site and resuming some web development projects that I had planned, now that there is a proper environment for these projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/03/home-sweet-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updates &amp; New Features on the Way!</title>
		<link>http://dustinberube.com/2010/02/updates-new-features-on-the-way/</link>
		<comments>http://dustinberube.com/2010/02/updates-new-features-on-the-way/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 04:29:17 +0000</pubDate>
		<dc:creator>Dustin Berube</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://dustinberube.com/?p=53</guid>
		<description><![CDATA[I am working on a few new features for my site. One of which will be tying a wiki into my current WordPress installation. I am looking forward to being able to distribute some of the scripts that I rely on daily with the rest of the community, and a wiki will be the perfect [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a few new features for my site. One of which will be tying a wiki into my current WordPress installation. I am looking forward to being able to distribute some of the scripts that I rely on daily with the rest of the community, and a wiki will be the perfect way to do this. Another project that I would like to get underway is a photo gallery. I am contemplating various ways of doing this, currently I am looking towards tying into Flickr (possibly by making use of their API). </p>
<p>In other news I am changing the overall focus of this blog. At the end of 2009 I took a new position as a Systems Administrator working in the public sector. This has reignited my passion of technology and I look forward to sharing some the things I encounter with anyone that care to read this blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://dustinberube.com/2010/02/updates-new-features-on-the-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

