<?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>Richard&#039;s Site &#187; Active Directory</title>
	<atom:link href="http://www.raseley.com/tag/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.raseley.com</link>
	<description>It&#039;s About Stuff!</description>
	<lastBuildDate>Wed, 14 Sep 2011 21:41:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Information Gathering via PowerShell Script Pt. 1</title>
		<link>http://www.raseley.com/2009/05/13/information-gathering-via-powershell-script/</link>
		<comments>http://www.raseley.com/2009/05/13/information-gathering-via-powershell-script/#comments</comments>
		<pubDate>Wed, 13 May 2009 19:51:23 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.raseley.com/?p=89</guid>
		<description><![CDATA[Here is a simple PowerShell script I wrote to gather either computer, group, or user information depending on your choices. This could easily be done with much simpler scripts, but I wanted to use it as more of a learning &#8230; <a href="http://www.raseley.com/2009/05/13/information-gathering-via-powershell-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is a simple PowerShell script I wrote to gather either computer, group, or user information depending on your choices. This could easily be done with much simpler scripts, but I wanted to use it as more of a learning process in order to better understand AD queries, variable expansion, functions, and other PowerShell features.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Function Definition: fnPause</span>
<span style="color: #0000FF;">Function</span> fnPause <span style="color: #000000;">&#40;</span><span style="color: #800080;">$message</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;Press any key to continue...&quot;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #008080; font-style: italic;">-NoNewLine</span> <span style="color: #800080;">$Message</span>
		<span style="color: #800080;">$null</span> <span style="color: pink;">=</span> <span style="color: #000080;">$Host</span>.UI.RawUI.ReadKey<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;NoEcho,IncludeKeyDown&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;&quot;</span>
		Main_Menu
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Function Definition: fnADSearchMenu </span>
<span style="color: #0000FF;">Function</span> fnADSearchMenu
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Display Welcome Message</span>
	Clear<span style="color: pink;">-</span>Host
	<span style="color: #800000;">&quot;Active Directory Search Script v1.0&quot;</span>
	<span style="color: #800000;">&quot;Created By: Richard Raseley (Richard@Raseley.com)&quot;</span>
	<span style="color: #800000;">&quot; &quot;</span>
&nbsp;
	<span style="color: #008000;"># Display Top Level Menu Question</span>
	<span style="color: #800000;">&quot;What type of Active Directory object would you like to search for?&quot;</span>
&nbsp;
	<span style="color: #008000;"># Display Top Level Menu</span>
	<span style="color: #800080;">$MenuTopLevel</span> <span style="color: pink;">=</span> 
	<span style="color: #800000;">'
	[1] User(s)
	[2] Group(s)
	[3] Computer(s)
	[4] Exit 
&nbsp;
	Choice'</span>
&nbsp;
	<span style="color: #008000;"># Define Logic for Top Level Menu</span>
	<span style="color: #0000FF;">switch</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Read-Host</span> <span style="color: #800080;">$MenuTopLevel</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #804000;">1</span> <span style="color: #000000;">&#123;</span>fnUserSearchMenu<span style="color: #000000;">&#125;</span>
		<span style="color: #804000;">2</span> <span style="color: #000000;">&#123;</span>fnGroupSearchMenu<span style="color: #000000;">&#125;</span>
		<span style="color: #804000;">3</span> <span style="color: #000000;">&#123;</span>fnComputerSearchMenu<span style="color: #000000;">&#125;</span>
		<span style="color: #804000;">4</span> <span style="color: #000000;">&#123;</span>Exit<span style="color: #000000;">&#125;</span>
		default <span style="color: #000000;">&#123;</span><span style="color: #800000;">&quot;You have chosen an invalid option&quot;</span>; fnPause; fnADSearchMenu<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Function Definition: fnUserSearchMenu</span>
<span style="color: #0000FF;">Function</span> fnUserSearchMenu
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Display User Search Menu Question</span>
	<span style="color: #800000;">&quot; &quot;</span>
	<span style="color: #800000;">&quot;What type of user information would you like?&quot;</span>
&nbsp;
	<span style="color: #008000;"># Display User Search Menu</span>
	<span style="color: #800080;">$MenuUserSearch</span> <span style="color: pink;">=</span>
	<span style="color: #800000;">'
	[1] Summary of all users in the current domain
	[2] Return to the main menu
&nbsp;
	Choice'</span>
&nbsp;
	<span style="color: #008000;"># Define Logic for User Search Menu</span>
	<span style="color: #0000FF;">switch</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Read-Host</span> <span style="color: #800080;">$MenuUserSearch</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #804000;">1</span> <span style="color: #000000;">&#123;</span>
		  	<span style="color: #008000;">#Define LDAP Filter</span>
			<span style="color: #800080;">$LDAPFilter</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;(objectCategory=User)&quot;</span>
&nbsp;
		  	<span style="color: #008000;">#Call fnADSearchExecute</span>
		  	fnADSearchExecute
		  <span style="color: #000000;">&#125;</span>
		<span style="color: #804000;">2</span> <span style="color: #000000;">&#123;</span>
	    	fnADSearchMenu
		  <span style="color: #000000;">&#125;</span>
		default <span style="color: #000000;">&#123;</span><span style="color: #800000;">&quot;You have chosen an invalid option&quot;</span>; fnPause; fnADSearchMenu<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Function Definition: fnGroupSearchMenu</span>
<span style="color: #0000FF;">Function</span> fnGroupSearchMenu
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Display Group Search Menu Question</span>
	<span style="color: #800000;">&quot; &quot;</span>
	<span style="color: #800000;">&quot;What type of group information would you like?&quot;</span>
&nbsp;
	<span style="color: #008000;"># Display Group Search Menu</span>
	<span style="color: #800080;">$MenuGoupSearch</span> <span style="color: pink;">=</span>
	<span style="color: #800000;">'
	[1] Summary of all groups in the current domain
	[2] Return to main menu
&nbsp;
	Choice'</span>
&nbsp;
	<span style="color: #008000;"># Define Logic for Group Search Menu</span>
	<span style="color: #0000FF;">switch</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Read-Host</span> <span style="color: #800080;">$MenuGoupSearch</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #804000;">1</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #008000;"># Define LDAP Filter</span>
			<span style="color: #800080;">$LDAPFilter</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;(objectCategory=Group)&quot;</span>
&nbsp;
			<span style="color: #008000;">#Call fnADSearchExecute</span>
			fnADSearchExecute
		  <span style="color: #000000;">&#125;</span>
		<span style="color: #804000;">2</span> <span style="color: #000000;">&#123;</span>
			fnADSearchMenu
		  <span style="color: #000000;">&#125;</span>
		default <span style="color: #000000;">&#123;</span><span style="color: #800000;">&quot;You have chosen an invalid option&quot;</span>; fnPause; fnADSearchMenu<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Function Definition: fnComputerSearchMenu</span>
<span style="color: #0000FF;">Function</span> fnComputerSearchMenu
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Display Computer Search Menu Question</span>
	<span style="color: #800000;">&quot; &quot;</span>
	<span style="color: #800000;">&quot;What type of computer information would you like?&quot;</span>
&nbsp;
	<span style="color: #008000;"># Display Group Search Menu</span>
	<span style="color: #800080;">$MenuComputerSearch</span> <span style="color: pink;">=</span>
	<span style="color: #800000;">'
	[1] Summary of all computers in the current domain
	[2] Return to main menu
&nbsp;
	Choice'</span>
&nbsp;
	<span style="color: #008000;"># Define Logic for Group Search Menu</span>
	<span style="color: #0000FF;">switch</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Read-Host</span> <span style="color: #800080;">$MenuComputerSearch</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #804000;">1</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #008000;"># Define LDAP Filter</span>
			<span style="color: #800080;">$LDAPFilter</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;(objectCategory=Computer)&quot;</span>
&nbsp;
			<span style="color: #008000;">#Call fnADSearchExecute</span>
			fnADSearchExecute
		  <span style="color: #000000;">&#125;</span>
		<span style="color: #804000;">2</span> <span style="color: #000000;">&#123;</span>
			fnADSearchMenu
		  <span style="color: #000000;">&#125;</span>
		default <span style="color: #000000;">&#123;</span><span style="color: #800000;">&quot;You have chosen an invalid option&quot;</span>; fnPause; fnADSearchMenu<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Function Definition: fnADSearchExecute</span>
<span style="color: #0000FF;">Function</span> fnADSearchExecute
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;"># Define AD Search Filter</span>
	<span style="color: #800080;">$strFilter</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$LDAPFilter&quot;</span>
&nbsp;
	<span style="color: #008000;"># Define AD Location for Search</span>
	<span style="color: #800080;">$objDomain</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.DirectoryEntry
&nbsp;
	<span style="color: #008000;"># Define AD Search Parameters</span>
	<span style="color: #800080;">$objSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.DirectoryServices.DirectorySearcher
	<span style="color: #800080;">$objSearcher</span>.SearchRoot <span style="color: pink;">=</span> <span style="color: #800080;">$objDomain</span>
	<span style="color: #800080;">$objSearcher</span>.PageSize <span style="color: pink;">=</span> <span style="color: #804000;">1000</span>
	<span style="color: #800080;">$objSearcher</span>.<span style="color: #0000FF;">Filter</span> <span style="color: pink;">=</span> <span style="color: #800080;">$strFilter</span>
	<span style="color: #800080;">$objSearcher</span>.SearchScope <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Subtree&quot;</span>
&nbsp;
	<span style="color: #008000;"># Define AD Properties Returned by Search</span>
	<span style="color: #800080;">$colProplist</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;name&quot;</span>
	<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$colProplist</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$objSearcher</span>.PropertiesToLoad.Add<span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #008000;"># Execute AD Search</span>
	<span style="color: #800080;">$colResults</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objSearcher</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #008000;"># Format AD Search Results</span>
	<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objResult</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$colResults</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$objItem</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objResult</span>.Properties
		<span style="color: #800000;">&quot;Name: &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$objItem</span>.name
		<span style="color: #800000;">&quot; &quot;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Call ADSearch Menu Function</span>
fnADSearchMenu</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.raseley.com/2009/05/13/information-gathering-via-powershell-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deny Logoff of an Administrator Logged in to the Console Session</title>
		<link>http://www.raseley.com/2009/04/21/deny-logoff-of-an-administrator-logged-in-to-the-console-session/</link>
		<comments>http://www.raseley.com/2009/04/21/deny-logoff-of-an-administrator-logged-in-to-the-console-session/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 17:44:21 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Group Policy]]></category>

		<guid isPermaLink="false">http://www.raseley.com/?p=79</guid>
		<description><![CDATA[Here is a Group Policy setting you can apply in Active Directory to prevent an administrator or other user from logging you off from a machine that you have remotely logged into via the console session. Policy Path: Administrative Templates\Windows &#8230; <a href="http://www.raseley.com/2009/04/21/deny-logoff-of-an-administrator-logged-in-to-the-console-session/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is a Group Policy setting you can apply in Active Directory to prevent an administrator or other user from logging you off from a machine that you have remotely logged into via the console session.</p>
<p><strong>Policy Path:</strong> Administrative Templates\Windows Components\Terminal Services </p>
<p><strong>Supported On:</strong> At least Microsoft Windows Server 2003 </p>
<p><strong>Help/Explain Text:</strong> Specifies whether to allow an administrator attempting to connect to the console of a server to log off an administrator currently logged on to the console. The console session is also known as Session 0. Console access can be obtained by using the /console switch from Remote Desktop Connection in the computer field name or from the command line. If the status is set to Enabled, logging off the connected administrator is not allowed. If the status is set to Disabled, logging off the connected administrator is allowed. If the status is set to Not Configured, logging off the connected administrator is allowed but can be changed at the local computer policy level. This policy is useful when the currently connected administrator does not want to be logged off by another administrator. If the connected administrator is logged off, any data not previously saved is lost.  </p>
<p><strong>Registry Settings:</strong> HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services!fDisableForcibleLogoff </p>
]]></content:encoded>
			<wfw:commentRss>http://www.raseley.com/2009/04/21/deny-logoff-of-an-administrator-logged-in-to-the-console-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

