<?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>PowerShell for Windows Admins &#187; Registry</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/powershell/tag/registry/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/powershell</link>
	<description>PowerShell and WMI: The fast and furious of windows administration.</description>
	<lastBuildDate>Wed, 12 Jun 2013 21:31:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Registry oddity</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/registry-oddity/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/registry-oddity/#comments</comments>
		<pubDate>Fri, 14 Dec 2012 14:26:20 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/?p=756</guid>
		<description><![CDATA[Looking at modifying the registry on a virtual machine while its offline. I mount the VHDX file and can run this&#160; to load the registry PS&#62; reg load HKLM\VHDSYS h:\windows\system32\config\system The operation completed successfully. If I perform a reg unload at this point everything works but if I access the registry – for instance PS&#62; [...]]]></description>
				<content:encoded><![CDATA[<p>Looking at modifying the registry on a virtual machine while its offline. I mount the VHDX file and can run this&#160; to load the registry</p>
<p>PS&gt; reg load HKLM\VHDSYS h:\windows\system32\config\system   <br />The operation completed successfully.</p>
<p>If I perform a reg unload at this point everything works but if I access the registry – for instance</p>
<p>PS&gt; ls hklm:</p>
<p>and then try and unload I get an error!</p>
<p>PS&gt; reg unload HKLM\VHDSYS   <br />ERROR: Access is denied.</p>
<p>One thing I found is that there is as reference to the remote hive in the variable collection</p>
<p>PS&gt; ls variable:</p>
<p>Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Value   <br />&#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211;    <br />$&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; HKLM\VHDSYS</p>
<p>Empirically I’ve found that running these commands</p>
<p>ls env:   <br />ls variable:</p>
<p>changes the value of the $ variable</p>
<p>You can then unload the hive</p>
<p>PS&gt; reg unload HKLM\VHDSYS   <br />The operation completed successfully.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/registry-oddity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading mounted device information from the registry</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/reading-mounted-device-information-from-the-registry/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/reading-mounted-device-information-from-the-registry/#comments</comments>
		<pubDate>Sun, 16 Sep 2012 13:41:07 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/?p=655</guid>
		<description><![CDATA[Interesting question about reading the registry.&#160; How do you read HKLM:\SYSTEM\MountedDevices and pull out the name of the device and the associated data. Get-Item -Path HKLM:\SYSTEM\MountedDevices returns data of this form Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Property &#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8211; MountedDevices&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\C: : {218, 187, 32, 142&#8230;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\G: : {92, 0, 63, 0&#8230;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\E: : {95, 0, 63, [...]]]></description>
				<content:encoded><![CDATA[<p>Interesting question about reading the registry.&#160; How do you read HKLM:\SYSTEM\MountedDevices and pull out the name of the device and the associated data.</p>
<p>Get-Item -Path HKLM:\SYSTEM\MountedDevices</p>
<p>returns data of this form</p>
<p><font face="Courier New">Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Property      <br />&#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8211;       <br />MountedDevices&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\C: : {218, 187, 32, 142&#8230;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\G: : {92, 0, 63, 0&#8230;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\E: : {95, 0, 63, 0&#8230;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\F: : {92, 0, 63, 0&#8230;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\D: : {218, 187, 32, 142&#8230;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; \DosDevices\I: : {95, 0, 63, 0&#8230;}</font></p>
<p>We need to drill into the property but if we expand the property we will only get the name of the device. So we need to loop through those names</p>
<pre><span style="color: #ff4500">$data</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">@(</span><span style="color: #000000">)</span>            
<span style="color: #0000ff">Get-Item</span> <span style="color: #000080">-Path</span> <span style="color: #8a2be2">HKLM:\SYSTEM\MountedDevices</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">Property</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">where</span> <span style="color: #000000">{</span><span style="color: #ff4500">$_</span> <span style="color: #a9a9a9">-like</span> <span style="color: #8b0000">&quot;\Dos*&quot;</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>             
<span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
 <span style="color: #ff4500">$name</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span>            
<span style="color: #ff4500">$data</span> <span style="color: #a9a9a9">+=</span> <span style="color: #0000ff">New-Object</span> <span style="color: #000080">-TypeName</span> <span style="color: #8a2be2">psobject</span> <span style="color: #000080">-Property</span> <span style="color: #000000">@{</span>            
  <span style="color: #000000">Device</span> <span style="color: #a9a9a9">=</span>  <span style="color: #ff4500">$name</span>             
  <span style="color: #000000">Value</span>  <span style="color: #a9a9a9">=</span> <span style="color: #000000">(</span><span style="color: #0000ff">Get-ItemProperty</span> <span style="color: #000080">-Path</span> <span style="color: #8a2be2">HKLM:\SYSTEM\MountedDevices</span> <span style="color: #000080">-Name</span> <span style="color: #ff4500">$name</span><span style="color: #000000">)</span><span style="color: #a9a9a9">.</span><span style="color: #8b0000">&quot;$name&quot;</span>            
 <span style="color: #000000">}</span>            
            
<span style="color: #000000">}</span>            
<span style="color: #ff4500">$data</span></pre>
<p>To simplify the output is limited to Dos devices</p>
<p>Get-itemproperty returns the data with the name of the device as the property name so we need to drill in to get the value</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/reading-mounted-device-information-from-the-registry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell in Practice offer today only</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/powershell-in-practice-offer-today-only/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/powershell-in-practice-offer-today-only/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 14:49:28 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Processor]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/powershell-in-practice-offer-today-only/</guid>
		<description><![CDATA[Manning have PowerShell in Practice on a half price offer today. Go to www.manning.com and use code dotd0330cc when ordering]]></description>
				<content:encoded><![CDATA[<p>Manning have PowerShell in Practice on a half price offer today. Go to <a href="http://www.manning.com">www.manning.com</a> and use code <strong>dotd0330cc</strong> when ordering</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/powershell-in-practice-offer-today-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading registry values with CIM</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/reading-registry-values-with-cim/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/reading-registry-values-with-cim/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 22:33:41 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell 3]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/reading-registry-values-with-cim/</guid>
		<description><![CDATA[In this post http://msmvps.com/blogs/richardsiddaway/archive/2012/03/10/migrating-to-cim-doh.aspx and its predecessors we saw how to enumerate registry sub-keys. But how do we read a registry value? function get-CIMRegValue{ [CmdletBinding(DefaultParameterSetName=&#34;UseComputer&#34;)] param ( [parameter(Mandatory=$true)] [ValidateSet(&#34;HKCR&#34;, &#34;HKCU&#34;, &#34;HKLM&#34;, &#34;HKUS&#34;, &#34;HKCC&#34;)] [string]$hive, [parameter(Mandatory=$true)] [string]$key, [parameter(Mandatory=$true)] [string]$value, [parameter(Mandatory=$true)] [string] [Validateset(&#34;DWORD&#34;, &#34;EXPANDSZ&#34;, &#34;MULTISZ&#34;, &#34;QWORD&#34;, &#34;SZ&#34;)] $type, [parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [parameter(ParameterSetName=&#34;UseComputer&#34;)] [string]$computer=&#34;$env:COMPUTERNAME&#34;, [parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [parameter(ParameterSetName=&#34;UseCIMSession&#34;)] [Microsoft.Management.Infrastructure.CimSession]$cimsession ) [...]]]></description>
				<content:encoded><![CDATA[<p>In this post</p>
<p><a title="http://msmvps.com/blogs/richardsiddaway/archive/2012/03/10/migrating-to-cim-doh.aspx" href="http://msmvps.com/blogs/richardsiddaway/archive/2012/03/10/migrating-to-cim-doh.aspx">http://msmvps.com/blogs/richardsiddaway/archive/2012/03/10/migrating-to-cim-doh.aspx</a></p>
<p>and its predecessors we saw how to enumerate registry sub-keys. But how do we read a registry value?</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-CIMRegValue</span><span style="color: #000000">{</span>             
<span style="color: #a9a9a9">[</span><span style="color: #add8e6">CmdletBinding</span><span style="color: #000000">(</span><span style="color: #000000">DefaultParameterSetName</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;UseComputer&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>             
            
<span style="color: #00008b">param</span> <span style="color: #000000">(</span>             
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">ValidateSet</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;HKCR&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;HKCU&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;HKLM&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;HKUS&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;HKCC&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$hive</span><span style="color: #a9a9a9">,</span>            
            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$key</span><span style="color: #a9a9a9">,</span>            
            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$value</span><span style="color: #a9a9a9">,</span>            
            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #008080">[string]</span>            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">Validateset</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;DWORD&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;EXPANDSZ&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;MULTISZ&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;QWORD&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;SZ&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #ff4500">$type</span><span style="color: #a9a9a9">,</span>            
            
  <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">ValueFromPipeline</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #a9a9a9">,</span>            
   <span style="color: #000000">ValueFromPipelineByPropertyName</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">ParameterSetName</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;UseComputer&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>             
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$computer</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;$env:COMPUTERNAME&quot;</span><span style="color: #a9a9a9">,</span>            
             
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">ValueFromPipeline</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #a9a9a9">,</span>            
   <span style="color: #000000">ValueFromPipelineByPropertyName</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">ParameterSetName</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;UseCIMSession&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>             
 <span style="color: #008080">[Microsoft.Management.Infrastructure.CimSession]</span><span style="color: #ff4500">$cimsession</span>            
             
<span style="color: #000000">)</span>             
<span style="color: #00008b">BEGIN</span><span style="color: #000000">{</span><span style="color: #000000">}</span><span style="color: #006400">#begin </span>            
<span style="color: #00008b">PROCESS</span><span style="color: #000000">{</span>            
            
<span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$hive</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
<span style="color: #8b0000">&quot;HKCR&quot;</span> <span style="color: #000000">{</span> <span style="color: #008080">[uint32]</span><span style="color: #ff4500">$hdkey</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483648</span><span style="color: #000000">}</span> <span style="color: #006400">#HKEY_CLASSES_ROOT</span>            
<span style="color: #8b0000">&quot;HKCU&quot;</span> <span style="color: #000000">{</span> <span style="color: #008080">[uint32]</span><span style="color: #ff4500">$hdkey</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483649</span><span style="color: #000000">}</span> <span style="color: #006400">#HKEY_CURRENT_USER</span>            
<span style="color: #8b0000">&quot;HKLM&quot;</span> <span style="color: #000000">{</span> <span style="color: #008080">[uint32]</span><span style="color: #ff4500">$hdkey</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483650</span><span style="color: #000000">}</span> <span style="color: #006400">#HKEY_LOCAL_MACHINE</span>            
<span style="color: #8b0000">&quot;HKUS&quot;</span> <span style="color: #000000">{</span> <span style="color: #008080">[uint32]</span><span style="color: #ff4500">$hdkey</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483651</span><span style="color: #000000">}</span> <span style="color: #006400">#HKEY_USERS</span>            
<span style="color: #8b0000">&quot;HKCC&quot;</span> <span style="color: #000000">{</span> <span style="color: #008080">[uint32]</span><span style="color: #ff4500">$hdkey</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483653</span><span style="color: #000000">}</span> <span style="color: #006400">#HKEY_CURRENT_CONFIG</span>            
<span style="color: #000000">}</span>            
            
<span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$type</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>            
<span style="color: #8b0000">&quot;DWORD&quot;</span>     <span style="color: #000000">{</span><span style="color: #ff4500">$methodname</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;GetDwordValue&quot;</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;EXPANDSZ&quot;</span>  <span style="color: #000000">{</span><span style="color: #ff4500">$methodname</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;GetExpandedStringValue&quot;</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;MULTISZ&quot;</span>   <span style="color: #000000">{</span><span style="color: #ff4500">$methodname</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;GetMultiStringValue&quot;</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;QWORD&quot;</span>     <span style="color: #000000">{</span><span style="color: #ff4500">$methodname</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;GetQwordValue&quot;</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;SZ&quot;</span>        <span style="color: #000000">{</span><span style="color: #ff4500">$methodname</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;GetStringValue&quot;</span><span style="color: #000000">}</span>            
<span style="color: #000000">}</span>            
<span style="color: #ff4500">$arglist</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">@{</span><span style="color: #000000">hDefKey</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$hdkey</span><span style="color: #000000">;</span> <span style="color: #000000">sSubKeyName</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$key</span><span style="color: #000000">;</span> <span style="color: #000000">sValueName</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$value</span><span style="color: #000000">}</span>            
            
<span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$psCmdlet</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ParameterSetName</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>            
 <span style="color: #8b0000">&quot;UseComputer&quot;</span>    <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Invoke-CimMethod</span> <span style="color: #000080">-Namespace</span> <span style="color: #8b0000">&quot;root\cimv2&quot;</span> <span style="color: #000080">-ClassName</span> <span style="color: #8a2be2">StdRegProv</span> <span style="color: #000080">-MethodName</span> <span style="color: #ff4500">$methodname</span>  <span style="color: #000080">-Arguments</span> <span style="color: #ff4500">$arglist</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span><span style="color: #000000">}</span>            
 <span style="color: #8b0000">&quot;UseCIMSession&quot;</span>  <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Invoke-CimMethod</span> <span style="color: #000080">-Namespace</span> <span style="color: #8b0000">&quot;root\cimv2&quot;</span> <span style="color: #000080">-ClassName</span> <span style="color: #8a2be2">StdRegProv</span> <span style="color: #000080">-MethodName</span> <span style="color: #ff4500">$methodname</span>  <span style="color: #000080">-Arguments</span> <span style="color: #ff4500">$arglist</span> <span style="color: #000080">-CimSession</span> <span style="color: #ff4500">$cimsession</span> <span style="color: #000000">}</span>            
 <span style="color: #8a2be2">default</span> <span style="color: #000000">{</span><span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Error!!! Should not be here&quot;</span> <span style="color: #000000">}</span>            
<span style="color: #000000">}</span>            
            
<span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$type</span><span style="color: #000000">)</span> <span style="color: #000000">{</span>            
<span style="color: #8b0000">&quot;DWORD&quot;</span>     <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">uValue</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;EXPANDSZ&quot;</span>  <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">sValue</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;MULTISZ&quot;</span>   <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">sValue</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;QWORD&quot;</span>     <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">uValue</span><span style="color: #000000">}</span>            
<span style="color: #8b0000">&quot;SZ&quot;</span>        <span style="color: #000000">{</span><span style="color: #ff4500">$result</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">sValue</span><span style="color: #000000">}</span>            
<span style="color: #000000">}</span>            
             
<span style="color: #000000">}</span><span style="color: #006400">#process </span>            
<span style="color: #00008b">END</span><span style="color: #000000">{</span><span style="color: #000000">}</span><span style="color: #006400">#end</span>            
            
<span style="color: #006400">&lt;# 
.SYNOPSIS
Displays a registry value

.DESCRIPTION
Displays a registry value using WSMAN or DCOM 
to access remote machines 

.PARAMETER  hive
Hive Name. One of &quot;HKCR&quot;, &quot;HKCU&quot;, &quot;HKLM&quot;, &quot;HKUS&quot; or &quot;HKCC&quot;
The name is validated against the set

.PARAMETER  key
The registry key - without the hive name e.g.
&quot;SYSTEM\CurrentControlSet\Services\BITS&quot;

.PARAMETER value
The specific registry value to return for the 
given key

.PARAMETER  type
The type of registry value to return.
Must be one of
&quot;DWORD&quot;, &quot;EXPANDSZ&quot;, &quot;MULTISZ&quot;, &quot;QWORD&quot;, &quot;SZ&quot;

.PARAMETER  computer
Name of a remote computer. Connectivity will be by WSMAN.

.PARAMETER  cimsession
An object representing a cimsession. Connectivity is controlled 
by the CIM session and can be WSMAN or DCOM

.EXAMPLE                                                                                       
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value DelayedAutoStart -type DWORD

.EXAMPLE
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value ObjectName -type SZ  

.EXAMPLE
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value DependOnService -type MULTISZ 

.EXAMPLE
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value ImagePath -type EXPANDSZ

.EXAMPLE
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value DelayedAutoStart -type DWORD -computer &quot;.&quot;

.EXAMPLE
$cs = New-CimSession -ComputerName Win7test  
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value DelayedAutoStart -type DWORD -cimsession $cs   

.EXAMPLE
$opt = New-CimSessionOption -Protocol Dcom                                                                                                          
$csd = New-CimSession -ComputerName server02 -SessionOption $opt                                                                                    
get-CIMRegValue -hive HKLM -key &quot;SYSTEM\CurrentControlSet\services\BITS&quot; -value DelayedAutoStart -type DWORD -cimsession $csd

.NOTES


.LINK

#&gt;</span>            
            
<span style="color: #000000">}</span></pre>
<p>Parameters define the hive, key, value to be read and the type of value.</p>
<p>Registry values come in a number of types:</p>
<ul>
<li>DWORD and QWORD are 32 &amp; 64 bit numbers </li>
<li>SZ is a string </li>
<li>EXPANDSZ is a string containing environmental variables that gets expanded </li>
<li>MULTISZ is a multi-valued string </li>
</ul>
<p>Parameters to define a computer name or CIM Session are also present</p>
<p>The numeric value for the hive is set in a switch statement. The data type is used to define the method name – each data type has its own method.</p>
<p>The argument list is populated and the method is invoked using a computer name or CIM session as appropriate</p>
<p>The results are decoded according to type.</p>
<p>Full help is provided on the function.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/reading-registry-values-with-cim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set registry key owner</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/set-registry-key-owner/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/set-registry-key-owner/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 20:48:19 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/set-registry-key-owner/</guid>
		<description><![CDATA[In chapter 7 of PowerShell and WMI I stated that I would post a .NET version of a script to set ownership of a registry key. The WMI method needs Vista or above so we need the .NET version for pre-Vista operating systems. function set-regkeyowner { [CmdletBinding()] param ( [parameter(Mandatory=$true)] [string] [Validateset(“HKCR”, “HKCU”, “HKLM”, &#34;HKUS&#34;, [...]]]></description>
				<content:encoded><![CDATA[<p>In chapter 7 of PowerShell and WMI I stated that I would post a .NET version of a script to set ownership of a registry key. The WMI method needs Vista or above so we need the .NET version for pre-Vista operating systems.</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">set-regkeyowner</span> <span style="color: #000000">{</span>            
<span style="color: #a9a9a9">[</span><span style="color: #add8e6">CmdletBinding</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
<span style="color: #00008b">param</span> <span style="color: #000000">(</span>            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #008080">[string]</span>            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">Validateset</span><span style="color: #000000">(</span><span style="color: #8b0000">“HKCR”</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">“HKCU”</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">“HKLM”</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;HKUS&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;HKCC&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
  <span style="color: #ff4500">$hive</span><span style="color: #a9a9a9">,</span>            
            
 <span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$key</span>            
<span style="color: #000000">)</span>              
<span style="color: #00008b">PROCESS</span> <span style="color: #000000">{</span>             
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Set Hive&quot;</span>            
<span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$hive</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
 <span style="color: #8b0000">“HKCR”</span> <span style="color: #000000">{</span><span style="color: #ff4500">$reg</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[Microsoft.Win32.Registry]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">ClassesRoot</span><span style="color: #000000">}</span>            
 <span style="color: #8b0000">“HKCU”</span> <span style="color: #000000">{</span><span style="color: #ff4500">$reg</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[Microsoft.Win32.Registry]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">CurrentUser</span><span style="color: #000000">}</span>            
 <span style="color: #8b0000">“HKLM”</span> <span style="color: #000000">{</span><span style="color: #ff4500">$reg</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[Microsoft.Win32.Registry]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">LocalMachine</span><span style="color: #000000">}</span>            
 <span style="color: #8b0000">&quot;HKUS&quot;</span> <span style="color: #000000">{</span><span style="color: #ff4500">$reg</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[Microsoft.Win32.Registry]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">Users</span><span style="color: #000000">}</span>            
 <span style="color: #8b0000">&quot;HKCC&quot;</span> <span style="color: #000000">{</span><span style="color: #ff4500">$reg</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[Microsoft.Win32.Registry]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">CurrentConfig</span><span style="color: #000000">}</span>            
<span style="color: #000000">}</span>            
            
<span style="color: #ff4500">$permchk</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[Microsoft.Win32.RegistryKeyPermissionCheck]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">ReadWriteSubTree</span>            
<span style="color: #ff4500">$regrights</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[System.Security.AccessControl.RegistryRights]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">ChangePermissions</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Open Key and get access control&quot;</span>            
<span style="color: #ff4500">$regkey</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$reg</span><span style="color: #a9a9a9">.</span><span style="color: #000000">OpenSubKey</span><span style="color: #000000">(</span><span style="color: #ff4500">$key</span><span style="color: #a9a9a9">,</span> <span style="color: #ff4500">$permchk</span><span style="color: #a9a9a9">,</span> <span style="color: #ff4500">$regrights</span><span style="color: #000000">)</span>            
<span style="color: #ff4500">$rs</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$regkey</span><span style="color: #a9a9a9">.</span><span style="color: #000000">GetAccessControl</span><span style="color: #000000">(</span><span style="color: #000000">)</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Create security principal&quot;</span>            
<span style="color: #ff4500">$user</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">New-Object</span> <span style="color: #000080">-TypeName</span> <span style="color: #8a2be2">Security.Principal.NTaccount</span> <span style="color: #000080">-ArgumentList</span> <span style="color: #8b0000">&quot;Administrators&quot;</span>            
            
<span style="color: #ff4500">$rs</span><span style="color: #a9a9a9">.</span><span style="color: #000000">SetGroup</span><span style="color: #000000">(</span><span style="color: #ff4500">$user</span><span style="color: #000000">)</span>             
<span style="color: #ff4500">$rs</span><span style="color: #a9a9a9">.</span><span style="color: #000000">SetOwner</span><span style="color: #000000">(</span><span style="color: #ff4500">$user</span><span style="color: #000000">)</span>             
<span style="color: #ff4500">$regkey</span><span style="color: #a9a9a9">.</span><span style="color: #000000">SetAccessControl</span><span style="color: #000000">(</span><span style="color: #ff4500">$rs</span><span style="color: #000000">)</span>            
<span style="color: #000000">}</span>            
<span style="color: #000000">}</span></pre>
<p>Take a hive and key as parameters. Use a switch to set the Registry enumeration and then set the permissions and rights we want. Open the key and get the access controls.</p>
<p>Create a security principal for the Administrators group and set the group and owner in the access control. Use SetAccessControl to change the permissions</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/set-registry-key-owner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPv6 Link local addresses and device identifier</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/ipv6-link-local-addresses-and-device-identifier/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/ipv6-link-local-addresses-and-device-identifier/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 19:50:21 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/ipv6-link-local-addresses-and-device-identifier/</guid>
		<description><![CDATA[If I run ipconfig on my system the partial results are this Wireless LAN adapter Wireless Network Connection: &#160;&#160; Connection-specific DNS Suffix&#160; . : tiscali.co.uk &#160;&#160; Link-local IPv6 Address . . . . . : fe80::6d95:b824:6a72:a0a9%11 &#160;&#160; IPv4 Address. . . . . . . . . . . : 192.168.1.2 &#160;&#160; Subnet Mask . [...]]]></description>
				<content:encoded><![CDATA[<p>If I run ipconfig on my system the partial results are this</p>
<p><font face="Courier New">Wireless LAN adapter Wireless Network Connection:</font></p>
<p><font face="Courier New">&#160;&#160; Connection-specific DNS Suffix&#160; . : tiscali.co.uk      <br />&#160;&#160; Link-local IPv6 Address . . . . . : fe80::6d95:b824:6a72:a0a9%11       <br />&#160;&#160; IPv4 Address. . . . . . . . . . . : 192.168.1.2       <br />&#160;&#160; Subnet Mask . . . . . . . . . . . : 255.255.255.0       <br />&#160;&#160; Default Gateway . . . . . . . . . : 192.168.1.1</font></p>
<p><font face="Courier New">Ethernet adapter Local Area Connection:</font></p>
<p><font face="Courier New">&#160;&#160; Connection-specific DNS Suffix&#160; . :      <br />&#160;&#160; Link-local IPv6 Address . . . . . : fe80::4547:ee51:7aac:521e%10       <br />&#160;&#160; IPv4 Address. . . . . . . . . . . : 10.10.54.202       <br />&#160;&#160; Subnet Mask . . . . . . . . . . . : 255.255.255.0       <br />&#160;&#160; Default Gateway . . . . . . . . . :</font></p>
<p>&#160;</p>
<p>Notice that the IPv6 addresses have a % sign followed by a number.&#160; This is the device id of the network adapter</p>
<p>If we modify our get-IPAddress function to output the adapter’s deviceid (Index on Win32_NetworkAdapterConfiguration class) </p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-IPAddress</span> <span style="color: #000000">{</span>            
<span style="color: #a9a9a9">[</span><span style="color: #add8e6">CmdletBinding</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #00008b">param</span> <span style="color: #000000">(</span>            
  <span style="color: #008080">[string]</span><span style="color: #ff4500">$computer</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;$env:COMPUTERNAME&quot;</span>            
 <span style="color: #000000">)</span>            
  <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_NetworkAdapterConfiguration</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">where</span> <span style="color: #000000">{</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddress</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>             
  <span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
  <span style="color: #ff4500">$address</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddress</span><span style="color: #a9a9a9">[</span><span style="color: #800080">1</span><span style="color: #a9a9a9">]</span>            
              
  <span style="color: #0000ff">Write-Debug</span> <span style="color: #8b0000">&quot;Test for ::&quot;</span>            
  <span style="color: #00008b">if</span> <span style="color: #000000">(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddress</span><span style="color: #a9a9a9">[</span><span style="color: #800080">1</span><span style="color: #a9a9a9">]</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Contains</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;::&quot;</span><span style="color: #000000">)</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
   <span style="color: #ff4500">$blocks</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddress</span><span style="color: #a9a9a9">[</span><span style="color: #800080">1</span><span style="color: #a9a9a9">]</span> <span style="color: #a9a9a9">-split</span> <span style="color: #8b0000">&quot;:&quot;</span>            
   <span style="color: #ff4500">$count</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Count</span>            
   <span style="color: #ff4500">$replace</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">8</span> <span style="color: #a9a9a9">-</span> <span style="color: #ff4500">$count</span> <span style="color: #a9a9a9">+</span> <span style="color: #800080">1</span>            
   <span style="color: #00008b">for</span> <span style="color: #000000">(</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">=</span><span style="color: #800080">0</span><span style="color: #000000">;</span> <span style="color: #ff4500">$i</span> <span style="color: #a9a9a9">-le</span> <span style="color: #ff4500">$count</span><span style="color: #a9a9a9">-</span><span style="color: #800080">1</span><span style="color: #000000">;</span> <span style="color: #ff4500">$i</span><span style="color: #a9a9a9">++</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
    <span style="color: #00008b">if</span> <span style="color: #000000">(</span><span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">[</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">]</span> <span style="color: #a9a9a9">-eq</span> <span style="color: #8b0000">&quot;&quot;</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
      <span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">[</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">]</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">(</span><span style="color: #8b0000">&quot;0000:&quot;</span> <span style="color: #a9a9a9">*</span> <span style="color: #ff4500">$replace</span><span style="color: #000000">)</span><span style="color: #a9a9a9">.</span><span style="color: #000000">TrimEnd</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;:&quot;</span><span style="color: #000000">)</span>            
    <span style="color: #000000">}</span>            
   <span style="color: #000000">}</span>            
   <span style="color: #ff4500">$address</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$blocks</span> <span style="color: #a9a9a9">-join</span> <span style="color: #8b0000">&quot;:&quot;</span>            
  <span style="color: #000000">}</span>            
            
  <span style="color: #0000ff">Write-Debug</span> <span style="color: #8b0000">&quot;Check leading 0 in place&quot;</span>            
  <span style="color: #ff4500">$blocks</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$address</span> <span style="color: #a9a9a9">-split</span> <span style="color: #8b0000">&quot;:&quot;</span>            
  <span style="color: #00008b">for</span> <span style="color: #000000">(</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">=</span><span style="color: #800080">0</span><span style="color: #000000">;</span> <span style="color: #ff4500">$i</span> <span style="color: #a9a9a9">-le</span> <span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Count</span><span style="color: #a9a9a9">-</span><span style="color: #800080">1</span><span style="color: #000000">;</span> <span style="color: #ff4500">$i</span><span style="color: #a9a9a9">++</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
    <span style="color: #00008b">if</span> <span style="color: #000000">(</span><span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">[</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">]</span><span style="color: #a9a9a9">.</span><span style="color: #000000">length</span> <span style="color: #a9a9a9">-ne</span> <span style="color: #800080">4</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
      <span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">[</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">]</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$blocks</span><span style="color: #a9a9a9">[</span><span style="color: #ff4500">$i</span><span style="color: #a9a9a9">]</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Padleft</span><span style="color: #000000">(</span><span style="color: #800080">4</span><span style="color: #a9a9a9">,</span><span style="color: #8b0000">&quot;0&quot;</span><span style="color: #000000">)</span>            
    <span style="color: #000000">}</span>            
   <span style="color: #000000">}</span>            
   <span style="color: #ff4500">$address</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$blocks</span> <span style="color: #a9a9a9">-join</span> <span style="color: #8b0000">&quot;:&quot;</span>            
            
   <span style="color: #ff4500">$ipconfig</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">New-Object</span> <span style="color: #000080">-TypeName</span> <span style="color: #8a2be2">PSObject</span> <span style="color: #000080">-Property</span> <span style="color: #000000">@{</span>            
     <span style="color: #000000">Description</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Description</span><span style="color: #000000">)</span>            
     <span style="color: #000000">IPv4Address</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddress</span><span style="color: #a9a9a9">[</span><span style="color: #800080">0</span><span style="color: #a9a9a9">]</span><span style="color: #000000">)</span>            
     <span style="color: #000000">IPv4Subnet</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPSubnet</span><span style="color: #a9a9a9">[</span><span style="color: #800080">0</span><span style="color: #a9a9a9">]</span><span style="color: #000000">)</span>            
     <span style="color: #000000">IPv6Address</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$address</span>            
     <span style="color: #000000">IPv6Subnet</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPSubnet</span><span style="color: #a9a9a9">[</span><span style="color: #800080">1</span><span style="color: #a9a9a9">]</span><span style="color: #000000">)</span>            
     <span style="color: #000000">DeviceId</span> <span style="color: #a9a9a9">=</span>  <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Index</span><span style="color: #000000">)</span>            
   <span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #8a2be2">Description</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">IPv4Address</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">IPv4Subnet</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">IPv6Address</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">IPv6Subnet</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">DeviceId</span>            
   <span style="color: #ff4500">$ipconfig</span>             
  <span style="color: #000000">}</span>              
<span style="color: #000000">}</span></pre>
<p>we get this output</p>
<p>PS&gt; get-IPAddress</p>
<p>
  <br /><font face="Courier New">Description : NVIDIA nForce 10/100/1000 Mbps Networking Controller<br />
    <br />IPv4Address : 10.10.54.202 </p>
<p>IPv4Subnet&#160; : 255.255.255.0 </p>
<p>IPv6Address : fe80:0000:0000:0000:4547:ee51:7aac:521e </p>
<p>IPv6Subnet&#160; : 64 </p>
<p>DeviceId&#160;&#160;&#160; : 7</font></p>
<p><font face="Courier New">Description : Atheros AR5007 802.11b/g WiFi Adapter<br />
    <br />IPv4Address : 192.168.1.2 </p>
<p>IPv4Subnet&#160; : 255.255.255.0 </p>
<p>IPv6Address : fe80:0000:0000:0000:6d95:b824:6a72:a0a9 </p>
<p>IPv6Subnet&#160; : 64 </p>
<p>DeviceId&#160;&#160;&#160; : 11</font></p>
<p>&#160;</p>
<p>These device ids don’t match – whats going on.</p>
<p>If we use the MSNdis_EnumerateAdapter and MSNdis_EnumerateAdapterEX classes as in this function from <a title="http://msmvps.com/blogs/richardsiddaway/archive/2011/08/25/network-adapter-details.aspx" href="http://msmvps.com/blogs/richardsiddaway/archive/2011/08/25/network-adapter-details.aspx">http://msmvps.com/blogs/richardsiddaway/archive/2011/08/25/network-adapter-details.aspx</a></p>
<p>We can get the adapter details stored in the registry which uses a different set of indexes!!!</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-adapter</span> <span style="color: #000000">{</span>            
<span style="color: #00008b">param</span><span style="color: #000000">(</span>            
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$computer</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;.&quot;</span>            
<span style="color: #000000">)</span>            
<span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Namespace</span> <span style="color: #8a2be2">root\wmi</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">MSNdis_EnumerateAdapter</span> <span style="color: #000000">`
</span><span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
 <span style="color: #ff4500">$nic</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Namespace</span> <span style="color: #8a2be2">root\wmi</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">MSNdis_EnumerateAdapterEx</span> <span style="color: #000000">`
</span><span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #000080">-Filter</span> <span style="color: #8b0000">&quot;InstanceName = '$($_.InstanceName)'&quot;</span>            
            
<span style="color: #ff4500">$header</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$nic</span><span style="color: #a9a9a9">.</span><span style="color: #000000">EnumerateAdapter</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Header</span>            
            
 <span style="color: #0000ff">New-Object</span> <span style="color: #000080">-TypeName</span> <span style="color: #8a2be2">PSobject</span> <span style="color: #000080">-Property</span> <span style="color: #000000">@{</span>            
  <span style="color: #000000">Computer</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">__SERVER</span>            
  <span style="color: #000000">Adapter</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">InstanceName</span>            
  <span style="color: #000000">Device</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">DeviceName</span>            
  <span style="color: #000000">Active</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Active</span>            
  <span style="color: #000000">Index</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$nic</span><span style="color: #a9a9a9">.</span><span style="color: #000000">EnumerateAdapter</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IfIndex</span><span style="color: #000000">)</span>            
  <span style="color: #000000">NetLuid</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$nic</span><span style="color: #a9a9a9">.</span><span style="color: #000000">EnumerateAdapter</span><span style="color: #a9a9a9">.</span><span style="color: #000000">NetLuid</span><span style="color: #000000">)</span>            
  <span style="color: #000000">Revision</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$header</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Revision</span>            
  <span style="color: #000000">Size</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$header</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Size</span>            
  <span style="color: #000000">Type</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$header</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Type</span>            
 <span style="color: #000000">}</span>            
<span style="color: #000000">}</span>            
<span style="color: #000000">}</span></pre>
<p>get-adapter | sort Index | Format-Table adapter, Index –AutoSize<br />
  </p>
<p>produces (truncated output of)</p>
<p><font face="Courier New">Adapter&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Index<br />
    <br />&#8212;&#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8211; </p>
<p>NVIDIA nForce 10/100/1000 Mbps Networking Controller&#160;&#160;&#160;&#160; 10 </p>
<p>Atheros AR5007 802.11b/g WiFi Adapter&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 11</font></p>
<p>&#160;</p>
<p>which matches the ipconfig results of</p>
<p><font face="Courier New">Ethernet adapter Local Area Connection:<br />
  <br />Link-local IPv6 Address . . . . . : fe80::4547:ee51:7aac:521e%10 </p>
<p></font></p>
<p><font face="Courier New">Wireless LAN adapter Wireless Network Connection:<br />
    <br />&#160;&#160; Link-local IPv6 Address . . . . . : fe80::6d95:b824:6a72:a0a9%11 </font></p>
<p>&#160;</p>
<p>We can test the relationship between the registry and WMI device Ids</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">resolve-deviceID</span> <span style="color: #000000">{</span>            
<span style="color: #a9a9a9">[</span><span style="color: #add8e6">CmdletBinding</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
 <span style="color: #00008b">param</span> <span style="color: #000000">(</span>            
  <span style="color: #008080">[string]</span><span style="color: #ff4500">$computer</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;$env:COMPUTERNAME&quot;</span>            
 <span style="color: #000000">)</span>            
  <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_NetworkAdapterConfiguration</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #a9a9a9">|</span>             
  <span style="color: #0000ff">where</span> <span style="color: #000000">{</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddress</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>             
  <span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
   <span style="color: #ff4500">$nic</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Namespace</span> <span style="color: #8a2be2">root\wmi</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">MSNdis_EnumerateAdapterEx</span> <span style="color: #000000">`
</span>  <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #000080">-Filter</span> <span style="color: #8b0000">&quot;InstanceName = '$($_.Description)'&quot;</span>            
               
   <span style="color: #0000ff">New-Object</span> <span style="color: #000080">-TypeName</span> <span style="color: #8a2be2">PSObject</span> <span style="color: #000080">-Property</span> <span style="color: #000000">@{</span>            
    <span style="color: #000000">Name</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Description</span><span style="color: #000000">)</span>            
    <span style="color: #000000">WMI_Index</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Index</span><span style="color: #000000">)</span>            
    <span style="color: #000000">Reg_Index</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$nic</span><span style="color: #a9a9a9">.</span><span style="color: #000000">EnumerateAdapter</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IfIndex</span><span style="color: #000000">)</span>            
   <span style="color: #000000">}</span>             
 <span style="color: #000000">}</span>            
<span style="color: #000000">}</span></pre>
<p>Which produces this out put</p>
<p>&#160;</p>
<p>PS&gt; resolve-deviceid | ft -a</p>
<p><font face="Courier New">Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Reg_Index WMI_Index<br />
    <br />&#8212;-&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212; &#8212;&#8212;&#8212; </p>
<p>NVIDIA nForce 10/100/1000 Mbps Networking Controller&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 10&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 7 </p>
<p>Atheros AR5007 802.11b/g WiFi Adapter&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 11&#160;&#160;&#160;&#160;&#160;&#160;&#160; 11 </p>
<p></font></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/ipv6-link-local-addresses-and-device-identifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Time Server</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/find-the-time-server/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/find-the-time-server/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 18:33:18 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/find-the-time-server/</guid>
		<description><![CDATA[No its not the latest Internet game. Active Directory synchronises the computer clock times. To know what server is being used function get-timeserver{ [CmdletBinding(SupportsShouldProcess=$true)] param ( [parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$computer ) BEGIN{ $HKLM = 2147483650 }#begin PROCESS{ $reg = [wmiclass]&#34;\\$computer\root\default:StdRegprov&#34; $key = &#34;SYSTEM\CurrentControlSet\Services\W32Time\Parameters&#34; switch ($computer){ &#34;.&#34; {$computername = $env:COMPUTERNAME} &#34;localhost&#34; {$computername = $env:COMPUTERNAME} default [...]]]></description>
				<content:encoded><![CDATA[<p>No its not the latest Internet game.</p>
<p>Active Directory synchronises the computer clock times. To know what server is being used</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-timeserver</span><span style="color: #000000">{</span>             
<span style="color: #a9a9a9">[</span><span style="color: #add8e6">CmdletBinding</span><span style="color: #000000">(</span><span style="color: #000000">SupportsShouldProcess</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>             
<span style="color: #00008b">param</span> <span style="color: #000000">(</span>             
<span style="color: #a9a9a9">[</span><span style="color: #add8e6">parameter</span><span style="color: #000000">(</span><span style="color: #000000">Position</span><span style="color: #a9a9a9">=</span><span style="color: #800080">0</span><span style="color: #a9a9a9">,</span>            
   <span style="color: #000000">Mandatory</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #a9a9a9">,</span>            
   <span style="color: #000000">ValueFromPipeline</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #a9a9a9">,</span>             
   <span style="color: #000000">ValueFromPipelineByPropertyName</span><span style="color: #a9a9a9">=</span><span style="color: #ff4500">$true</span><span style="color: #000000">)</span><span style="color: #a9a9a9">]</span>            
   <span style="color: #008080">[string]</span><span style="color: #ff4500">$computer</span>             
<span style="color: #000000">)</span>             
<span style="color: #00008b">BEGIN</span><span style="color: #000000">{</span>            
 <span style="color: #ff4500">$HKLM</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483650</span>            
<span style="color: #000000">}</span><span style="color: #006400">#begin </span>            
            
<span style="color: #00008b">PROCESS</span><span style="color: #000000">{</span>            
 <span style="color: #ff4500">$reg</span> <span style="color: #a9a9a9">=</span> <span style="color: #008080">[wmiclass]</span><span style="color: #8b0000">&quot;\\$computer\root\default:StdRegprov&quot;</span>            
            
 <span style="color: #ff4500">$key</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;SYSTEM\CurrentControlSet\Services\W32Time\Parameters&quot;</span>            
             
 <span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$computer</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
   <span style="color: #8b0000">&quot;.&quot;</span>         <span style="color: #000000">{</span><span style="color: #ff4500">$computername</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$env:COMPUTERNAME</span><span style="color: #000000">}</span>            
   <span style="color: #8b0000">&quot;localhost&quot;</span> <span style="color: #000000">{</span><span style="color: #ff4500">$computername</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$env:COMPUTERNAME</span><span style="color: #000000">}</span>            
   <span style="color: #8a2be2">default</span>     <span style="color: #000000">{</span><span style="color: #ff4500">$computername</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$computer</span><span style="color: #000000">}</span>            
 <span style="color: #000000">}</span>            
             
 <span style="color: #ff4500">$value</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;NtpServer&quot;</span>            
 <span style="color: #ff4500">$server</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$reg</span><span style="color: #a9a9a9">.</span><span style="color: #000000">GetStringValue</span><span style="color: #000000">(</span><span style="color: #ff4500">$HKLM</span><span style="color: #a9a9a9">,</span> <span style="color: #ff4500">$key</span><span style="color: #a9a9a9">,</span> <span style="color: #ff4500">$value</span><span style="color: #000000">)</span>  <span style="color: #006400">## REG_SZ</span>            
 <span style="color: #ff4500">$server</span><span style="color: #a9a9a9">.</span><span style="color: #000000">sValue</span> <span style="color: #a9a9a9">-split</span> <span style="color: #8b0000">&quot;,&quot;</span>            
              
<span style="color: #000000">}</span><span style="color: #006400">#process </span>            
<span style="color: #00008b">END</span><span style="color: #000000">{</span><span style="color: #000000">}</span><span style="color: #006400">#end</span>            
            
<span style="color: #000000">}</span></pre>
<p>Read the &quot;SYSTEM\CurrentControlSet\Services\W32Time\Parameters&quot; key for the Ntpserver value.&#160; Its a string so use GetstringValue(). It is possible to define multiple time servers so split the string on “,”</p>
<p>Ignore the final value of 0&#215;9</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/find-the-time-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Registry data types</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/registry-data-types/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/registry-data-types/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 19:57:41 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/registry-data-types/</guid>
		<description><![CDATA[&#160; One point I didn’t cover in my series on working with the registry was how to get the type of a registry value. 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 $regtype&#160;=&#160;DATA&#160;{ ConvertFrom-StringData&#160;-StringData&#160;@&#8217; 1 = REG_SZ 2 = REG_EXPAND_SZ 3 = REG_BINARY 4 = [...]]]></description>
				<content:encoded><![CDATA[<p>&#160;</p>
<p>One point I didn’t cover in my series on working with the registry was how to get the type of a registry value.</p>
<div style="padding-bottom: 5px;padding-left: 5px;width: 488px;padding-right: 5px;font-family:;height: 319px;padding-top: 5px">
<table border="0" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td valign="top">
<div style="padding-bottom: 5px;padding-left: 5px;padding-right: 5px;font-family:;padding-top: 5px"><font face="Consolas"><font color="#000000">001                 <br />002                  <br />003                  <br />004                  <br />005                  <br />006                  <br />007                  <br />008                  <br />009                  <br />010                  <br />011                  <br />012                  <br />013                  <br />014                  <br />015                  <br />016                  <br />017                  <br />018</font></font>              </div>
</td>
<td valign="top" nowrap="nowrap">
<div style="padding-bottom: 5px;padding-left: 5px;padding-right: 5px;font-family:;padding-top: 5px"><font face="Consolas"><span><font color="#ff4500"><font>$regtype</font></font></span><font><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#000000">&#160;</font></span><span><font color="#00008b">DATA</font></span><font color="#000000"><span>&#160;</span><span>{</span></font>                  <br /><span><font color="#0000ff">ConvertFrom-StringData</font></span><span><font color="#000000">&#160;</font></span><span><font color="#000080">-StringData</font></span><span><font color="#000000">&#160;</font></span></font></font><font><font face="Consolas"><span><font color="#8b0000">@&#8217;                     <br />1 = REG_SZ                      <br />2 = REG_EXPAND_SZ                      <br />3 = REG_BINARY                      <br />4 = REG_DWORD                      <br />7 = REG_MULTI_SZ                      <br />&#8216;@</font></span>                  <br /><span><font color="#000000">}</font></span>                  <br /><span><font color="#ff4500">$HKLM</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#000000">&#160;</font></span><span><font color="#800080">2147483650</font></span>                  <br /><span><font color="#ff4500">$key</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#000000">&#160;</font></span><span><font color="#8b0000">&quot;SOFTWARE\Microsoft\Windows\CurrentVersion&quot;</font></span>                  <br /><span><font color="#ff4500">$computer</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#8b0000">&quot;.&quot;</font></span>                  <br /><span><font color="#ff4500">$reg</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#000000">&#160;</font></span><span><font color="#008080">[wmiclass]</font></span><span><font color="#8b0000">&quot;\\$computer\root\default:StdRegprov&quot;</font></span>                  <br /><span><font color="#ff4500">$data</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#000000">&#160;</font></span><span><font color="#ff4500">$reg</font></span><span><font color="#a9a9a9">.</font></span><font color="#000000"><span>EnumValues</span><span>(</span></font><span><font color="#ff4500">$HKLM</font></span><span><font color="#a9a9a9">,</font></span><span><font color="#000000">&#160;</font></span><span><font color="#ff4500">$key</font></span><span><font color="#000000">)</font></span>                  <br /><span><font color="#ff4500">$x</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">=</font></span><font color="#000000"><span>&#160;</span><span>(</span></font><span><font color="#ff4500">$data</font></span><span><font color="#a9a9a9">.</font></span><font color="#000000"><span>snames</span><span>)</span></font><span><font color="#a9a9a9">.</font></span><span><font color="#000000">Length</font></span>                  <br /><span><font color="#00008b">for</font></span><font color="#000000"><span>&#160;</span><span>(</span></font><span><font color="#ff4500">$i</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#800080">0</font></span><font color="#000000"><span>;</span><span>&#160;</span></font><span><font color="#ff4500">$i</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">-le</font></span><span><font color="#000000">&#160;</font></span><span><font color="#ff4500">$x</font></span><font color="#000000"><span>;</span><span>&#160;</span></font><span><font color="#ff4500">$i</font></span><span><font color="#a9a9a9">++</font></span><font color="#000000"><span>)</span><span>{</span></font><span><font color="#8b0000">&quot;{0,-30} {1}&quot;</font></span><span><font color="#000000">&#160;</font></span><span><font color="#a9a9a9">-f</font></span></font></font><font face="Consolas"><font><font color="#000000"><span>&#160;</span>                    <br /><span>&#160; </span><span>$(</span></font><span><font color="#ff4500">$data</font></span><span><font color="#a9a9a9">.</font></span><span><font color="#000000">snames</font></span><span><font color="#a9a9a9">[</font></span><span><font color="#ff4500">$i</font></span><span><font color="#a9a9a9">]</font></span><span><font color="#000000">)</font></span><span><font color="#a9a9a9">,</font></span><span><font color="#000000">&#160;</font></span><span><font color="#ff4500">$regtype</font></span><span><font color="#a9a9a9">[</font></span><span><font color="#8b0000">&quot;$($data.types[$i])&quot;</font></span><span><font color="#a9a9a9">]</font></span><span><font color="#000000">&#160;</font></span></font><span><font color="#000000">}</font></span></font>              </div>
</td>
</tr>
</tbody>
</table></div>
<p>The easiest way is to use the EnumValues() method.&#160; This returns integer values for the type.</p>
<p>Define a hash table that contains the integer and its meaning. Define the hive and the key. Create an instance of StdRegProv and invoke the EnumValues method. Loop through the returned values and use a formatted string to display the results</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/registry-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recording and slides for July 2010 UG meeting</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/recording-and-slides-for-july-2010-ug-meeting/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/recording-and-slides-for-july-2010-ug-meeting/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 20:00:43 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[User Group]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/recording-and-slides-for-july-2010-ug-meeting/</guid>
		<description><![CDATA[This months meeting covered working with the registry. The slides and the demo script are available from http://cid-43cfa46a74cf3e96.office.live.com/browse.aspx/PowerShell%20User%20Group/2010%20July &#160; The recording is available Richard Siddaway has invited you to view a Microsoft Office Live Meeting recording. View Recording Recording Details &#160;&#160;&#160; Subject: PowerShell and the Registry &#160;&#160;&#160; Recording URL: https://www.livemeeting.com/cc/usergroups/view &#160;&#160;&#160; Recording ID: CB99JS &#160;&#160;&#160; [...]]]></description>
				<content:encoded><![CDATA[<p>This months meeting covered working with the registry.</p>
<p>The slides and the demo script are available from</p>
<p><a title="http://cid-43cfa46a74cf3e96.office.live.com/browse.aspx/PowerShell%20User%20Group/2010%20July" href="http://cid-43cfa46a74cf3e96.office.live.com/browse.aspx/PowerShell%20User%20Group/2010%20July">http://cid-43cfa46a74cf3e96.office.live.com/browse.aspx/PowerShell%20User%20Group/2010%20July</a></p>
<p>&#160;</p>
<p>The recording is available </p>
<p>Richard Siddaway has invited you to view a Microsoft Office Live Meeting recording.    <br /><a href="https://www.livemeeting.com/cc/usergroups/view?id=CB99JS&amp;pw=mm%242%21%22%2C%24G">View Recording</a>     <br />Recording Details     <br />&#160;&#160;&#160; Subject: PowerShell and the Registry     <br />&#160;&#160;&#160; Recording URL: <a href="https://www.livemeeting.com/cc/usergroups/view">https://www.livemeeting.com/cc/usergroups/view</a>     <br />&#160;&#160;&#160; Recording ID: CB99JS     <br />&#160;&#160;&#160; Attendee Key: mm$2!&quot;,$G </p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/recording-and-slides-for-july-2010-ug-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tomorrow &#8211; July UG meeting</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/tomorrow-july-ug-meeting/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/tomorrow-july-ug-meeting/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 18:41:00 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[Registry]]></category>
		<category><![CDATA[User Group]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/tomorrow-july-ug-meeting/</guid>
		<description><![CDATA[Tomorrow is the PowerShell UG Live Meeting on the Registry, PowerShell, .NET and WMI. Full details from http://msmvps.com/blogs/richardsiddaway/archive/2010/07/20/july-2010-ug-meeting-registry.aspx]]></description>
				<content:encoded><![CDATA[<p>Tomorrow is the PowerShell UG Live Meeting on the Registry, PowerShell, .NET and WMI.</p>
<p>Full details from</p>
<p><a title="http://msmvps.com/blogs/richardsiddaway/archive/2010/07/20/july-2010-ug-meeting-registry.aspx" href="http://msmvps.com/blogs/richardsiddaway/archive/2010/07/20/july-2010-ug-meeting-registry.aspx">http://msmvps.com/blogs/richardsiddaway/archive/2010/07/20/july-2010-ug-meeting-registry.aspx</a></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/tomorrow-july-ug-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
