<?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>yakk0.org &#187; active directory</title>
	<atom:link href="http://www.yakk0.org/tag/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yakk0.org</link>
	<description>a blog on technology in the real world</description>
	<lastBuildDate>Thu, 05 Jan 2012 03:40:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PowerShell: Add printers to DNS</title>
		<link>http://www.yakk0.org/2010/03/08/powershell-add-printers-to-dns/</link>
		<comments>http://www.yakk0.org/2010/03/08/powershell-add-printers-to-dns/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 20:55:52 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.yakk0.org/?p=281</guid>
		<description><![CDATA[I realized today that most of our printers at work did not have DNS entries. This isn’t a big problem for users because they’re on our print server and they get their printers through Group Policy. The Print server has each printer set up to the IPs. We just implemented a management system today, and [...]]]></description>
			<content:encoded><![CDATA[<p>I realized today that most of our printers at work did not have DNS entries. This isn’t a big problem for users because they’re on our print server and they get their printers through Group Policy. The Print server has each printer set up to the IPs. We just implemented a management system today, and it lists the printers by IP and because the DNS entries were “Unknown” for most of them, it wasn’t easy to determine what printer we were looking at.</p>
<p>I found several PowerShell examples on the web for interacting with Microsoft DNS servers, and took a bit from each to come up with this script. It takes the shared printer name and publishes that as the DNS name. This does cause a problem if you have spaces in a share name, but our environment doesn’t, so I didn’t program for that issue.</p>
<p>Here’s the script:</p>
<p><span id="more-281"></span></p>
<p style="font-family: consolas,lucida console; background: #fcfcfc; font-size: 8pt; padding: 5px;"><span style="color: #00008b;">Function</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">Add-ARecord</span><br />
<span style="color: #000000;">{</span><br />
<span style="color: #000000;"> </span><span style="color: #0000ff;">Write-Host</span><span style="color: #000000;"> </span><span style="color: #000080;">-ForegroundColor</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">DarkCyan</span><span style="color: #000000;"> </span><span style="color: #8b0000;">"Importing Printer information"</span><br />
<span style="color: #000000;"> </span><span style="color: #006400;"># Imports all printers from Print Server</span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$printers</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">(</span><span style="color: #0000ff;">get-WmiObject</span><span style="color: #000000;"> </span><span style="color: #000080;">-class</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$Class</span><span style="color: #000000;"> </span><span style="color: #000080;">-computername</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$printSvr</span><span style="color: #000000;">)</span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$Arecord</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #008080;">[WmiClass]</span><span style="color: #8b0000;">"\\$dnsSvr\root\MicrosoftDNS:MicrosoftDNS_AType"</span><span style="color: #000000;"> </span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$class</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> </span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$ttl</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">3600</span><span style="color: #000000;"> </span><span style="color: #006400;"># Time-To-Live in seconds</span><br />
<span style="color: #000000;"> </span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$printers</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">|</span><span style="color: #000000;"> </span><span style="color: #0000ff;">ForEach-Object</span><span style="color: #000000;">{</span><br />
<span style="color: #000000;"> </span><span style="color: #0000ff;">Get</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">the</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">name</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">of</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">the</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">Shared</span><span style="color: #000000;"> </span><span style="color: #8a2be2;">Printer</span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$name</span><span style="color: #000000;"> </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;">ShareName</span><span style="color: #000000;"> </span><br />
<span style="color: #000000;"> </span><span style="color: #006400;"># Get IP information from TCP/IP port</span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$address</span><span style="color: #000000;"> </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;">portname</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Replace</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"IP_"</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;"> </span><span style="color: #8b0000;">""</span><span style="color: #000000;">)</span><span style="color: #000000;"> </span><span style="color: #000000;"> </span><span style="color: #006400;"># output variables for testing</span><br />
<span style="color: #000000;"> </span><span style="color: #006400;">#write-host -ForegroundColor Yellow $server, $zone, $name, $class, $ttl, $address </span><br />
<span style="color: #000000;"> </span><br />
<span style="color: #000000;"> </span><span style="color: #006400;"># create DNS A Records</span><br />
<span style="color: #000000;"> </span><span style="color: #ff4500;">$Arecord</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">CreateInstanceFromPropertydata</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$server</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$zone</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$name</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$class</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$ttl</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;"> </span><span style="color: #ff4500;">$address</span><span style="color: #000000;">)</span><span style="color: #000000;"> </span><br />
<span style="color: #000000;"> </span><span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span></p>
<p><span style="color: #ff4500;">$Class</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #8b0000;">"win32_printer"</span><span style="color: #000000;"> </span><span style="color: #006400;"># WMI class for printers</span><br />
<span style="color: #006400;"># Change to suit your environment</span><br />
<span style="color: #ff4500;">$printSvr</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #8b0000;">"printsvr"</span><span style="color: #000000;"> </span><span style="color: #006400;"># Print server</span><br />
<span style="color: #ff4500;">$dnsSvr</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #8b0000;">"dnssvr"</span><span style="color: #000000;"> </span><span style="color: #006400;"># DNS Server</span><br />
<span style="color: #ff4500;">$zone</span><span style="color: #000000;"> </span><span style="color: #a9a9a9;">=</span><span style="color: #000000;"> </span><span style="color: #8b0000;">"dnszone"</span><span style="color: #000000;"> </span><span style="color: #006400;"># DNS Zone</span></p>
<p><span style="color: #0000ff;">Add-ARecord</span></p>
<p>[edit] A couple people left comments that this didn't work for them, and I was unable to get it to work for me again. I swear it worked the day I needed it. If anyone can tell me why it doesn't work now, I'd appreciate it.</p>
<p style="font-family: consolas,lucida console; background: #fcfcfc; font-size: 8pt; padding: 5px;">
]]></content:encoded>
			<wfw:commentRss>http://www.yakk0.org/2010/03/08/powershell-add-printers-to-dns/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fixing IT problems with a hammer</title>
		<link>http://www.yakk0.org/2009/11/20/fixing-it-problems-with-a-hammer/</link>
		<comments>http://www.yakk0.org/2009/11/20/fixing-it-problems-with-a-hammer/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 19:35:40 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.yakk0.org/2009/11/20/fixing-it-problems-with-a-hammer/</guid>
		<description><![CDATA[In a continuing process of cleaning up horrible decisions by our predecessors, we just moved a website off one of our domain controllers. The website was moving from IIS6 to 7 (or 7.5, whatever comes with Server 2008 R2), and it required some tweaking to start working again. One of the parts that didn’t work [...]]]></description>
			<content:encoded><![CDATA[<p>In a continuing process of cleaning up horrible decisions by our predecessors, we just moved a website off one of our domain controllers. The website was moving from IIS6 to 7 (or 7.5, whatever comes with Server 2008 R2), and it required some tweaking to start working again. One of the parts that didn’t work was a self-help page where teachers could unlock student accounts. I set up this web server, and created a service account for it that doesn’t have any special rights on the domain. Because the website runs in IIS as this service account, it could query the domain with no problems, but it didn’t have the rights to unlock accounts. </p>
<p>This is obviously where I differ from a coworker…</p>
<blockquote><p>him: “Just add the service account to Domain Admins”</p>
<p>me: “Why would I want to do that?”</p>
</blockquote>
<p>In the end I remembered I can delegate just the permissions needed to unlock our student accounts to that service account and it works fine. </p>
<p>Why use a hammer when you only need a tiny screwdriver?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yakk0.org/2009/11/20/fixing-it-problems-with-a-hammer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One line administration – search and delete computer accounts</title>
		<link>http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/</link>
		<comments>http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/#comments</comments>
		<pubDate>Wed, 06 May 2009 19:02:29 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/</guid>
		<description><![CDATA[Here’s a quick one-line script I’ve been using to clean up some old computer accounts in active directory. It requires the dsquery and dsrm tools from the Server 2003 Admin Pack or the Remote Server Administration Toolkit. @for /f %%a in ('DSQUERY COMPUTER -NAME *%1') do (dsrm %%a) Save that in as a batch file [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">Here’s a quick one-line script I’ve been using to clean up some old computer accounts in active directory. It requires the dsquery and dsrm tools from the Server 2003 Admin Pack or the Remote Server Administration Toolkit.</p>
<pre>
<span style="color: #008000;"><strong><em>@for /f %%a in ('DSQUERY COMPUTER -NAME *%1') do (dsrm %%a)</em></strong></span></pre>
<p align="justify">Save that in as a batch file and it’ll query Active Directory for computers including the argument passed.  Here’s an example with a naming structure where we have the last 4 digits of the MAC address in the name for uniqueness.</p>
<pre><span style="color: #008000;"><strong><em>C:\&gt;adrm.cmd 6736
C:\&gt;(dsrm "CN=LABPC6736,OU=Labs,DC=yakk0,DC=org" )
Are you sure you wish to delete CN=LABPC6736,OU=Labs,DC=yakk0,DC=org (Y/N)? y
dsrm succeeded:CN=LABPC6736,OU=Labs,DC=yakk0,DC=org</em></strong></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yakk0.org/2009/05/06/one-line-administration-search-and-delete-computer-accounts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 63/69 queries in 0.033 seconds using disk: basic

Served from: www.yakk0.org @ 2012-02-05 07:27:46 -->
