<?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>thomasmaurer.ch &#187; Windows</title>
	<atom:link href="http://www.thomasmaurer.ch/tag/windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thomasmaurer.ch</link>
	<description>Just another sys admin weblog</description>
	<lastBuildDate>Wed, 08 Sep 2010 14:14:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Powershell: How to rename all files in a folder</title>
		<link>http://www.thomasmaurer.ch/2010/08/powershell-how-to-rename-all-files-in-a-folder/</link>
		<comments>http://www.thomasmaurer.ch/2010/08/powershell-how-to-rename-all-files-in-a-folder/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 06:01:02 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[change extentions]]></category>
		<category><![CDATA[extention]]></category>
		<category><![CDATA[extentions]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[get-content]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[rename files]]></category>
		<category><![CDATA[rename-item]]></category>
		<category><![CDATA[renaming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Powershell]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=999</guid>
		<description><![CDATA[Sometimes you need a fast way to rename a lot of file. With Powershell this is pretty easy. You list all files in the directory and you can use this object with a foreach loop. This script basically changes the &#8230; <a href="http://www.thomasmaurer.ch/2010/08/powershell-how-to-rename-all-files-in-a-folder/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" alt="Powershell Header" width="440" height="104" /></p>
<p>Sometimes you need a fast way to rename a lot of file. With Powershell this is pretty easy. You list all files in the directory and you can use this object with a foreach loop.</p>
<p>This script basically changes the extension from .JPEG to .jpg:<br />
[powershell]$files = Get-Content<br />
foreach ($file in $files) {<br />
	$newFileName=$file.name.replace(&#8220;.JPEG&#8221;,&#8221;.jpg&#8221;)<br />
	Rename-Item $file $newFileName<br />
}[/powershell]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/08/powershell-how-to-rename-all-files-in-a-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a Powershell v2 Module</title>
		<link>http://www.thomasmaurer.ch/2010/08/how-to-create-a-powershell-v2-module/</link>
		<comments>http://www.thomasmaurer.ch/2010/08/how-to-create-a-powershell-v2-module/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 06:00:08 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[dotsourced]]></category>
		<category><![CDATA[Import-Module]]></category>
		<category><![CDATA[Module]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Powershell Module]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Powershell]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=937</guid>
		<description><![CDATA[If you need some functions a lot in different scripts you create maybe external function files. This is a good way to clean up your code. To get this functions running in your mainscript.ps1 you can call this other file &#8230; <a href="http://www.thomasmaurer.ch/2010/08/how-to-create-a-powershell-v2-module/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" alt="Powershell Header" width="440" height="104" /></p>
<p>If you need some functions a lot in different scripts you create maybe external function files. This is a good way to clean up your code. To get this functions running in your mainscript.ps1 you can call this other file &#8220;dotsourced&#8221;:</p>
<p>[powershell]<br />
. C:\PSscript\output\sayhello.ps1<br />
[/powershell]</p>
<p>If you have more than one external function you have to call each file:</p>
<p>[powershell]<br />
. C:\PSscript\Modules\Output\sayhello.ps1<br />
. C:\PSscript\Modules\Output\saygoodday.ps1<br />
. C:\PSscript\Modules\Output\saybye.ps1<br />
[/powershell]</p>
<p>In Powershell v2 you can create your own modules, which you can call by:</p>
<p>[powershell]<br />
Import-Module C:\PSscript\Modules\Output<br />
[/powershell]</p>
<p>Now how can you create this output module?</p>
<ul>
<li>First you create a directory for the all modules, called Modules</li>
<li>Secound you create a directory for the Output module, called Output</li>
<li>Than copy all of your Powershell Scripts (.ps1 files) in to this folder</li>
<li>Now create a file called Output.psm1. Its important that this file has the same name as the folder</li>
<li>In this file write the following code (for each file in this folder):<br />
[powershell]<br />
. ./Modules/Output/sayhello.ps1<br />
. ./Modules//Output/saygoodday.ps1<br />
. ./Modules//Output/saybye.ps1<br />
[/powershell]</li>
</ul>
<p>Now you can use the Import-Module to import your own module called output.</p>
<p>There are a lot of other things you can use to make everything a little bit easier, like system variables for the module and script paths.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/08/how-to-create-a-powershell-v2-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Changing registry key value</title>
		<link>http://www.thomasmaurer.ch/2010/08/powershell-changing-registry-key-value/</link>
		<comments>http://www.thomasmaurer.ch/2010/08/powershell-changing-registry-key-value/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 16:00:21 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Changing]]></category>
		<category><![CDATA[get-psdrive]]></category>
		<category><![CDATA[HKLM]]></category>
		<category><![CDATA[key value]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[Microsoft Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[registry key value]]></category>
		<category><![CDATA[Set-ItemProperty]]></category>
		<category><![CDATA[Set-Location]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[Windows Registry]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=907</guid>
		<description><![CDATA[After posting Pagefile size bigger than 4095MB on Windows Server 2003 I had the Idea to change this registry values with powershell. First start powershell You can get all PS Drives with the command [powershell]Get-PSDrive[/powershell] Now you see the drive &#8230; <a href="http://www.thomasmaurer.ch/2010/08/powershell-changing-registry-key-value/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-medium wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42-300x70.png" alt="Powershell Header" width="300" height="70" /></p>
<p>After posting <a title="Pagefile size bigger than 4095MB on Windows Server 2003" href="http://www.thomasmaurer.ch/2010/08/pagefile-size-bigger-than-4095mb-on-windows-server-2003/" target="_blank">Pagefile size bigger than 4095MB on Windows Server 2003</a> I had the Idea to change this registry values with powershell.</p>
<ol>
<li>First start powershell</li>
<li>You can get all PS Drives with the command<br />
[powershell]Get-PSDrive[/powershell]<br />
<a href="http://www.thomasmaurer.ch/wp-content/uploads/2010/08/Screen-shot-2010-08-02-at-16.41.23.png" rel="lightbox[907]"><img class="aligncenter size-medium wp-image-909" title="Get-PSDrive" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/08/Screen-shot-2010-08-02-at-16.41.23-300x152.png" alt="Get-PSDrive" width="300" height="152" /></a></li>
<li>Now you see the drive HKLM which stands for HKEY_LOCAL_MACHINE</li>
<li>Open this Registry Key<br />
[powershell]Set-Location &#8216;HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management&#8217;[/powershell]</li>
<li>With this command you get all the key values<br />
[powershell]Get-ItemProperty -path .[/powershell]</li>
<li> With the next command you can set the the key value<br />
[powershell]Set-ItemProperty -path . -name &#8220;PagingFiles&#8221; -value &#8220;D:\pagefile1\pagefile.sys 4096 4096&#8243;[/powershell]</li>
</ol>
<p>And now the simple way with multiple entries:<br />
[powershell]<br />
$values = @&#8221;<br />
D:\pagefile1\pagefile.sys 4096 4096<br />
D:\pagefile2\pagefile.sys 4096 4096<br />
&#8220;@<br />
$keys = &#8220;HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management&#8221;<br />
$name = &#8220;PagingFiles&#8221;<br />
Set-ItemProperty -path $keys -name $name -value $values<br />
[/powershell]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/08/powershell-changing-registry-key-value/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pagefile size bigger than 4095MB on Windows Server 2003</title>
		<link>http://www.thomasmaurer.ch/2010/08/pagefile-size-bigger-than-4095mb-on-windows-server-2003/</link>
		<comments>http://www.thomasmaurer.ch/2010/08/pagefile-size-bigger-than-4095mb-on-windows-server-2003/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 16:00:01 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[32bit]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[multiple pagefiles]]></category>
		<category><![CDATA[Pagefile]]></category>
		<category><![CDATA[Pagefiles]]></category>
		<category><![CDATA[partitions]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=903</guid>
		<description><![CDATA[The pagefile size on Windows Server 2003 x86 and other Windows x86 platforms is limited to 4095 MB per pagefile. But a lot of Windows Server 2003 systems already have 4GB RAM and are using PAE (Physical Address Extension) to &#8230; <a href="http://www.thomasmaurer.ch/2010/08/pagefile-size-bigger-than-4095mb-on-windows-server-2003/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The pagefile size on Windows Server 2003 x86 and other Windows x86 platforms is limited to 4095 MB per pagefile. But a lot of Windows Server 2003 systems already have 4GB RAM and are using PAE (<a title="PAE Physical Address Extension Wikipedia" href="http://en.wikipedia.org/wiki/Physical_Address_Extension" target="_blank">Physical Address Extension</a>) to use them. So it would be useful to create more than 4 GB pagefiles.</p>
<p>Microsofts solution for this is to create multiple pagefiles. You can now create multiple pagefiles on different partitions. If you don&#8217;t have enough partitions or you just have one, you can create multiple pagefile in different folders by using the Windows Registry.</p>
<p><a href="http://www.thomasmaurer.ch/wp-content/uploads/2010/08/Screen-shot-2010-08-02-at-16.25.07.png" rel="lightbox[903]"><img class="aligncenter size-full wp-image-904" title="Pagefiles" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/08/Screen-shot-2010-08-02-at-16.25.07.png" alt="Pagefiles" width="384" height="351" /></a></p>
<ol>
<li>Create the folders on the drive where the pagefiles should be located. For example, C:\Pagefile1, C:\Pagefile2, and C:\Pagefile3.</li>
<li>Open regedit.exe</li>
<li>I would recommend to create a backup of the registry</li>
<li>locate this key:<br />
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SessionManager\MemoryManagement</li>
<li>Edit the value &#8220;PagingFiles&#8221;</li>
<li>Remove the existing values and add the following values:<br />
C:\Pagefile1\pagefile.sys 4096 4096<br />
C:\Pagefile2\pagefile.sys 4096 4096<br />
C:\Pagefile3\pagefile.sys 4096 4096</li>
<li>Save this</li>
</ol>
<p>Note: It&#8217;s still recommended to have the Pagefiles on the same partition as the system</p>
<p>You can get more information in this Microsoft Knowledge Base entry: <a title="How to overcome the 4,095 MB paging file size limit in Windows" href="http://support.microsoft.com/kb/237740" target="_blank">How to overcome the 4,095 MB paging file size limit in Windows</a></p>
<p>How to do this with Powershell: <a title="Powershell: Changing registry key value" href="http://www.thomasmaurer.ch/2010/08/powershell-changing-registry-key-value/" target="_blank">Powershell: Changing registry key value</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/08/pagefile-size-bigger-than-4095mb-on-windows-server-2003/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Powershell: Working with XML part 2</title>
		<link>http://www.thomasmaurer.ch/2010/07/powershell-working-with-xml-part-2/</link>
		<comments>http://www.thomasmaurer.ch/2010/07/powershell-working-with-xml-part-2/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 13:42:04 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Server Core]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[Add Data to XML]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[Microsoft Powershell]]></category>
		<category><![CDATA[Object]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Remove]]></category>
		<category><![CDATA[Remove data from XML]]></category>
		<category><![CDATA[Save]]></category>
		<category><![CDATA[Save XML Object]]></category>
		<category><![CDATA[Saving data to XML]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Windows Powershell]]></category>
		<category><![CDATA[Working]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XML Powershell]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=863</guid>
		<description><![CDATA[After my first post (Powershell: Parsing XML part 1) about working with XML and Powershell, I have create this second post which describes how to create a XML file, Add content to the XML file, remove content from the XML &#8230; <a href="http://www.thomasmaurer.ch/2010/07/powershell-working-with-xml-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" rel="lightbox[863]"><img class="aligncenter size-full wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" alt="Powershell Header" width="440" height="104" /></a></p>
<p>After my first post (<a href="http://www.thomasmaurer.ch/2010/06/powershell-parsing-xml-part-1/">Powershell: Parsing XML part 1</a>) about working with XML and Powershell, I have create this second post which describes how to create a XML file, Add content to the XML file, remove content from the XML file and save the XML objects as a file.</p>
<p>While I was writing a script which communicates with a webserver, I realized that I need some error handling if the server can not anwser a request from my script. For example if the webserver is down or has to much load.</p>
<p>I created a little retry part (<a href="http://www.thomasmaurer.ch/2010/07/powershell-simple-retry-logic/" target="_self">Powershell: Simple retry logic</a>) which retries several times. But if the Server is down for several hours or days your script hangs in a retry loop. Obviously this cant be the solution. After a little bit of thinking a decided to write the data, which I was trying to send, down in a XML file. And the next time the script runs it reads the XML file and tries to send the data again.</p>
<p>Thats the story behind my idea for saving data in a XML file.</p>
<h2>Creating a XML object</h2>
<p>[powershell]<br />
[XML]$FruitList = &#8220;&lt;Box&gt;<br />
&lt;Fruit&gt;<br />
&lt;Name&gt;Banana&lt;/Name&gt;<br />
&lt;Color&gt;yellow&lt;/Color&gt;<br />
&lt;/Fruit&gt;<br />
&lt;/Box&gt;&#8221;<br />
[/powershell]</p>
<h2>Save a XML object as a XML file</h2>
<p>[powershell]<br />
$FruitList.Save(&#8220;./myfruitlist.xml&#8221;)<br />
[/powershell]<br />
XML:<br />
[XML]<br />
<Box><br />
	<Fruit><br />
		<Name>Banana</Name><br />
		<Color>yellow</Color><br />
	</Fruit><br />
</Box><br />
[/XML]</p>
<h2>Open a saved XML file</h2>
<p>[powershell]<br />
[xml]$FruitList = Get-Content ./myfruitlist.xml<br />
[/powershell]</p>
<h2>Add data to XML object and save it in a XML file</h2>
<p>[powershell]<br />
# Copy Object from Banana<br />
[Object]$CopyFruit = FruitList.Box.Fruit | Where-Object {$_.Name -eq &#8220;Banana&#8221;}<br />
$NewFruit = $CopyFruit.Clone()<br />
# Add Fruit to new Object<br />
$NewFruit.Name = &#8220;Apple&#8221;<br />
$NewFruit.Color = &#8220;green&#8221;<br />
# Add Fruit to XML Object<br />
$FruitList.Box.AppendChild($NewFruit)<br />
#Save to XML object ot XML file<br />
$FruitList.Save(&#8220;./myfruitlist.xml&#8221;)<br />
[/powershell]<br />
XML:<br />
[XML]<br />
<Box><br />
	<Fruit><br />
		<Name>Banana</Name><br />
		<Color>yellow</Color><br />
	</Fruit><br />
	<Fruit><br />
		<Name>Apple</Name><br />
		<Color>green</Color><br />
	</Fruit><br />
</Box>[/XML]</p>
<h2>Change data from XML Object and save it as XML file</h2>
<p>[powershell]<br />
# Change Apple Color<br />
$FruitList.Box.Fruit | Where-Object {$_.Name -eq &#8220;Apple&#8221;} | ForEach-Object { $_.Color = &#8220;red&#8221; }<br />
#Save to XML object ot XML file<br />
$FruitList.Save(&#8220;./myfruitlist.xml&#8221;)<br />
[/powershell]<br />
XML:<br />
[XML]<br />
<Box><br />
	<Fruit><br />
		<Name>Banana</Name><br />
		<Color>yellow</Color><br />
	</Fruit><br />
	<Fruit><br />
		<Name>Apple</Name><br />
		<Color>red</Color><br />
	</Fruit><br />
</Box>[/XML]</p>
<h2>Remove data from XML Object and save it as XML file</h2>
<p>[powershell]<br />
# Remove Banana from Object<br />
$RemoveFruit = $FruitList.Box.Fruit | Where-Object {$_.Name -eq &#8220;Banana&#8221;}<br />
$FruitList.Box.RemoveChild($RemoveFruit)<br />
#Save to XML object ot XML file<br />
$FruitList.Save(&#8220;./myfruitlist.xml&#8221;)<br />
[/powershell]<br />
XML:<br />
[XML]<br />
<Box><br />
	<Fruit><br />
		<Name>Apple</Name><br />
		<Color>green</Color><br />
	</Fruit><br />
</Box>[/XML]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/07/powershell-working-with-xml-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Count your Code lines</title>
		<link>http://www.thomasmaurer.ch/2010/07/powershell-count-your-code-lines/</link>
		<comments>http://www.thomasmaurer.ch/2010/07/powershell-count-your-code-lines/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 09:26:36 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Count]]></category>
		<category><![CDATA[Count lines]]></category>
		<category><![CDATA[Get-ChildItem]]></category>
		<category><![CDATA[Microsoft Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[ps1]]></category>
		<category><![CDATA[Select-String]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Powershell]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=860</guid>
		<description><![CDATA[After Coding some lines in a lot of different files you wanna know how much lines you have coded. There are two (I am sure there are even more) ways to do that. The first one is to get the &#8230; <a href="http://www.thomasmaurer.ch/2010/07/powershell-count-your-code-lines/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" rel="lightbox[860]"><img class="aligncenter size-full wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" alt="Powershell Header" width="440" height="104" /></a></p>
<p>After Coding some lines in a lot of different files you wanna know how much lines you have coded. There are two (I am sure there are even more) ways to do that. The first one is to get the content of the files (<code>Get-Content</code>) and count the lines in there.</p>
<p>The other way and the fasterway is with <code>Select-String</code>:</p>
<p>[powershell](Get-ChildItem -Include *.ps1 -Recurse | Select-String -pattern .).Count[/powershell]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/07/powershell-count-your-code-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Simple retry logic</title>
		<link>http://www.thomasmaurer.ch/2010/07/powershell-simple-retry-logic/</link>
		<comments>http://www.thomasmaurer.ch/2010/07/powershell-simple-retry-logic/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 15:13:53 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[do while]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[Loop]]></category>
		<category><![CDATA[Microsoft Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Retry]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Powershell]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=834</guid>
		<description><![CDATA[I am working at some larger powershell scripts right now and so I needed to create a simple retry logic for sending web request to a server. [powershell] # Comment $Stoploop = $false [int]$Retrycount = &#34;0&#34; do { try { &#8230; <a href="http://www.thomasmaurer.ch/2010/07/powershell-simple-retry-logic/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" rel="lightbox[834]"><img class="aligncenter size-full wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" alt="Powershell Header" width="440" height="104" /></a></p>
<p>I am working at some larger powershell scripts right now and so I needed to create a simple retry logic for sending web request to a server.</p>
<p><a href="http://www.thomasmaurer.ch/wp-content/uploads/2010/07/Screen-shot-2010-07-23-at-17.08.09.png" rel="lightbox[834]"><img class="aligncenter size-medium wp-image-835" title="Powershell retry loop" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/07/Screen-shot-2010-07-23-at-17.08.09-300x166.png" alt="Powershell retry loop" width="300" height="166" /></a></p>
<p><span id="more-834"></span></p>
<pre>
[powershell]
# Comment
$Stoploop = $false
[int]$Retrycount = &quot;0&quot;

do {
	try {
		Scripts Commands here
		Write-Host &quot;Job completed&quot;
		$Stoploop = $true
		}
	catch {
		if ($Retrycount -gt 3){
			Write-Host &quot;Could not send Information after 3 retrys.&quot;
			$Stoploop = $true
		}
		else {
			Write-Host &quot;Could not send Information retrying in 30 seconds...&quot;
			Start-Sleep -Seconds 30
			$Retrycount = $Retrycount + 1
		}
	}
}
While ($Stoploop -eq $true)
[/powershell]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/07/powershell-simple-retry-logic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: if Statement basics</title>
		<link>http://www.thomasmaurer.ch/2010/07/powershell-if-statement-basics/</link>
		<comments>http://www.thomasmaurer.ch/2010/07/powershell-if-statement-basics/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 19:10:34 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[conditions]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[if statement]]></category>
		<category><![CDATA[operators]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[ps]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Powershell]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=827</guid>
		<description><![CDATA[The Iif Statement is a pretty important, if you are creating powershell scripts. So I created this post to get some basic information here. First the syntax with a simple if: if (condition) {do} You can also use elseif and &#8230; <a href="http://www.thomasmaurer.ch/2010/07/powershell-if-statement-basics/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-621" title="Powershell Header" src="http://www.thomasmaurer.ch/wp-content/uploads/2010/05/Screen-shot-2010-05-30-at-13.08.42.png" alt="Powershell Header" width="440" height="104" /></p>
<p>The Iif Statement is a pretty important, if you are creating powershell scripts. So I created this post to get some basic information here.</p>
<p><strong>First the syntax with a simple if:</strong></p>
<p><code>if (condition) {do}</code></p>
<p><strong>You can also use elseif and else:</strong></p>
<p><code>if (condition) {do}<br />
elseif (condition) {do}<br />
else {do}</code></p>
<p><strong>A simple if could look like this:</strong></p>
<pre>
[powershell]if ($varibale -eq "1") {
Write-Host "Yes variable is 1"
}
[/powershell]
</pre>
<p><strong>Comparison Operators:</strong></p>
<ul>
<li>Equal to: <code>-eq</code></li>
<li>Less than: <code>-lt</code></li>
<li>Greater than: <code>-gt</code></li>
<li>Greater than or Eqaul to: <code>-ge</code></li>
<li>Less than or equal to: <code>-le</code></li>
<li>Not equal to: <code>-ne</code></li>
</ul>
<p>You can also check case-sensitive by adding a &#8220;c&#8221; to the operator. &#8220;<code>-eq</code>&#8221; would be &#8220;<code>-ceq</code>&#8221;</p>
<p><strong>Logical Operators:</strong></p>
<ul>
<li>Not <code>-not</code></li>
<li>Not <code>!</code></li>
<li>And <code>-and</code></li>
<li>Or <code>-or</code></li>
</ul>
<p><strong>So you can simply add multiple conditions:</strong></p>
<pre>[powershell]if ($varibale -eq "1" -or $varibale -eq "2") {
Write-Host "Varibale is 1 or 2"
}[/powershell]</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/07/powershell-if-statement-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solved: Cannot download File from IIS6 FTP</title>
		<link>http://www.thomasmaurer.ch/2010/07/solved-cannot-download-file-from-iis6-ftp/</link>
		<comments>http://www.thomasmaurer.ch/2010/07/solved-cannot-download-file-from-iis6-ftp/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 11:15:06 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows Server 2003]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Cannot download File from IIS6 FTP]]></category>
		<category><![CDATA[filename]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[IIS 6]]></category>
		<category><![CDATA[IIS 6.0]]></category>
		<category><![CDATA[renaming]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=824</guid>
		<description><![CDATA[Today we a ticket which was escalated by the second level support to the engineering. A customer could not download, remove or rename the file via FTP. The Hosting is running on a Windows Server 2003 R2 with IIS6. After &#8230; <a href="http://www.thomasmaurer.ch/2010/07/solved-cannot-download-file-from-iis6-ftp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today we a ticket which was escalated by the second level support to the engineering. A customer could not download, remove or rename the file via FTP. The Hosting is running on a Windows Server 2003 R2 with IIS6. After checking the file on the filesystem I saw that the filename had a space in before.</p>
<p><strong>Normalfilename:</strong></p>
<p>&#8220;filename.html&#8221;</p>
<p><strong>Wrongfilename:</strong></p>
<p>&#8221; filename.html&#8221;</p>
<p>You cannot really name a file like that with a windows machine. But Linux and Unix systems like Mac OS X allow this.</p>
<p>After renaming the file to a normal Windows filename, the customer you download the file again.</p>
<p>Btw you can simple rename the file with powershell</p>
<p><code>Rename-Item " filename.html" "newfilename.html"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/07/solved-cannot-download-file-from-iis6-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Install Roles and Features Windows Server 2008 R2 Core (Shell)</title>
		<link>http://www.thomasmaurer.ch/2010/07/howto-install-roles-and-features-windows-server-2008-r2-core-shell/</link>
		<comments>http://www.thomasmaurer.ch/2010/07/howto-install-roles-and-features-windows-server-2008-r2-core-shell/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 11:00:08 +0000</pubDate>
		<dc:creator>Thomas Maurer</dc:creator>
				<category><![CDATA[Hyper-v]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Server Core]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows Server 2008 R2]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[DISM]]></category>
		<category><![CDATA[dism.exe]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[roles]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Core Server]]></category>
		<category><![CDATA[windows server 2008]]></category>
		<category><![CDATA[Windows Server 2008 Core]]></category>
		<category><![CDATA[Windows Server 2008 R2 Core]]></category>
		<category><![CDATA[Windows Server Core]]></category>

		<guid isPermaLink="false">http://www.thomasmaurer.ch/?p=803</guid>
		<description><![CDATA[This Guide should help you to install Roles and Features on Windows Server 2008 R2 per shell or on a Windows Server 2008 R2 Core Server. Under Windows Server 2008 you could install Roles and Features with the command OCSETUP. Since &#8230; <a href="http://www.thomasmaurer.ch/2010/07/howto-install-roles-and-features-windows-server-2008-r2-core-shell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This Guide should help you to install Roles and Features on Windows Server 2008 R2 per shell or on a Windows Server 2008 R2 Core Server.</p>
<p>Under Windows Server 2008 you could install Roles and Features with the command OCSETUP. Since we use Windows Server 2008 R2 Microsoft used the tool called DISM (Deployment Image Servicing and Management tool).</p>
<p>For checking availible Server roles type:</p>
<p><code>Dism /online /get-features /format:table</code></p>
<p>To enable a Feature or a Role, in this case the DNS Server Role, you just type:</p>
<p><code>Dism /online /enable-feature /featurename:DNS-Server-Core-Role</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomasmaurer.ch/2010/07/howto-install-roles-and-features-windows-server-2008-r2-core-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
