 




<?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; Operating System</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/powershell/tag/operating-system/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>Thu, 16 May 2013 18:56:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<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>Windows Server 8&#8211;features removed or deprecated</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/windows-server-8features-removed-or-deprecated/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/windows-server-8features-removed-or-deprecated/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 13:27:24 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Windows Server 8]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/windows-server-8features-removed-or-deprecated/</guid>
		<description><![CDATA[When you start your implementation planning for Windows Server 8 make sure to check with this page for functionality that has been removed or deprecated (means it will be removed in a future version) http://technet.microsoft.com/en-us/library/hh831568.aspx]]></description>
				<content:encoded><![CDATA[<p>When you start your implementation planning for Windows Server 8 make sure to check with this page for functionality that has been removed or deprecated (means it will be removed in a future version)</p>
<p><a title="http://technet.microsoft.com/en-us/library/hh831568.aspx" href="http://technet.microsoft.com/en-us/library/hh831568.aspx">http://technet.microsoft.com/en-us/library/hh831568.aspx</a></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/windows-server-8features-removed-or-deprecated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 8 svchost</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/windows-8-svchost/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/windows-8-svchost/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 14:26:51 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell 3]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/windows-8-svchost/</guid>
		<description><![CDATA[When you run get-process you will see a number of entries named svchost.&#160; These are processes that host services. In task manager on Windows 7 and below all we see is the svchost entry. In the Windows 8 family we see the services running in a particular host Now can we do anything similar with [...]]]></description>
				<content:encoded><![CDATA[<p>When you run get-process you will see a number of entries named svchost.&#160; These are processes that host services. In task manager on Windows 7 and below all we see is the svchost entry. In the Windows 8 family we see the services running in a particular host</p>
<p>Now can we do anything similar with PowerShell.</p>
<p>Get-Service doesn’t do anything to help BUT the Win32_Service class has a ProcessID property that we can use</p>
<pre><span style="color: #0000ff">Get-CimInstance</span> <span style="color: #000080">-ClassName</span> <span style="color: #8a2be2">Win32_Service</span> <span style="color: #a9a9a9">|</span>             
<span style="color: #0000ff">sort</span> <span style="color: #8a2be2">ProcessID</span> <span style="color: #000080">-Descending</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
  <span style="color: #ff4500">$proc</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-Process</span> <span style="color: #000080">-Id</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ProcessID</span>            
  <span style="color: #ff4500">$_</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">ProcessName</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$proc</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ProcessName</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span>            
<span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Format-Table</span> <span style="color: #8a2be2">DisplayName</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">ProcessName</span> <span style="color: #000080">-GroupBy</span> <span style="color: #8a2be2">ProcessId</span></pre>
<p>I’ve used Get-CimInstance in this example because of the CIM cmdlets are new to PowerShell v3. For a PowerShell v2 install use Get-WmiObject</p>
<pre><span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_Service</span> <span style="color: #a9a9a9">|</span>             
<span style="color: #0000ff">sort</span> <span style="color: #8a2be2">ProcessID</span> <span style="color: #000080">-Descending</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
  <span style="color: #ff4500">$proc</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-Process</span> <span style="color: #000080">-Id</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ProcessID</span>            
  <span style="color: #ff4500">$_</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">ProcessName</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$proc</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ProcessName</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span>            
<span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Format-Table</span> <span style="color: #8a2be2">DisplayName</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">ProcessName</span> <span style="color: #000080">-GroupBy</span> <span style="color: #8a2be2">ProcessId</span></pre>
<p>The WMI objects are piped through sort &amp; into foreach where we add the process name. In both cases I’ve used Get-Process – either Get-CIMInstance or Get-WmiObject using the Win32_Process class could be used instead.</p>
<p>Format-table is used with GroupBy to produce a nicely formatted report. This information is important because it shows the services that are related to a particular process and the impact if that process fails..</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/windows-8-svchost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Win32_AutocheckSetting class</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/win32_autochecksetting-class/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/win32_autochecksetting-class/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 20:24:17 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/win32_autochecksetting-class/</guid>
		<description><![CDATA[I stumbled on this class Get-WmiObject Win32_AutochkSetting The useful output is Caption&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : Description&#160;&#160;&#160;&#160;&#160; : SettingID&#160;&#160;&#160;&#160;&#160;&#160;&#160; : Microsoft Windows 7 Ultimate &#124;C:\Windows&#124;\Device\Harddisk0\Partition2 UserInputDelay&#160;&#160; : 10 &#160; Be careful with the documentation because it states that SettingID holds the date and time of installation!&#160; I’ve made the output a bit easier to understand $acs = Get-WmiObject [...]]]></description>
				<content:encoded><![CDATA[<p>I stumbled on this class</p>
<p>Get-WmiObject Win32_AutochkSetting</p>
<p>The useful output is</p>
<p>Caption&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; :    <br />Description&#160;&#160;&#160;&#160;&#160; :     <br />SettingID&#160;&#160;&#160;&#160;&#160;&#160;&#160; : Microsoft Windows 7 Ultimate |C:\Windows|\Device\Harddisk0\Partition2     <br />UserInputDelay&#160;&#160; : 10</p>
<p>&#160;</p>
<p>Be careful with the documentation because it states that SettingID holds the date and time of installation!&#160; </p>
<p>I’ve made the output a bit easier to understand</p>
<pre><span style="color: #ff4500">$acs</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_AutochkSetting</span>             
<span style="color: #ff4500">$setting</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$acs</span><span style="color: #a9a9a9">.</span><span style="color: #000000">SettingID</span> <span style="color: #a9a9a9">-split</span> <span style="color: #8b0000">&quot;\|&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">OS</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$setting</span><span style="color: #a9a9a9">[</span><span style="color: #800080">0</span><span style="color: #a9a9a9">]</span>            
  <span style="color: #000000">Path</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$setting</span><span style="color: #a9a9a9">[</span><span style="color: #800080">1</span><span style="color: #a9a9a9">]</span>            
  <span style="color: #000000">Disk</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$setting</span><span style="color: #a9a9a9">[</span><span style="color: #800080">2</span><span style="color: #a9a9a9">]</span>            
  <span style="color: #8b0000">'Delay(s)'</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$acs</span><span style="color: #a9a9a9">.</span><span style="color: #000000">UserInputDelay</span>            
<span style="color: #000000">}</span></pre>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/win32_autochecksetting-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can I? Should?&#8211;copying VBscripts</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/can-i-shouldcopying-vbscripts/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/can-i-shouldcopying-vbscripts/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 19:43:22 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/can-i-shouldcopying-vbscripts/</guid>
		<description><![CDATA[One of the major errors I see PowerShell newcomers performing is copying script structures and syntax of VBScript into PowerShell. Let me give you an example This piece of VBScript is borrowed from the Windows 2000 scripting guide &#160; strComputer = &#34;.&#34; Set objWMIService = GetObject(&#34;winmgmts:&#34; _ &#38; &#34;{impersonationLevel=impersonate}!\\&#34; &#38; strComputer &#38; &#34;\root\cimv2&#34;) Set colSettings [...]]]></description>
				<content:encoded><![CDATA[<p>One of the major errors I see PowerShell newcomers performing is copying script structures and syntax of VBScript into PowerShell. Let me give you an example</p>
<p>This piece of VBScript is borrowed from the Windows 2000 scripting guide</p>
<p>&#160;</p>
<p>strComputer = &quot;.&quot;    <br />Set objWMIService = GetObject(&quot;winmgmts:&quot; _     <br />&amp; &quot;{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)     <br />Set colSettings = objWMIService.ExecQuery _     <br />(&quot;SELECT * FROM Win32_OperatingSystem&quot;)     <br />For Each objOperatingSystem in colSettings     <br />Wscript.Echo &quot;OS Name: &quot; &amp; objOperatingSystem.Name     <br />Wscript.Echo &quot;Version: &quot; &amp; objOperatingSystem.Version     <br />Wscript.Echo &quot;Service Pack: &quot; &amp; _     <br />objOperatingSystem.ServicePackMajorVersion _     <br />&amp; &quot;.&quot; &amp; objOperatingSystem.ServicePackMinorVersion     <br />Wscript.Echo &quot;OS Manufacturer: &quot; &amp; objOperatingSystem.Manufacturer     <br />Wscript.Echo &quot;Windows Directory: &quot; &amp; _     <br />objOperatingSystem.WindowsDirectory     <br />Wscript.Echo &quot;Locale: &quot; &amp; objOperatingSystem.Locale     <br />Wscript.Echo &quot;Available Physical Memory: &quot; &amp; _     <br />objOperatingSystem.FreePhysicalMemory     <br />Wscript.Echo &quot;Total Virtual Memory: &quot; &amp; _     <br />objOperatingSystem.TotalVirtualMemorySize     <br />Wscript.Echo &quot;Available Virtual Memory: &quot; &amp; _     <br />objOperatingSystem.FreeVirtualMemory     <br />Wscript.Echo &quot;OS Name: &quot; &amp; objOperatingSystem.SizeStoredInPagingFiles     <br />Next     </p>
<p>It uses the Win32_OperatingSystem class to display information about the computers OS. As you can see the bulk of the script is concerned with formatting. Note the error in the script regarding OS Name</p>
<p>&#160;</p>
<p>What often happens is that this will be translated directly, line by line, into PowerShell – which gives us something like this</p>
<pre><span style="color: #ff4500">$strComputer</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;.&quot;</span>            
            
<span style="color: #ff4500">$colSettings</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Query</span> <span style="color: #8b0000">&quot;SELECT * FROM Win32_OperatingSystem&quot;</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$strComputer</span>            
<span style="color: #00008b">foreach</span> <span style="color: #000000">(</span><span style="color: #ff4500">$objOperatingSystem</span> <span style="color: #00008b">in</span> <span style="color: #ff4500">$colSettings</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;OS Name: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Name</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Version: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Version</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Service Pack: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ServicePackMajorVersion</span> <span style="color: #8b0000">&quot;.&quot;</span> <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">ServicePackMinorVersion</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;OS Manufacturer: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Manufacturer</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Windows Directory: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">WindowsDirectory</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Locale: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Locale</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Available Physical Memory: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">FreePhysicalMemory</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Total Virtual Memory: &quot;</span>  <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">TotalVirtualMemorySize</span>            
 <span style="color: #0000ff">Write-Host</span> <span style="color: #8b0000">&quot;Available Virtual Memory: &quot;</span> <span style="color: #ff4500">$objOperatingSystem</span><span style="color: #a9a9a9">.</span><span style="color: #000000">FreeVirtualMemory</span>            
<span style="color: #000000">}</span></pre>
<p>This is less code but still seems like a lot of work</p>
<p>&#160;</p>
<p>lets put it into PowerShell as if we had written it from scratch</p>
<pre><span style="color: #ff4500">$strComputer</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;.&quot;</span>            
            
<span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_OperatingSystem</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$strComputer</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">select</span> <span style="color: #8a2be2">Name</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">Version</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">ServicePackMajorVersion</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">ServicePackMinorVersion</span><span style="color: #a9a9a9">,</span>            
<span style="color: #8a2be2">Manufacturer</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">WindowsDirectory</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">Locale</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">FreePhysicalMemory</span><span style="color: #a9a9a9">,</span>             
<span style="color: #8a2be2">TotalVirtualMemorySize</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">FreeVirtualMemory</span></pre>
<p>&#160;</p>
<p>Now that is much easier. Quicker to code and easier to understand.</p>
<p>&#160;</p>
<p>By all means use VBscripts as references for using WMI classes (I do) but re-write into PowerShell its much, much easier. </p>
<p>This isn’t a contradiction of my previous post as I advocated leaving legacy VBScript alone until you needed to&#160; modify it</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/can-i-shouldcopying-vbscripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer Report IV: Time server</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/computer-report-iv-time-server/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/computer-report-iv-time-server/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 12:52:47 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/computer-report-iv-time-server/</guid>
		<description><![CDATA[The batch file uses net time /querysntp which displays the name of the Network Time Protocol (NTP) server currently configured for the local computer or the one specified in ComputerName. Unfortunately /querysntp&#160; has been deprecated in later versions of Windows. In a domain we normally configure client and server machines to use the domain time [...]]]></description>
				<content:encoded><![CDATA[<p>The batch file uses </p>
<p>net time /querysntp </p>
<p>which displays the name of the Network Time Protocol (NTP) server currently configured for the local computer or the one specified in <em>ComputerName</em>.</p>
<p>Unfortunately /querysntp&#160; has been deprecated in later versions of Windows. </p>
<p>In a domain we normally configure client and server machines to use the domain time synchronisation hierarchy rather than an external time source (the exception to this is the PDC emulator FSMO role holder in the root domain which is the top of hierarchy and synchronises externally)</p>
<p>Our test then should be to see if we are using a domain time synchronisation source or external. This information is held in the registry.</p>
<p>We need to look in HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\parameters.</p>
<p>The Type property tells us if we are using domain synchronisation (NT5DS) or and external server (NTP). The server( s ) are held in the NTPserver property.</p>
<p>We can amend our basic data function to read these registry keys</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-basicdata</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;localhost&quot;</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: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get Operating System&quot;</span>            
<span style="color: #ff4500">$os</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_OperatingSystem</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get Computer System&quot;</span>            
<span style="color: #ff4500">$comp</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_ComputerSystem</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get IP Address&quot;</span>            
<span style="color: #ff4500">$ip</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Test-Connection</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #000080">-Count</span> <span style="color: #800080">1</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Read registry entry&quot;</span>            
<span style="color: #ff4500">$HKLM</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483650</span> <span style="color: #006400">#HKEY_LOCAL_MACHINE</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\Control\Terminal Server\WinStations\rdp-tcp&quot;</span>            
<span style="color: #ff4500">$value</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;MinEncryptionLevel&quot;</span>            
<span style="color: #ff4500">$minlvl</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$reg</span><span style="color: #a9a9a9">.</span><span style="color: #000000">GetDwordValue</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_DWORD</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Create Object&quot;</span>            
<span style="color: #ff4500">$obj</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: #ff4500">$obj</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">OperatingSystem</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$os</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Caption</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">ServicePack</span>    <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$os</span><span style="color: #a9a9a9">.</span><span style="color: #000000">CSDVersion</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Version</span>       <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$os</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Version</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Domain</span>       <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$comp</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Domain</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Name</span>       <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$comp</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Name</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">IPv4Address</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$ip</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPV4Address</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddressToString</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">MinEncrypt</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$minlvl</span><span style="color: #a9a9a9">.</span><span style="color: #000000">uValue</span><span style="color: #000000">)</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Read registry time entry&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: #ff4500">$value</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;Type&quot;</span>            
<span style="color: #ff4500">$type</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">$value1</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;NtpServer&quot;</span>            
<span style="color: #ff4500">$NTPserver</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">$value1</span><span style="color: #000000">)</span>  <span style="color: #006400">## REG_SZ</span>            
            
<span style="color: #00008b">switch</span> <span style="color: #000000">(</span><span style="color: #ff4500">$type</span><span style="color: #a9a9a9">.</span><span style="color: #000000">svalue</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
 <span style="color: #8b0000">&quot;NTP&quot;</span>  <span style="color: #000000">{</span> <span style="color: #ff4500">$obj</span> <span style="color: #a9a9a9">|</span>            
          <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">TimeType</span> <span style="color: #000080">-Value</span> <span style="color: #8b0000">&quot;External Server&quot;</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
          <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">TimeServer</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$NTPServer</span><span style="color: #a9a9a9">.</span><span style="color: #000000">svalue</span><span style="color: #000000">)</span>            
         <span style="color: #000000">}</span>            
 <span style="color: #8b0000">&quot;NT5DS&quot;</span> <span style="color: #000000">{</span> <span style="color: #ff4500">$obj</span> <span style="color: #a9a9a9">|</span>            
           <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">TimeType</span> <span style="color: #000080">-Value</span> <span style="color: #8b0000">&quot;Domain&quot;</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
           <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">TimeServer</span> <span style="color: #000080">-Value</span> <span style="color: #8b0000">&quot;&quot;</span>            
         <span style="color: #000000">}</span>            
<span style="color: #000000">}</span>            
            
<span style="color: #ff4500">$obj</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>&#160;</p>
<p>A switch statement is used to test the value of Type and the appropriate data is add to the object.</p>
<p>As before use</p>
<p>get-basicdata&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p>
<p>to generate output to screen or something like this</p>
<p>&#160;&#160; get-basicdata | out-file basicdata.txt&#160;&#160;&#160; </p>
<p>to create an output file</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/computer-report-iv-time-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer Report: II Service Information</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/computer-report-ii-service-information/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/computer-report-ii-service-information/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 11:06:40 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/computer-report-ii-service-information/</guid>
		<description><![CDATA[&#160; The batch file retrieves service information using wmic service where state=&#34;Running&#34; get DisplayName, Caption Direct PowerShell translation is this. Get-WmiObject -Class Win32_Service -Filter &#34;State=&#8217;Running&#8217;&#34; &#124; Select DisplayName, Caption Couple of problems: DisplayName and Caption tend to show the same output What about services that aren’t running? A major problem could be resolved if you [...]]]></description>
				<content:encoded><![CDATA[<p>&#160;</p>
<p>The batch file retrieves service information using</p>
<p>wmic service where state=&quot;Running&quot; get DisplayName, Caption</p>
<p>Direct PowerShell translation is this.</p>
<p>Get-WmiObject -Class Win32_Service -Filter &quot;State=&#8217;Running&#8217;&quot; | Select DisplayName, Caption    </p>
<p>Couple of problems:</p>
<ol>
<li>DisplayName and Caption tend to show the same output </li>
<li>What about services that aren’t running? A major problem could be resolved if you realised a service that should be running has stopped. </li>
</ol>
<p>Lets change the WMI to </p>
<p>Get-WmiObject -Class Win32_Service | sort State | Select State, Name, Caption</p>
<p>When we create our function we can add a switch to restrict output to just running services if required</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-servicestate</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;localhost&quot;</span><span style="color: #a9a9a9">,</span>            
   <span style="color: #008080">[switch]</span><span style="color: #ff4500">$running</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: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get Services&quot;</span>            
<span style="color: #ff4500">$services</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_Service</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span>            
            
<span style="color: #00008b">if</span> <span style="color: #000000">(</span><span style="color: #ff4500">$running</span><span style="color: #000000">)</span><span style="color: #000000">{</span>            
  <span style="color: #ff4500">$services</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">State</span> <span style="color: #a9a9a9">-eq</span> <span style="color: #8b0000">&quot;Running&quot;</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Select</span> <span style="color: #8a2be2">Name</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">Caption</span>            
<span style="color: #000000">}</span>            
<span style="color: #00008b">else</span> <span style="color: #000000">{</span>            
  <span style="color: #ff4500">$services</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">sort</span> <span style="color: #8a2be2">State</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Select</span> <span style="color: #8a2be2">State</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">Name</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">Caption</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: #000000">}</span></pre>
<p>&#160;</p>
<p>By fetching all of the service information we allow ourselves the ability to easily modify the output if requirements change</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/computer-report-ii-service-information/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Computer report</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/computer-report/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/computer-report/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 19:56:20 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/computer-report/</guid>
		<description><![CDATA[A recent post on the powershell.com site asked about running a Windows command (batch) file through PowerShell against remote machines. The batch file was expected to produce a number of files of data in a folder structure based on computer name. This makes it difficult as we could in theory run the batch file through [...]]]></description>
				<content:encoded><![CDATA[<p>A recent post on the powershell.com site asked about running a Windows command (batch) file through PowerShell against remote machines. The batch file was expected to produce a number of files of data in a folder structure based on computer name. This makes it difficult as we could in theory run the batch file through remoting (not actually tried it) but writing to a file share isn’t easy.</p>
<p>I decide to convert the batch file to PowerShell.&#160; The first part uses a number of basic Windows commands to generate data. This function supplies exactly the same functionality</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">get-basicdata</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;localhost&quot;</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: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get Operating System&quot;</span>            
<span style="color: #ff4500">$os</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_OperatingSystem</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get Computer System&quot;</span>            
<span style="color: #ff4500">$comp</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-WmiObject</span> <span style="color: #000080">-Class</span> <span style="color: #8a2be2">Win32_ComputerSystem</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Get IP Address&quot;</span>            
<span style="color: #ff4500">$ip</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Test-Connection</span> <span style="color: #000080">-ComputerName</span> <span style="color: #ff4500">$computer</span> <span style="color: #000080">-Count</span> <span style="color: #800080">1</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Read registry entry&quot;</span>            
<span style="color: #ff4500">$HKLM</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">2147483650</span> <span style="color: #006400">#HKEY_LOCAL_MACHINE</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\Control\Terminal Server\WinStations\rdp-tcp&quot;</span>            
<span style="color: #ff4500">$value</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;MinEncryptionLevel&quot;</span>            
<span style="color: #ff4500">$minlvl</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$reg</span><span style="color: #a9a9a9">.</span><span style="color: #000000">GetDwordValue</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_DWORD</span>            
            
<span style="color: #0000ff">Write-Verbose</span> <span style="color: #8b0000">&quot;Create Object&quot;</span>            
<span style="color: #ff4500">$obj</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: #ff4500">$obj</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">OperatingSystem</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$os</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Caption</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">ServicePack</span>    <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$os</span><span style="color: #a9a9a9">.</span><span style="color: #000000">CSDVersion</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Version</span>       <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$os</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Version</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Domain</span>       <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$comp</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Domain</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Name</span>       <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$comp</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Name</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">IPv4Address</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$ip</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPV4Address</span><span style="color: #a9a9a9">.</span><span style="color: #000000">IPAddressToString</span><span style="color: #000000">)</span> <span style="color: #000080">-PassThru</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">MinEncrypt</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$minlvl</span><span style="color: #a9a9a9">.</span><span style="color: #000000">uValue</span><span style="color: #000000">)</span>            
            
<span style="color: #ff4500">$obj</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>All we do is make a few calls to WMI classes and we get the results into an object as shown.</p>
<p>To produce a file use</p>
<p>The contents look like this</p>
<p><font size="2" face="Courier New">OperatingSystem : Microsoft Windows 7 Ultimate<br />
    <br />ServicePack&#160;&#160;&#160;&#160; : Service Pack 1 </p>
<p>Version&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : 6.1.7601 </p>
<p>Domain&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : WORKGROUP </p>
<p>Name&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : RSLAPTOP01 </p>
<p>IPv4Address&#160;&#160;&#160;&#160; : 127.0.0.1 </p>
<p>MinEncrypt&#160;&#160;&#160;&#160;&#160; : 2</font></p>
<p>That covers the basic data.&#160; Need to look at services and TCP ports next</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/computer-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Stability part II</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/system-stability-part-ii/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/system-stability-part-ii/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 19:08:12 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[Windows 2008 R2]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/system-stability-part-ii/</guid>
		<description><![CDATA[Last time we looked at the Win32_ReliabilityStabilityMetrics and closed by stating we’d look at the reliability records.&#160; Reliability records are event log records related to system reliability.&#160; The working part of the record is shown below (after the system properties are removed) ComputerName&#160;&#160;&#160;&#160; : RSLAPTOP01 EventIdentifier&#160; : 19 InsertionStrings : {Security Update for Microsoft .NET [...]]]></description>
				<content:encoded><![CDATA[<p>Last time we looked at the Win32_ReliabilityStabilityMetrics and closed by stating we’d look at the reliability records.&#160; Reliability records are event log records related to system reliability.&#160; The working part of the record is shown below (after the system properties are removed)</p>
<p><font size="2" face="Courier New">ComputerName&#160;&#160;&#160;&#160; : RSLAPTOP01      <br />EventIdentifier&#160; : 19       <br />InsertionStrings : {Security Update for Microsoft .NET Framework 4 on&#160; Windows XP, Windows Server&#160;&#160;&#160;&#160; 2003, Windows Vista, Windows 7, Windows Server 2008, {ac2a295d-228e-4941-8568-ff131f842920}, 105}</font></p>
<p> <font size="2" face="Courier New">
<p>Logfile&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : System       <br />Message&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : Installation Successful: Windows successfully installed the following update: Security Update for Mi&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; crosoft .NET Framework 4 on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 x86 (KB2446708)</p>
<p>ProductName&#160;&#160;&#160;&#160;&#160; : Security Update for Microsoft .NET Framework 4 on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008       <br />RecordNumber&#160;&#160;&#160;&#160; : 180291       <br />SourceName&#160;&#160;&#160;&#160;&#160;&#160; : Microsoft-Windows-WindowsUpdateClient       <br />TimeGenerated&#160;&#160;&#160; : 20110414224442.000000-000       <br />User&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : NT AUTHORITY\SYSTEM</p>
<p> </font>
<p>&#160;</p>
<p>This is fairly typical in that it shows something that has changed and could therefore affect system reliability. Which logs are involved.&#160; On my system</p>
<p>PS&gt; Get-WmiObject Win32_ReliabilityRecords | select Logfile -Unique</p>
<p><font face="Courier New">Logfile      <br />&#8212;&#8212;-       <br />System       <br />Application</font></p>
<p>As we are talking about event logs they have to have a source</p>
<p>PS&gt; Get-WmiObject Win32_ReliabilityRecords | select SourceName -Unique</p>
<p><font face="Courier New">SourceName      <br />&#8212;&#8212;&#8212;-       <br />Microsoft-Windows-WindowsUpdateClient       <br />Application Error       <br />MsiInstaller       <br />Microsoft-Windows-UserPnp       <br />Application Hang       <br />Application-Addon-Event-Provider       <br />EventLog</font></p>
<p>If we want to see the events related to a particular source then we can do this</p>
<p>PS&gt; Get-WmiObject -Class Win32_ReliabilityRecords -Filter &quot;SourceName=&#8217;Application Hang&#8217;&quot; | Format-Table TimeGenerated, ProductName, Message –wrap –AutoSize</p>
<p>What we really need is a function to wrap the choices so we just choose parameters. Thats what we’ll do next</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/system-stability-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Restore Points pt 2</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/system-restore-points-pt-2/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/system-restore-points-pt-2/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 20:08:22 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Operating System]]></category>
		<category><![CDATA[PowerShell v2]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/system-restore-points-pt-2/</guid>
		<description><![CDATA[  We have seen how to discover the available restore points.  What about creating one. 001 002 003 004 005 006 007 008 009 010 011 012 013 function new-systemrestorepoint { [CmdletBinding()] param (  [string]$computername=&#8220;.&#8221;, [string]$description=&#8220;Testing123&#8243; ) $test = Test-Connection -ComputerName $computername -Count 1 if (-not ($test)){Throw &#8220;Computer $computername not reachable&#8221; }  $sr = [wmiclass]&#8220;\\$computername\root\default:SystemRestore&#8221;  $sr.CreateRestorePoint($description, 0, 100) }         We need to use [wmiclass] to create a new [...]]]></description>
				<content:encoded><![CDATA[<p> </p>
<p>We have seen how to discover the available restore points.  What about creating one.</p>
<div style="width: 568px;height: 244px;padding: 5px">
<table style="width: 611px;height: 259px" 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"><span style="font-family: Consolas"><span style="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</span></span></div>
</td>
<td valign="top">
<div style="padding-bottom: 5px;padding-left: 5px;padding-right: 5px;font-family:;padding-top: 5px"><span style="font-family: Consolas"><span><span style="color: #00008b"><span>function</span></span></span><span><span><span style="color: #000000"> </span></span><span><span style="color: #8a2be2">new-systemrestorepoint</span></span><span style="color: #000000"><span> </span><span>{</span></span><br />
<span><span style="color: #a9a9a9">[</span></span><span><span style="color: #add8e6">CmdletBinding</span></span><span style="color: #000000"><span>(</span><span>)</span></span><span><span style="color: #a9a9a9">]</span></span><br />
<span><span style="color: #00008b">param</span></span><span style="color: #000000"><span> </span><span>(</span><span> </span></span><br />
<span><span style="color: #008080">[string]</span></span><span><span style="color: #ff4500">$computername</span></span><span><span style="color: #a9a9a9">=</span></span><span><span style="color: #8b0000">&#8220;.&#8221;</span></span><span><span style="color: #a9a9a9">,</span></span><br />
<span><span style="color: #008080">[string]</span></span><span><span style="color: #ff4500">$description</span></span><span><span style="color: #a9a9a9">=</span></span><span><span style="color: #8b0000">&#8220;Testing123&#8243;</span></span><br />
<span style="color: #000000"><span>)</span><span> </span></span><span><span style="color: #ff4500">$test</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #a9a9a9">=</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #0000ff">Test-Connection</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #000080">-ComputerName</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #ff4500">$computername</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #000080">-Count</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #800080">1</span></span><br />
<span><span style="color: #00008b">if</span></span><span style="color: #000000"><span> </span><span>(</span></span><span><span style="color: #a9a9a9">-not</span></span><span style="color: #000000"><span> </span><span>(</span></span><span><span style="color: #ff4500">$test</span></span><span style="color: #000000"><span>)</span><span>)</span><span>{</span></span><span><span style="color: #00008b">Throw</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #8b0000">&#8220;Computer $computername not reachable&#8221;</span></span></p>
<div><span style="font-family: Consolas"><span><span style="color: #000000"><span>}</span> </span></span></span></div>
<p></span></span></div>
<p><span style="font-family: Consolas"><span><span style="color: #000000"><span> </span><span><span style="color: #ff4500">$sr</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #a9a9a9">=</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #008080">[wmiclass]</span></span><span><span style="color: #8b0000">&#8220;\\$computername\root\default:SystemRestore&#8221;</span></span><br />
<span><span style="color: #000000"> </span></span><span><span style="color: #ff4500">$sr</span></span><span><span style="color: #a9a9a9">.</span></span><span style="color: #000000"><span>CreateRestorePoint</span><span>(</span></span><span><span style="color: #ff4500">$description</span></span><span><span style="color: #a9a9a9">,</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #800080">0</span></span><span><span style="color: #a9a9a9">,</span></span><span><span style="color: #000000"> </span></span><span><span style="color: #800080">100</span></span><span style="color: #000000"><span>)</span><br />
<span>}</span> </span></p>
<p></span></span></span></td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>We need to use [wmiclass] to create a new instance of the SystemRestore class. We can then use the CreateRestorePoint method with the description we’ve input as a parameter. The other paarmeters define it as an application install and begin system change respectively. This are generic enough to be left as is.  They can be made parameters if required</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/system-restore-points-pt-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
