<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>PowerShell Ponderings &#187; PowerShell &#8211; Scripts</title>
	<atom:link href="http://andrwwatt.wordpress.com/category/powershell-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrwwatt.wordpress.com</link>
	<description>Pondering the power of PowerShell</description>
	<lastBuildDate>Fri, 19 May 2006 09:06:24 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='andrwwatt.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/7a3577429727eb864e230a6da306b64a?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>PowerShell Ponderings &#187; PowerShell &#8211; Scripts</title>
		<link>http://andrwwatt.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://andrwwatt.wordpress.com/osd.xml" title="PowerShell Ponderings" />
		<item>
		<title>Limitations of the rename-item cmdlet</title>
		<link>http://andrwwatt.wordpress.com/2006/05/13/limitations-of-the-rename-item-cmdlet/</link>
		<comments>http://andrwwatt.wordpress.com/2006/05/13/limitations-of-the-rename-item-cmdlet/#comments</comments>
		<pubDate>Sat, 13 May 2006 12:47:12 +0000</pubDate>
		<dc:creator>andrwwatt</dc:creator>
				<category><![CDATA[PowerShell - Scripts]]></category>
		<category><![CDATA[Powershell - Cmdlets]]></category>

		<guid isPermaLink="false">https://andrwwatt.wordpress.com/2006/05/13/limitations-of-the-rename-item-cmdlet/</guid>
		<description><![CDATA[If you&#39;ve been using Monad betas before the release of PowerShell RC1 you quite possibly have a significant number of scripts that you wrote using the Monad betas. Those files will have a .msh file extension. When you upgrade to PowerShell, apart from any changes you need to make to the content, you need to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrwwatt.wordpress.com&blog=221566&post=7&subd=andrwwatt&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you&#39;ve been using Monad betas before the release of PowerShell RC1 you quite possibly have a significant number of scripts that you wrote using the Monad betas. Those files will have a <b>.msh</b> file extension. When you upgrade to PowerShell, apart from any changes you need to make to the content, you need to change the file extension to <b>.ps1</b>.</p>
<p>In the good old Windows command shell, doing that is straightforward. Simply navigate to the folder holding the scripts. Then use the following command:</p>
<p><b>ren *.msh *.ps1</b></p>
<p>If you try that with Monad you receive the following error:</p>
<p><b>PS C:\PowerShellScripts&gt; ren *.msh *.ps1<br />
Rename-Item : Cannot process argument because the value of argument &quot;path&quot; is invalid. At line:1 char:4<br />
+ ren  &lt;&lt;&lt;&lt; *.msh *.ps1</b></p>
<p>So, what&#39;s wrong with the path? To figure that out I will show the command in a full form:</p>
<p><b>ren -Path *.msh -NewName *.ps1</b></p>
<p>The error relates to the value of the <b>Path</b> parameter. It accepts wildcards in the path but it must resolve to a single file.</p>
<p>So how do you use PowerShell to rename multiple files?</p>
<p>PowerShell is designed to use pipelines. And you need a two step pipeline to get the job done. Assuming you are in the directory that contains the files that you want to rename, use the following command:</p>
<p><b>get-childitem -Path *.msh | </b></p>
<p><b>rename-item -NewName {$_.name -replace &quot;.msh&quot;,&quot;.ps1&quot;} -whatif</b></p>
<p>As you can see it&#39;s a pipeline with two steps. The first step uses the <b>get-childitem</b> cmdlet to retrieve information about all files in the current folder with a <b>.msh</b> file extension. The second step uses the <b>rename-item</b> cmdlet to process each object passed on from the first step. Each object is a <b>FileInfo</b> object. The value of the Extension property of each <b>FileInfo</b> object is <b>.msh</b>, as you can see by using the following command:</p>
<p><b>get-childitem *.msh |</b></p>
<p><b>format-table Name, Extension</b></p>
<p>The value of the <b>NewName</b> parameter is <b>{$_.name -replace &quot;.msh&quot;,&quot;.ps1&quot;}</b>. Any occurrence of <b>.msh</b> in the value of the <b>Name</b> property of the current object is replaced by <b>.ps1</b>.</p>
<p>To put it more succinctly, all files with a file extension of <b>.msh</b> are renamed to have a file extension of <b>.ps1</b>.</p>
<p>In Windows Explorer you can rename the current folder. The <b>rename-item</b> cmdlet doesn&#39;t allow you to rename any folder.</p>
<p>The example I showed used the <b>FileSystem</b> provider. You can use the <b>rename-item</b> cmdlet to rename items in other providers, for example the <b>alias</b> and <b>variable</b> providers. To display available providers use this command:</p>
<p><b>get-PSDrive</b></p>
<p>The <b>get-PSDrive</b> cmdlet has replaced the <b>get-drive</b> cmdlet which was found in public builds before RC1.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andrwwatt.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andrwwatt.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrwwatt.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrwwatt.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andrwwatt.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andrwwatt.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andrwwatt.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andrwwatt.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andrwwatt.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andrwwatt.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andrwwatt.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andrwwatt.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrwwatt.wordpress.com&blog=221566&post=7&subd=andrwwatt&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andrwwatt.wordpress.com/2006/05/13/limitations-of-the-rename-item-cmdlet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bbd01d97e4b6b8a5c05a55b10c599ce2?s=96&#38;d=identicon" medium="image">
			<media:title type="html">andrwwatt</media:title>
		</media:content>
	</item>
		<item>
		<title>Filtering WMI Object Properties using PowerShell</title>
		<link>http://andrwwatt.wordpress.com/2006/05/12/filtering-wmi-object-properties-using-powershell/</link>
		<comments>http://andrwwatt.wordpress.com/2006/05/12/filtering-wmi-object-properties-using-powershell/#comments</comments>
		<pubDate>Fri, 12 May 2006 12:31:05 +0000</pubDate>
		<dc:creator>andrwwatt</dc:creator>
				<category><![CDATA[PowerShell - Scripts]]></category>

		<guid isPermaLink="false">https://andrwwatt.wordpress.com/2006/05/12/filtering-wmi-object-properties-using-powershell/</guid>
		<description><![CDATA[When you use the get-wmiobject cmdlet to retrieve properties of a Windows Management Instrumentation, WMI, class you can be overwhelmed by the number of properties displayed. Among the properties displayed when you use an asterisk wildcard with the format-list cmdlet,
get-wmiobject -Class Win32_BIOS &#124;
format-list *
are the WMI system properties which you probably don&#39;t want to see. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrwwatt.wordpress.com&blog=221566&post=5&subd=andrwwatt&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When you use the get-wmiobject cmdlet to retrieve properties of a Windows Management Instrumentation, WMI, class you can be overwhelmed by the number of properties displayed. Among the properties displayed when you use an asterisk wildcard with the <b>format-list</b> cmdlet,</p>
<p><b>get-wmiobject -Class Win32_BIOS |</b></p>
<p><b>format-list *</b></p>
<p>are the WMI system properties which you probably don&#39;t want to see. You can use a more specific wildcard with the <b>format-list </b>cmdlet to filter the properties displayed.</p>
<p>If you want to display properties about the BIOS of your machine you might use the command but exclude the WMI system properties use this command:</p>
<p><b> get-wmiobject -Class Win32_BIOS |</b></p>
<p><b>format-list [a-z]*</b></p>
<p>How does this work? The first step of the pipeline uses the <b>Win32_BIOS</b> WMI class to pass its properties to the second step of the pipeline. The <b>format-list</b> cmdlet formats the output as a list, but which properties are to be displayed?</p>
<p>The <b>[a-z]*</b> is an extended wildcard. It&#39;s partly a traditional wildcard and partly like a regular expression. The <b>[a-z]</b> is a character class. It matches any lower case alphabetic character between a and z. The <b>*</b> matches zero or more characters. Taken together the wildcard means &quot;Match any sequence of characters that begins with an alphabetic character&quot;.</p>
<p>You can use more focussed wilcards. To retrieve the properties beginning with s use this command:</p>
<p><b> get-wmiobject -Class Win32_BIOS |</b></p>
<p><b>format-list s*</b></p>
<p>The pattern <b>s*</b> matches any sequence of characters where the first character is s.<br />
<a href="http://technorati.com/claim/tat7fcstm5" rel="me" target="_blank">Technorati Profile</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/andrwwatt.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/andrwwatt.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andrwwatt.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andrwwatt.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andrwwatt.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andrwwatt.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andrwwatt.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andrwwatt.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andrwwatt.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andrwwatt.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andrwwatt.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andrwwatt.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrwwatt.wordpress.com&blog=221566&post=5&subd=andrwwatt&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://andrwwatt.wordpress.com/2006/05/12/filtering-wmi-object-properties-using-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bbd01d97e4b6b8a5c05a55b10c599ce2?s=96&#38;d=identicon" medium="image">
			<media:title type="html">andrwwatt</media:title>
		</media:content>
	</item>
	</channel>
</rss>