<?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>Michael Phillips Blog &#187; Scripting</title>
	<atom:link href="http://nukeitmike.com/blog/category/scripting/feed" rel="self" type="application/rss+xml" />
	<link>http://nukeitmike.com/blog</link>
	<description>My place to speak about things</description>
	<lastBuildDate>Fri, 03 Feb 2012 22:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Launch a PowerShell script minimized</title>
		<link>http://nukeitmike.com/blog/2011/12/28/launch-a-powershell-script-minimized/</link>
		<comments>http://nukeitmike.com/blog/2011/12/28/launch-a-powershell-script-minimized/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 20:45:55 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Citrix]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/?p=299</guid>
		<description><![CDATA[We use Citrix for a lot of applications, and I have a need to launch Outlook, then an application, and then close Outlook when that application is closed by the user.&#160; This seems like a pretty simple thing to do (and I suppose it is, sort of) but it took me a while to figure [...]]]></description>
			<content:encoded><![CDATA[<p>We use Citrix for a lot of applications, and I have a need to launch Outlook, then an application, and then close Outlook when that application is closed by the user.&#160; This seems like a pretty simple thing to do (and I suppose it is, sort of) but it took me a while to figure it out.&#160; </p>
<p>One piece of the puzzle is that PowerShell remains open if you do it the way I have it setup right now.&#160; If the user closes that PowerShell window, then the monitor process will not close Outlook when the user exits the LOB app.&#160; In order to mitigate this issue somewhat, I wanted to start PowerShell minimized.&#160; The way to do this is:</p>
<blockquote><p>powershell -WindowStyle Minimized .\ScriptToRun.ps1</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2011/12/28/launch-a-powershell-script-minimized//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Powershell to get logon script path from Active Directory</title>
		<link>http://nukeitmike.com/blog/2010/07/29/using-powershell-to-get-logon-script-path-from-active-directory/</link>
		<comments>http://nukeitmike.com/blog/2010/07/29/using-powershell-to-get-logon-script-path-from-active-directory/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 20:57:31 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/2010/07/29/using-powershell-to-get-logon-script-path-from-active-directory/</guid>
		<description><![CDATA[If you want to know what logon script users are getting, this is an easy way to get that information: Import-Module -Name ActiveDirectory Get-ADUser -Filter * -SearchBase &#34;OU=YourOUName,DC=YourDomain,DC=COM&#34; -properties ScriptPath &#124; Export-Csv &#34;c:\script\ADUser.csv&#34; Note: In order for this to work, you have to have the ActiveDirectory Module loaded.&#160;]]></description>
			<content:encoded><![CDATA[<p>If you want to know what logon script users are getting, this is an easy way to get that information:</p>
<blockquote><p>Import-Module -Name ActiveDirectory </p>
<p>Get-ADUser -Filter * -SearchBase &quot;OU=YourOUName,DC=YourDomain,DC=COM&quot; -properties ScriptPath | Export-Csv &quot;c:\script\ADUser.csv&quot;</p>
</blockquote>
<p>Note: In order for this to work, you have to have the ActiveDirectory Module loaded.&#160; </p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2010/07/29/using-powershell-to-get-logon-script-path-from-active-directory//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Not recognized as a cmdlet&#8230;</title>
		<link>http://nukeitmike.com/blog/2010/03/25/not-recognized-as-a-cmdlet/</link>
		<comments>http://nukeitmike.com/blog/2010/03/25/not-recognized-as-a-cmdlet/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 13:07:03 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/2010/03/25/not-recognized-as-a-cmdlet/</guid>
		<description><![CDATA[I have been working on a simple little script to copy a file and then launch a program.&#160; I am sure that there are a lot of ways to do it, but I decided to use PowerShell, and this is what I came up with: $CheckForFile = &#34;H:\custom.ini&#34; $FileToCopy = &#34;c:\IT\custom.ini&#34; $CopyFileTo = &#34;H:\&#34; $PathTest [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a simple little script to copy a file and then launch a program.&#160; I am sure that there are a lot of ways to do it, but I decided to use PowerShell, and this is what I came up with:</p>
<blockquote><p>$CheckForFile = &quot;H:\custom.ini&quot;     <br />$FileToCopy = &quot;c:\IT\custom.ini&quot;      <br />$CopyFileTo = &quot;H:\&quot; </p>
<p>$PathTest = Test-Path $CheckForFile      <br />If ($PathTest -eq &quot;false&quot;)      <br />&#160;&#160;&#160; {      <br />&#160;&#160;&#160; Copy-Item $FileToCopy $CopyFileTo      <br />&#160;&#160;&#160; } </p>
<p>#uses the Invoke-Item command to launch the application     <br />Invoke-Item &quot;C:\Program Files\executable to launch.exe&quot;</p>
</blockquote>
<p>This is for use in a Citrix/Terminal Server environment, so I want to be able to call this script like this: PowerShell copythenlaunch.ps1</p>
<p>When I tested that, I got this:</p>
<blockquote><p>C:\IT&gt;powershell copythenlaunch.ps1     <br />The term &#8216;copythenlaunch.ps1&#8242; is not recognized as a cmdlet, function, operable      <br /> program, or script file. Verify the term and try again.      <br />At line:1 char:18      <br />+ copythenlaunch.ps1 &lt;&lt;&lt;&lt;</p>
</blockquote>
<p>I kept thinking there was some problem with the install of PowerShell (I am running this particular script on a Windows 2003 Server) or that I had some illegal character in the name (it had a number in it originally) or some other simple problem.&#160; Finally I did a search and came across this little bit of conversation:</p>
<blockquote><p>re: Power and Pith<a name="1380970"></a></p>
</blockquote>
<blockquote><p>I just started with PowerShell.</p>
<p>Wanted to run some test scripts from you download.</p>
<p>When I tpye in Beep.ps1 I get &quot;The term &#8216;Beep.1&#8242; is not recognized&#8230;..&quot;</p>
<p>What Am I doing wrong?</p>
<p>Friday, December 29, 2006 3:17 PM by <a>MikeL</a></p>
<h6><a href="http://blogs.msdn.com/powershell/archive/2006/10/21/Power-and-Pith.aspx#1381442">#</a> re: Power and Pith<a name="1381442"></a></h6>
<p>&gt; When I tpye in Beep.ps1 I get &quot;The term &#8216;Beep.1&#8242; is not recognized&#8230;..&quot;</p>
<p>&gt; What Am I doing wrong?</p>
<p>You are relying upon a traditional bad shell behaviour that has been a security nightmere for decades.</p>
<p>In PowerShell, you have to be explicit if you want to run a command in the current directory.&#160; Type &quot;.\beep.ps1&quot;</p>
<p>Jeffrey Snover [MSFT]</p>
<p>Windows PowerShell/MMC Architect</p>
<p>Visit the Windows PowerShell Team blog at:&#160;&#160;&#160; <a href="http://blogs.msdn.com/PowerShell">http://blogs.msdn.com/PowerShell</a></p>
<p>Visit the Windows PowerShell ScriptCenter at:&#160; <a href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx">http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx</a></p>
<p>Friday, December 29, 2006 5:19 PM by <a href="http://blogs.msdn.com/user/Profile.aspx?UserID=29278">PowerShellTeam</a></p>
<h6><a href="http://blogs.msdn.com/powershell/archive/2006/10/21/Power-and-Pith.aspx#1865770">#</a> re: Power and Pith<a name="1865770"></a></h6>
<p><strong>Thank You for supplying the &quot;.\*&quot; information.&#160; I have been racking my brain for almost two days wondering what I was doing wrong.&#160; And to think it was as simple as using the PROPER .\yourscripthere.ps1 format.</strong></p>
<p>Thank you very very much</p>
</blockquote>
<p>Ditto on the thanks…</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2006/10/21/Power-and-Pith.aspx">Windows PowerShell Blog : Power and Pith</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2010/03/25/not-recognized-as-a-cmdlet//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Confirm Preference</title>
		<link>http://nukeitmike.com/blog/2010/03/04/powershell-confirm-preference/</link>
		<comments>http://nukeitmike.com/blog/2010/03/04/powershell-confirm-preference/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 03:47:39 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/2010/03/04/powershell-confirm-preference/</guid>
		<description><![CDATA[I seem to run into an issue when I run some PowerShell scripts where I get prompted at each line of the script for confirmation.&#160; That can get really annoying, so I have to look up how to prevent that behavior.&#160; Thankfully, there is already some good information out there on how to do that: [...]]]></description>
			<content:encoded><![CDATA[<p> I seem to run into an issue when I run some PowerShell scripts where I get prompted at each line of the script for confirmation.&#160; That can get really annoying, so I have to look up how to prevent that behavior.&#160; Thankfully, there is already some good information out there on how to do that: </p>
<blockquote><p>When confirmation is turned on by $ConfirmPreference, you can turn it off for any individual cmdlet invocation using &quot;-Confirm:$false&quot;.&#160; You can also use &quot;-Confirm:$false&quot; to turn off default confirmation for high impact cmdlets such as Removing a Mailbox.&#160; Another way to turn off confirmation is by setting $ConfirmPreference to &quot;None&quot;; you can limit the effect by setting $script:ConfirmPreference etc, see &quot;get-help about_scope&quot; for more details.</p>
</blockquote>
<p>For more details and options besides just turning it off, go see the original post:</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2006/12/15/confirmpreference.aspx">Windows PowerShell Blog : ConfirmPreference</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2010/03/04/powershell-confirm-preference//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servers in Domain</title>
		<link>http://nukeitmike.com/blog/2010/02/24/servers-in-domain/</link>
		<comments>http://nukeitmike.com/blog/2010/02/24/servers-in-domain/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 03:24:25 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/2010/02/24/servers-in-domain-2/</guid>
		<description><![CDATA[At some point, I had a desire to list all the computer accounts for any server OS in Active Directory.  I am pretty sure that I did a search and found the script below, but I don’t remember where, so whoever wrote it doesn’t get credit this time… $strCategory = &#8220;computer&#8221; $strOperatingSystem = &#8220;Windows*Server*&#8221; $objDomain [...]]]></description>
			<content:encoded><![CDATA[<p>At some point, I had a desire to list all the computer accounts for any server OS in Active Directory.  I am pretty sure that I did a search and found the script below, but I don’t remember where, so whoever wrote it doesn’t get credit this time…</p>
<blockquote><p>$strCategory = &#8220;computer&#8221;<br />
$strOperatingSystem = &#8220;Windows*Server*&#8221;</p>
<p>$objDomain = New-Object System.DirectoryServices.DirectoryEntry</p>
<p>$objSearcher = New-Object System.DirectoryServices.DirectorySearcher<br />
$objSearcher.SearchRoot = $objDomain</p>
<p>$objSearcher.Filter = (&#8220;OperatingSystem=$strOperatingSystem&#8221;)</p>
<p>$colProplist = &#8220;name&#8221;<br />
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}</p>
<p>$colResults = $objSearcher.FindAll()<br />
Write-Host $colResults.count<br />
foreach ($objResult in $colResults)<br />
    {<br />
    $objComputer = $objResult.Properties;<br />
    $objComputer.name<br />
    }</p></blockquote>
<p>If you change the $strOperatingSystem = “Windows*Server*” to something like $strOperatingSystem = “Windows*”  it will return all computer accounts that have “Windows” in the Name field on the Operating System tab of the properties of the AD object:</p>
<p><a href="http://nukeitmike.com/blog/wp-content/uploads/2010/02/image.png"><img title="image" src="http://nukeitmike.com/blog/wp-content/uploads/2010/02/image_thumb.png" border="0" alt="image" width="644" height="263" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2010/02/24/servers-in-domain//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using XML in your PowerShell scripting</title>
		<link>http://nukeitmike.com/blog/2009/09/22/using-xml-in-your-powershell-scripting/</link>
		<comments>http://nukeitmike.com/blog/2009/09/22/using-xml-in-your-powershell-scripting/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 03:07:19 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/2009/09/22/using-xml-in-your-powershell-scripting/</guid>
		<description><![CDATA[I have written a lot of scripts that use .txt files to read or store data, but I have a need to read some information from an .xml file.  This could be done by treating the file as a simple txt file, but it would require some pretty good filtering that is already a part [...]]]></description>
			<content:encoded><![CDATA[<p>I have written a lot of scripts that use .txt files to read or store data, but I have a need to read some information from an .xml file.  This could be done by treating the file as a simple txt file, but it would require some pretty good filtering that is already a part of the xml file.  A quick search helped me locate this article:</p>
<blockquote><p><a title="http://blogs.msdn.com/kalleb/archive/2008/07/19/using-powershell-to-read-xml-files.aspx" href="http://blogs.msdn.com/kalleb/archive/2008/07/19/using-powershell-to-read-xml-files.aspx">http://blogs.msdn.com/kalleb/archive/2008/07/19/using-powershell-to-read-xml-files.aspx</a></p></blockquote>
<p>Which contained the key to helping me with what I needed to do.  The specific piece I needed was in Lesson 2:</p>
<blockquote><p>Lesson 2:<br />
Read data from an XML-file.<br />
The XML-file that I&#8217;m going to read from has the following structure:<br />
&lt;Users&gt;<br />
  &lt;User&gt;<br />
    &lt;Name&gt;Kalle&lt;/Name&gt;<br />
&lt;/User&gt;<br />
  &lt;User&gt;<br />
    &lt;Name&gt;Becker&lt;/Name&gt;<br />
  &lt;/User&gt;<br />
&lt;/Users&gt;<br />
Reading data from an XML-file is really easy in PowerShell! Use this command to load the file into an variable:<br />
PS C:\Tmp&gt; <em>[xml]$userfile = Get-Content Accounts.xml </em></p>
<p>When the xml-file is loaded you can type <em>&#8220;$userfile.U</em>&#8221; and press tab to get auto completion!! It&#8217;s a breeze.</p></blockquote>
<p>The trick is that you have to actually READ what is in front of you.  The key here is to let PowerShell know that you are reading an xml file, and that is done by placing<strong> [xml]</strong> prior to getting the content.  I missed that the first six times I read this and couldn’t figure out why I wasn’t getting the results I expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2009/09/22/using-xml-in-your-powershell-scripting//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring drive space</title>
		<link>http://nukeitmike.com/blog/2009/09/04/monitoring-drive-space/</link>
		<comments>http://nukeitmike.com/blog/2009/09/04/monitoring-drive-space/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 21:25:29 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[General Info]]></category>
		<category><![CDATA[Operational Excellence]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/2009/09/04/monitoring-drive-space/</guid>
		<description><![CDATA[One of the things that we spend a lot of time on is trying to keep track of what servers have enough free space.&#160; We have a lot of different tools to check drive space, and we even use some of them from time to time.&#160; We have a pretty complicated system created by Rickey [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that we spend a lot of time on is trying to keep track of what servers have enough free space.&#160; We have a lot of different tools to check drive space, and we even use some of them from time to time.&#160; We have a pretty complicated system created by <a href="http://www.whitworth.org/" target="_blank">Rickey</a> that creates a nice webpage, with highlighting for problem areas (percentage change from day to day, current percent free, etc.)&#160; It even puts the info into a database for historical reporting.</p>
<p>We don’t store or report on VMs currently, mainly because we were trying to keep track of total REAL disk used.&#160; VMs often don’t use as much as they think they do, so that would skew the results, as well as the fact that we are reporting on the hosts.&#160; </p>
<p>All of that is the reason that <a href="http://pburch.com/blog" target="_blank">Patrick</a> asked me to come up with some other tool to use for the VMs so I happened to find a few pieces of PowerShell script that I managed to put together to do a pretty good job of providing some of the info we wanted, and I thought I would share that with the 2 people who read my blog.&#160; <img src='http://nukeitmike.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#160;</p>
<blockquote><p>$servers = Get-Content servers.txt </p>
<p>#Open Excel and create a new workbook and worksheet     <br />$ExcelSheet=New-Object -comobject Excel.application&#160;&#160;&#160; <br />$WorkBook=$ExcelSheet.WorkBooks.add(1)&#160;&#160;&#160;&#160; <br />$WorkSheet=$WorkBook.WorkSheets.item(1)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p>
<p>#Header row     <br />$WorkSheet.cells.item(1,1)=”Computer Name”&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />$WorkSheet.cells.item(1,2)=”Disk Device ID”&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />$WorkSheet.cells.item(1,3)=”Volume Name”&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />$WorkSheet.cells.item(1,4)=”Size (GB)”&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />$WorkSheet.cells.item(1,5)=”Free Space (GB)”      <br />$WorkSheet.cells.item(1,6)=”Space Used (GB)”      <br />$WorkSheet.cells.item(1,7)=”Percent Used” </p>
<p>$i=2 </p>
<p>ForEach ($ComputerName in $servers)     <br />{&#160;&#160;&#160; <br />&#160;&#160;&#160; echo &quot;Server Name : &quot;, $ComputerName      <br />&#160;&#160;&#160; $Disks = gwmi –computername $ComputerName win32_logicaldisk -filter &quot;drivetype=3&quot; </p>
<p>&#160;&#160;&#160; foreach ($Disk in $Disks)      <br />&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Size = &quot;{0:0.0}&quot; -f ($Disk.Size/1GB)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FreeSpace = &quot;{0:0.0}&quot; -f ($Disk.FreeSpace/1GB)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Used = ([int64]$Disk.size &#8211; [int64]$Disk.freespace)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $SpaceUsed = &quot;{0:0.0}&quot; -f ($Used/1GB)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Percent = ($Used * 100.0)/$Disk.Size      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Percent = &quot;{0:N0}&quot; -f $Percent      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,1)=$ComputerName      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,2)=$Disk.deviceid      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,3)=$Disk.volumename      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,4)=$Size      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,5)=$FreeSpace      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,6)=$SpaceUsed      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $WorkSheet.cells.item($i,7)=$Percent </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $i=$i+1&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; }      <br />}      <br />#Show the results      <br />$ExcelSheet.visible=$true</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2009/09/04/monitoring-drive-space//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another Registry Script&#8230;</title>
		<link>http://nukeitmike.com/blog/2009/03/11/another-registry-script/</link>
		<comments>http://nukeitmike.com/blog/2009/03/11/another-registry-script/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 03:18:30 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://nukeitmike.com/blog/?p=111</guid>
		<description><![CDATA[I have the unfortunate need to occasionally fix things in the registry, mostly related to applications running in a Citrix environment.  I believe there are nice tools out there that are supposed to do this for you, if given the right information, but I haven&#8217;t bothered to figure out what those tools are or how [...]]]></description>
			<content:encoded><![CDATA[<p>I have the unfortunate need to occasionally fix things in the registry, mostly related to applications running in a Citrix environment.  I believe there are nice tools out there that are supposed to do this for you, if given the right information, but I haven&#8217;t bothered to figure out what those tools are or how to use them.  Instead, I torture myself with trying to muddle through VBScript and make it do what I want. </p>
<p>In that spirit, I am going to show you one of my pitiful scripts (and this one is horrible, because I didn&#8217;t bother to clean it up after I worked out how to make it accomplish the desired goal.  So&#8230; here you go:</p>
<p>&#8216;==========================================================================<br />
&#8216;<br />
&#8216; VBScript Source File &#8212; Created with SAPIEN Technologies PrimalScript 2007<br />
&#8216;<br />
&#8216; NAME: BorlandDBPathFix.vbs<br />
&#8216;<br />
&#8216; AUTHOR: Michael Phillips , Brasfield &amp; Gorrie, LLC<br />
&#8216; DATE : March 11, 2009<br />
&#8216;<br />
&#8216; COMMENT: This script is to change the value of 2 registry keys on a per<br />
&#8216; user basis. It should set the value to be the correct system<br />
&#8216; drive (c: or u:).<br />
&#8216; It should also be noted that this script isn&#8217;t very pretty.<br />
&#8216;==========================================================================<br />
&#8216;Registry stuff<br />
Const HKCU = &amp;H80000001 &#8216;This defines the Current User Hive<br />
Const HKLM = &amp;H80000002 &#8216;This defines the Local Machine Hive<br />
Const REG_SZ = 1<br />
Const REG_EXPAND_SZ = 2<br />
Const REG_BINARY = 3<br />
Const REG_DWORD = 4<br />
Const REG_MULTI_SZ = 7<br />
vDebug = 1<br />
Dim strComputer</p>
<p>strComputer = &#8220;.&#8221; &#8216;This computer is the &#8220;.&#8221;. If you want another computer, replace the .</p>
<p>Set oReg=GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\&#8221; &amp; _<br />
strComputer &amp; &#8220;\root\default:StdRegProv&#8221;)</p>
<p>sGetPath<br />
Sub sGetPath<br />
Set oShell = CreateObject( &#8220;WScript.Shell&#8221; )<br />
strSystemDrive = oShell.ExpandEnvironmentStrings(&#8220;%systemdrive%&#8221;)<br />
&#8216;* wscript.echo strSystemDrive<br />
fGetRegistryValues strSystemDrive<br />
End Sub</p>
<p>&#8216;*<br />
&#8216;* This is what we are looking for:<br />
&#8216;* [HKCU\Software\Borland\BDS\4.0\DBExpress]<br />
&#8216;* @=&#8221;"<br />
&#8216;* &#8220;Connection Registry File&#8221;=&#8221;C:\\Program Files\\Common Files\\Borland Shared\\DBExpress\\dbxconnections.ini&#8221;<br />
&#8216;* &#8220;Driver Registry File&#8221;=&#8221;C:\\Program Files\\Common Files\\Borland Shared\\DBExpress\\dbxdrivers.ini&#8221;<br />
Function fGetRegistryValues (vSystemDrive)<br />
&#8216;* wscript.echo vSystemDrive &amp; &#8221; is being passed as vSystemDrive&#8221;<br />
oReg.GetExpandedStringValue HKCU,&#8221;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Connection Registry File&#8221;,strValue1<br />
oReg.GetExpandedStringValue HKCU,&#8221;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Driver Registry File&#8221;,strValue2<br />
strDriveLetter1 = Left (strValue1,2)<br />
&#8216;* wscript.echo strDriveLetter1 &amp; strValue1 &amp; strSystemDrive<br />
strDriveLetter2 = Left (strValue2,2)<br />
If strDriveLetter1 = vSystemDrive Then<br />
If strDriveLetter2 = vSystemDrive Then<br />
Else<br />
fSetRegistryValues strValue1,strValue2,vSystemDrive</p>
<p>End If<br />
Else<br />
fSetRegistryValues strValue1,strValue2,vSystemDrive<br />
End If<br />
End Function<br />
Function fSetRegistryValues (fValue1,fValue2,fDriveLetter)<br />
&#8216;* wscript.echo &#8220;Bad Letter is being passed &#8221; &amp; fValue1 &amp; fValue2 &amp; fDriveLetter<br />
vLength1 = (Len (fValue1))-2<br />
vLength2 = (Len (fValue2))-2<br />
&#8216;* wscript.echo &#8220;&#8211;strValue1 &amp; vLength1&#8211; &gt;&#8221; &amp; fValue1 &amp; &#8221; &#8221; &amp; vLength1<br />
strPathNoLetter1 = Right (fValue1,vLength1)<br />
strNewKeyValue1 = fDriveLetter &amp; strPathNoLetter1<br />
fWriteStringRegistryValues &#8220;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Connection Registry File&#8221;,strNewKeyValue1<br />
&#8216;* wscript.echo strNewKeyValue1</p>
<p>strPathNoLetter2 = Right (fValue2,vLength2)<br />
strNewKeyValue2 = fDriveLetter &amp; strPathNoLetter2<br />
fWriteStringRegistryValues &#8220;Software\Borland\BDS\4.0\DBExpress&#8221;,&#8221;Driver Registry File&#8221;,strNewKeyValue2<br />
&#8216;* wscript.echo (fDriveLetter &amp; (Right (fValue2,vLength2)))<br />
End Function</p>
<p>Function fWriteStringRegistryValues (fvRegistryKeyPath,fvRegistryKeyName,fvRegistryKeyValue)<br />
If vDebug = 1 Then<br />
&#8216;* wscript.echo &#8220;Begining Function -fWriteStringRegistryValues-.&#8221;<br />
End If<br />
&#8216; This function takes input to write string values to the registry. Key must already exist.<br />
oReg.SetStringValue HKCU,fvRegistryKeyPath,fvRegistryKeyName,fvRegistryKeyValue<br />
End Function</p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2009/03/11/another-registry-script//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading a Unicode text file using VB Script</title>
		<link>http://nukeitmike.com/blog/2007/09/07/reading-a-unicode-text-file-using-vb-script/</link>
		<comments>http://nukeitmike.com/blog/2007/09/07/reading-a-unicode-text-file-using-vb-script/#comments</comments>
		<pubDate>Fri, 07 Sep 2007 00:15:41 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.nukeitmike.com/blog/2007/09/07/ReadingAUnicodeTextFileUsingVBScript.aspx</guid>
		<description><![CDATA[&#160;I was looking for something else and came across this in the Scripting guy archives&#8230; Set objFile = objFSO.OpenTextFile("c:\scripts\test.txt", ForReading,False,TriStateTrue) The first two parameters probably don’t faze you much: they’re simply the full path to the file we want to open and the constant ForReading. And you’re right: this is standard operating procedure when it [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;I was looking for something else and came across this in the Scripting guy archives&#8230;</p>
<blockquote><pre><em>Set objFile = objFSO.OpenTextFile("c:\scripts\test.txt", ForReading,False,TriStateTrue)</em></pre>
<p><em>The first two parameters probably don’t faze you much: they’re simply the full path to the file we want to open and the constant ForReading. And you’re right: this is standard operating procedure when it comes to reading text files. But what about those other two parameters, one <b>False</b>, the other the constant <b>TriStateTrue</b>?</em></p>
<p><em>This is where the Scripting Guys perform their magic. The optional third parameter is a Boolean parameter that, if True, creates the specified text file if the file cannot be found. Because we’re only interested in opening an existing file, we set this parameter to False (which is also the default value).</em></p>
<p><em>That brings us to parameter 4, our old pal TriStateTrue. If the fourth parameter passed to the OpenTextFile method is equal to -1 then the file will be opened as a Unicode file. It’s that easy. Leave the fourth parameter off and the file will be opened as ASCII; set the fourth parameter to -1 and &#8211; presto-changeo! &#8211; your file will be opened as Unicode,</em></p>
</blockquote>
<p><a href="http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr06/hey0419.mspx"><em>Hey, Scripting Guy! How Can I Open a Text File as Unicode?</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2007/09/07/reading-a-unicode-text-file-using-vb-script//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode isn&#8217;t friendly to vbscript</title>
		<link>http://nukeitmike.com/blog/2007/08/29/unicode-isnt-friendly-to-vbscript/</link>
		<comments>http://nukeitmike.com/blog/2007/08/29/unicode-isnt-friendly-to-vbscript/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 20:32:15 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.nukeitmike.com/blog/2007/08/29/UnicodeIsntFriendlyToVbscript.aspx</guid>
		<description><![CDATA[I was trying to write a script to read a text file and evaluate the data to do some formatting on it.&#160; This is for a project I am working on and the person that gave me the text file wants some changes made based on the contents of the file.&#160; I have done similar [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to write a script to read a text file and evaluate the data to do some formatting on it.&nbsp; This is for a project I am working on and the person that gave me the text file wants some changes made based on the contents of the file.&nbsp; I have done similar things before, but I kept having trouble with this one.</p>
<p>I started with trying to do a <em>readline </em>and then <em>echo</em> that back.&nbsp; Every time I tried it, I got <em>&nbsp;<font color="#ff0000">ÿ_[</font></em>&nbsp; (y with the umlaut, underscore and the bracket)as the output for the first line and then nothing for everything after that.&nbsp; I tried it against other text files and got the expected result.&nbsp; I was investigating, trying to figure out if there was a character in the file that didn&#8217;t work well, and finally decided to try and do a <em>writeline</em> to another text file to see if it would at least write the value out that way.&nbsp; </p>
<p>Imagine my surprise when the results came back with a space between each letter in the source file.&nbsp; Turns out that it was in UNICODE format.&nbsp; I saved it as ANSI and then everything was golden.&nbsp; I also noticed that the file was half the original size&#8230;&nbsp; must have to do with all those extra spaces&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://nukeitmike.com/blog/2007/08/29/unicode-isnt-friendly-to-vbscript//feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

