<?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>PhishThis! &#187; Server Management</title>
	<atom:link href="http://www.phishthis.com/category/server-management/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phishthis.com</link>
	<description></description>
	<lastBuildDate>Tue, 22 Feb 2011 05:48:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>How to configure AD, SQL, and IIS for two-hop Kerberos authentication</title>
		<link>http://www.phishthis.com/2009/10/24/how-to-configure-ad-sql-and-iis-for-two-hop-kerberos-authentication-2/</link>
		<comments>http://www.phishthis.com/2009/10/24/how-to-configure-ad-sql-and-iis-for-two-hop-kerberos-authentication-2/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 00:01:48 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Kerberos]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web service]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/?p=138</guid>
		<description><![CDATA[<p>Recently, some of our developers were writing an app that required impersonation from the web service, as the user, to the database. Admittedly, Kerberos isn&#8217;t one of my strong points.</p> <p>There were two hops here. From the user -&#62; IIS server and from IIS Server -&#62; SQL Server, but the application in IIS would [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, some of our developers were writing an app that required impersonation from the web service, as the user, to the database. Admittedly, <A class=zem_slink title="Kerberos (protocol)" href="http://en.wikipedia.org/wiki/Kerberos_%28protocol%29" rel=wikipedia>Kerberos</A> isn&#8217;t one of my strong points.</p>
<p>There were two hops here. From the user -&gt; IIS server and from IIS Server -&gt; SQL Server, but the application in IIS would impersonate the user when authenticating with the SQL server.</p>
<p>So, the idea here is that from the user to the IIS server, we know Kerberos will work. The user passes its ticket to the web service. Nothing unusual. From there, the web app, running as a custom app pool ID, needs to pretend (delegate) to be the user when it authenticates to the SQL server. </p>
<p>There are a few requirements.<br />
<strong>1) </strong>Your application in IIS should be running under a custom identity &#8211; domain\MyAppService<br />
<strong>2) </strong>SQL Server needs to be running under a domain service account &#8211; domain\MySQLService<br />
<strong>3)</strong> IIS needs to use Negotiate instead of NTLM for that application. It should do this by default, then fall back to NTLM. For whatever reason, my app was using NTLM. IIS should also have Windows Authentication enabled.<br />
<strong>4) </strong>Change your connection string to impersonate the site user</p>
<p><STRONG>Step 1</STRONG> &#8211; Set the SPN on your app pool ID for the site, for the hostname and FQDN.<br />
<CODE>setspn -a http/mysite domain\MyAppService<br />
setspn -a http/mysite.domain.com domain\MyAppService</CODE></p>
<p><STRONG>Step 2</STRONG> &#8211; Set the SPN for the SQL service on your SQL service account &#8211; assuming you use the default SQL port<br />
<CODE>setspn -a MSSQLSvc/hostname domain\MySQLService<br />
setspn -a MSSQLSvc/hostname.domain.com domain/MySQLService<br />
setspn -a MSSQLSvc/hostname:1433 domain\MySQLService<br />
setspn -a MSSQLSvc/hostname.domain.com:1433 domain/MySQLService</CODE><br />
Restart SQL</p>
<p><STRONG>Step 3</STRONG> &#8211; In Active Directory Users and Computers, find the service account, click the delegation tab, and trust it for delegation. You can set it for delegation to anywhere, or constrained delegation to the SPNs you&#8217;ll set for the SQL service account. </p>
<p><STRONG>Step 4</STRONG> &#8211; Force your site or application to use Negotiate. This won&#8217;t work with NTLM, so we&#8217;ll remove it. (Note: This is for IIS7/7.5)<br />
- Find and open your applicationHost.config. It&#8217;s probably under c:\windows\system32\inetsrv\config. You can also set this in the system.webServer section of the web.config for the application. </p>
<p>- Scroll to the bottom and above /configuration copy this in:</p>
<pre>
   &lt;location path=&quot;SitePath&quot;&gt;
        &lt;system.webServer&gt;
            &lt;security&gt;
                &lt;authentication&gt;
                    &lt;windowsAuthentication&gt;
                        &lt;providers&gt;
                            &lt;add value=&quot;Negotiate&quot; /&gt;
                            &lt;remove value=&quot;NTLM&quot; /&gt;
                        &lt;/providers&gt;
                    &lt;/windowsAuthentication&gt;
                &lt;/authentication&gt;
            &lt;/security&gt;
        &lt;/system.webServer&gt;
    &lt;/location&gt;
</pre>
<p>If you get a 500 error after adding the above XML, it&#8217;s probably because Negotiate is already added elsewhere. Just remove the line that says add value=&#8221;Negotiate&#8221; and leave the remove NTLM line. </p>
<p>Reference: This post was extremely helpful in solving my problem &#8211; <A href="http://blogs.technet.com/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx">http://blogs.technet.com/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx</A> &#8211; in the end, I did pretty much everything in that post, and still had the IIS server passing anonymous to SQL, which is what tipped me off that it was using NTLM and not Negotiate.</p>
<p><DIV style="MARGIN-TOP: 10px; HEIGHT: 15px" class=zemanta-pixie><A class=zemanta-pixie-a title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/fbffe8a7-8bb0-4ce5-9df2-afc98ab58ee0/"><IMG style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; FLOAT: right; BORDER-TOP: medium none; BORDER-RIGHT: medium none" class=zemanta-pixie-img alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=fbffe8a7-8bb0-4ce5-9df2-afc98ab58ee0"></A><SPAN class="zem-script more-related pretty-attribution"><SCRIPT type="text/javascript" defer="defer" src="http://static.zemanta.com/readside/loader.js"></SCRIPT></SPAN></DIV></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2009/10/24/how-to-configure-ad-sql-and-iis-for-two-hop-kerberos-authentication-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AjaxControlToolkit causes System.Security.SecurityException: Request for the permission of type &#8216;System.Web.AspNetHostingPermission &#8230; failed.</title>
		<link>http://www.phishthis.com/2009/03/11/ajaxcontroltoolkit-causes-systemsecuritysecurityexception-request-for-the-permission-of-type-systemwebaspnethostingpermission-failed/</link>
		<comments>http://www.phishthis.com/2009/03/11/ajaxcontroltoolkit-causes-systemsecuritysecurityexception-request-for-the-permission-of-type-systemwebaspnethostingpermission-failed/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 21:02:51 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[IIS7]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[System.Security.SecurityException]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/?p=84</guid>
		<description><![CDATA[<p>Here&#8217;s a quick one&#8230;</p> <p>A developer was using AJAXControlToolkit in an application. Not a big deal. Except that it kept throwing that damn exception. You know the one:</p> <p> Server Error in &#8221; Application. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick one&#8230;</p>
<p>A developer was using AJAXControlToolkit in an application. Not a big deal. Except that it kept throwing that damn exception. You know the one:</p>
<p><CODE><br />
Server Error in &#8221; Application.<br />
Security Exception<br />
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application&#8217;s trust level in the configuration file.</p>
<p>Exception Details: System.Security.SecurityException: Request for the permission of type &#8216;System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242; failed.<br />
</CODE></p>
<p>I know what you&#8217;re going to say, but I prefer to not use caspol.exe to set the trust. </p>
<p>There were several other sites on the server using the toolkit that worked fine, <B>without using caspol to set full trust</B>. </p>
<p>The difference? Those other applications were compiling the AJAX DLL when the apps themselves were compiled. The developer in this case had just copied the DLL from the toolkit download and added the reference to her code. </p>
<p>I copied the DLL from one of the sites that I knew worked, and it magically started working. Copy her version of the DLL back, and it failed again (after IISReset). </p>
<p>I don&#8217;t really know how this happened, but if the DLL was referenced in the VS project, it should have been built with the rest of the app and then deployed with full trust&#8230;</p>
<p>So, if you&#8217;re running into this and you&#8217;re building the code yourself, make sure that the AjaxControlToolkit.dll is building with the rest of your application (the timestamp should be the same) as the other DLLs that were modified. Don&#8217;t just drop it in afterwards&#8230;it won&#8217;t work&#8230;</p>
<p><DIV class=zemanta-pixie style="MARGIN-TOP: 10px; HEIGHT: 15px"><A class=zemanta-pixie-a title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/fdd8051e-f9fd-4550-9c8d-cd308ab24e44/"><IMG class=zemanta-pixie-img style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FLOAT: right; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none" alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=fdd8051e-f9fd-4550-9c8d-cd308ab24e44"></A><span class="zem-script more-related"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></DIV></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2009/03/11/ajaxcontroltoolkit-causes-systemsecuritysecurityexception-request-for-the-permission-of-type-systemwebaspnethostingpermission-failed/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>get-servernames.ps1 &#8211; Return a List of Computer Objects from Active Directory</title>
		<link>http://www.phishthis.com/2008/12/18/get-servernamesps1-return-a-list-of-computer-objects-from-active-directory/</link>
		<comments>http://www.phishthis.com/2008/12/18/get-servernamesps1-return-a-list-of-computer-objects-from-active-directory/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 18:00:36 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[get-servernames.ps1]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/?p=57</guid>
		<description><![CDATA[<p>I should have posted this a long, long time ago&#8230;but forgot. Until I got a comment from dvdor about it. </p> <p>In Active Directory, we set the &#8220;Managed By&#8221; field on all of the servers we manage to our primary, non-admin account. This makes it easy for people to find out who manages what [...]]]></description>
			<content:encoded><![CDATA[<p>I should have posted this a long, long time ago&#8230;but forgot. Until I got a comment from dvdor about it. </p>
<p>In Active Directory, we set the &#8220;Managed By&#8221; field on all of the servers we manage to our primary, non-admin account. This makes it easy for people to find out who manages what servers. It also makes it easy to do batch upgrades/file copies/whatever to your own servers. </p>
<p>This script, get-servernames.ps1, has a single parameter. -username. It just returns a text list of your servers&#8230;no objects or anything. I didn&#8217;t see the need, since all I wanted was the names.</p>
<p>Syntax: .\get-servernames.ps1 -username tmoser</p>
<p>Summary: Will take in your username (samaccountname) and first search AD for it. If found, it will search AD for all computer objects that have your account in the &#8220;Managed By&#8221; field. Those are returned in a list. </p>
<p>Uses: Things like: .\get-servernames.ps1 -username tmoser | foreach { copy-item C:\temp\somefile.txt \\$_\c$\temp\somefile.txt } </p>
<p>You can use it for error log checking, copying files, running remote psexec commands&#8230;anything, really. </p>
<pre>
param($username)

$root = new-object DirectoryServices.DirectoryEntry 'LDAP://dc=yourdomain,dc=com'
$searcher = new-object DirectoryServices.DirectorySearcher
$searcher.SearchRoot = $root
$searcher.Filter = "(samaccountname=$username)"

$results = $searcher.findOne()

if ($results -eq $null) {
	write-host -fore 'blue' -back 'white' "`"$($username)`" not found"
	exit(1)
}
else {
	$dn = $results.GetDirectoryEntry().distinguishedname
	$searcher.Filter = "(&#038;(samaccounttype=805306369)(managedby=$($dn)))"
	$servers = $searcher.FindAll()
		if ($($servers.count) -gt 0) {
			foreach ($server in $servers) { write-output "$($server.GetDirectoryEntry().cn)" }
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2008/12/18/get-servernamesps1-return-a-list-of-computer-objects-from-active-directory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerShell Script for Remote Event Log Viewing</title>
		<link>http://www.phishthis.com/2007/12/13/powershell-script-for-remote-event-log-viewing/</link>
		<comments>http://www.phishthis.com/2007/12/13/powershell-script-for-remote-event-log-viewing/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 04:27:52 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[PowerShell Script]]></category>
		<category><![CDATA[WMI]]></category>
		<category><![CDATA[WMI Query]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/12/13/powershell-script-for-remote-event-log-viewing/</guid>
		<description><![CDATA[Either way, I needed to check all of my event logs for EventID 11 and 15. [...]]]></description>
			<content:encoded><![CDATA[<p>I had an issue today where I needed to find the frequency of an error on some of my VMs. It seems like I get VMSCSI errors at the same time each which (which probably means high SAN activity, but I&#8217;m trying to nail everything down). Either way, I needed to check all of my event logs for EventID 11 and 15. It&#8217;s slow&#8230;and by slow I mean it took about 30 minutes to scan 10 or so VMs&#8230;but it works, and I was able to get a decent idea of the times I&#8217;m seeing these errors.<br />
[source language='c#']<br />
$servers = .\getservernames.ps1 Tom </p>
<p>foreach ($server in $servers)<br />
{<br />
     if ((get-wmiobject -computer $server win32_computersystem).manufacturer -eq &#8220;VMware, Inc.&#8221;)<br />
     {<br />
         get-wmiobject -query<br />
            &#8220;select * from Win32_NTLogEvent where LogFile = &#8216;System&#8217; AND EventCode = 11<br />
            OR EventCode = 15&#8243; |<br />
            foreach { add-content c:\temp\$server.log &#8220;$_.timegenerated &#8211; $_.eventcode&#8221; }<br />
     }<br />
}<br />
[/source]<br />
Aaaand, it&#8217;ll return logs for each server, with a time stamp, the event ID, and nothing more. Quick, dirty, but took me 5 minutes and got the info I needed&#8230;30 minutes later :p There&#8217;s probably a better way. I&#8217;ll have to see what I can come up with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/12/13/powershell-script-for-remote-event-log-viewing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Powershell 2.0 CTP &#8211; Remoting &#8211; PowerShell Remove WDS</title>
		<link>http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/</link>
		<comments>http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 22:47:07 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell 2.0 CTP]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShell Script]]></category>
		<category><![CDATA[Remove WDS Script]]></category>
		<category><![CDATA[scripting to uninstall wds]]></category>
		<category><![CDATA[WDS Removal]]></category>
		<category><![CDATA[WSUS WDS]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/</guid>
		<description><![CDATA[<p>So, with PowerShell 2.0 CTP&#8217;s arrival, and me finally having some time to mess around with some of the new features, here&#8217;s my previous (and first popular) post re-hashed for PowerShell 2.0 CTP. This will only work on machines with WS-Management installed, so it probably won&#8217;t work on most of your machines (unless you&#8217;ve deployed [...]]]></description>
			<content:encoded><![CDATA[<p>So, with PowerShell 2.0 CTP&#8217;s arrival, and me finally having some time to mess around with some of the new features, here&#8217;s my previous (and first popular) post re-hashed for PowerShell 2.0 CTP. This will only work on machines with WS-Management installed, so it probably won&#8217;t work on most of your machines (unless you&#8217;ve deployed it), but it works well in my little test world. It utilizes two new features. These features are the [ADSISearcher] and Invoke-Expression. Instead of creating all of the Directory Service objects each time, you can just cast the ASDISearcher type and you&#8217;re done. Invoke-Expression allows you to use the -computer parameter and pass one, or many, computers to the cmdlet. I chose to use a single command here.</p>
<p><code><br />
[adsisearcher]$searcher = "LDAP://dc=foo,dc=bar,dc=com"<br />
$searcher.filter = "(objectclass=computer)"<br />
foreach ($machine in ($searcher.findall()))<br />
{<br />
   invoke-expression -computer $machine.properties.cn -command "c:\windows\`$NtUninstallKB917013`$\spuninst\spuninst.exe /q /norestart"<br />
}</code></p>
<p>I haven&#8217;t had a chance to test it, but you could use mutiple computers. We could change the foreach loop to write to a text file, then read that file for the computer names.</p>
<p><code>...<br />
foreach ($machine in ($searcher.findall())){ add-content c:\temp\machines.txt "$($machine.properties.cn)" }<br />
invoke-expression -computer (get-content c:\temp\machines.txt) -command "c:\windows\`$NtUninstallKB917013`$\spuninst\spuninst.exe /q /norestart"<br />
</code></p>
<p>That&#8217;ll kick off on 50 machines at a time. You can adjust that via the -ThrottleLimit parameter, and make it more or less, depending on bandwidth, CPU power, etc.</p>
<p>As you can see, I tend to learn better by example or by practical application. You&#8217;ll never see me write a book :) More soon!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSUS/WDS Debacle</title>
		<link>http://www.phishthis.com/2007/10/30/wsuswds-debacle/</link>
		<comments>http://www.phishthis.com/2007/10/30/wsuswds-debacle/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 02:47:11 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[powershell psexec foreach]]></category>
		<category><![CDATA[PowerShell Script]]></category>
		<category><![CDATA[WDS]]></category>
		<category><![CDATA[Windows Desktop Search]]></category>
		<category><![CDATA[Windows Desktop Search Removal]]></category>
		<category><![CDATA[Windows Desktop Search Removal Script]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/10/30/wsuswds-debacle/</guid>
		<description><![CDATA[<p>I don&#8217;t understand the big issue with the accidental release of WDS (Windows Desktop Search) via WSUS (here). It wasn&#8217;t like MS said &#8220;Muhuhahaha, let&#8217;s release WDS  to the masses via WSUS!&#8221; I mean&#8230;why? There&#8217;s no compelling reason for this besides a simple mistake. Now, the fact that the mistake was made is a little scary. [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t understand the big issue with the accidental release of WDS (Windows Desktop Search) via WSUS (<a href="http://blogs.technet.com/wsus/archive/2007/10/25/wds-update-revision-follow-up.aspx">here</a>). It wasn&#8217;t like MS said &#8220;Muhuhahaha, let&#8217;s release WDS  to the masses via WSUS!&#8221; I mean&#8230;why? There&#8217;s no compelling reason for this besides a simple mistake. Now, the fact that the mistake was made is a little scary. I don&#8217;t want some blue-screen causing driver or security update released to 500 servers. That might wreck my month&#8230;no, year. Then again, how many critical servers are set to auto-update? Test and QA boxes, but never production, unless you&#8217;re load balanced (ie, IIS boxes), and can stagger update times. At least that&#8217;s how I see it&#8230;</p>
<p>Removal was pretty easy, too. Altiris works wonders. But, let&#8217;s say you don&#8217;t have Altiris. You could use (ready for this?) PowerShell. They provide the removal instructions on the WDS blog entry. Using another handy utility, <a href="http://www.microsoft.com/technet/sysinternals/Security/PsExec.mspx">PSEXEC</a>, you could very easily run a script to remove WDS. It might take a while, depending on the number of machines, but it&#8217;ll work&#8230;and without much effort.</p>
<p>For the sake of argument (and typing), let&#8217;s say it went to every box on your domain, server and desktop. This will only return 1,000 objects, so you&#8217;ll need to break it out by OU or some other method if you have more than that. Here&#8217;s my remove wds script (excuse the formatting&#8230;)</p>
<p><code><br />
$root = new-object DirectoryServices.DirectoryEntry<br />
$searcher = new-object DirectoryServices.DirectorySearcher<br />
$searcher.SearchRoot = $root<br />
$searcher.Filter = "(samaccounttype=805306369)"<br />
$machines = $searcher.FindAll()<br />
foreach ($machine in $machines)<br />
{<br />
  psexec.exe "\\$($machine.properties.cn)" -d - c:\windows\`$NtUninstallKB917013`$\spuninst\spuninst.exe /q /norestart<br />
  #run PSEXEC, execute sp uninstaller quietly, with no restart. PSEXEC will not wait for app to finish<br />
  #and will only wait 5 seconds before timing out when attempting to run the remote command<br />
}<br />
</code></p>
<p>Now, you&#8217;ve kicked off the task to remove the update from all of your machines&#8230;or 1,000 of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/10/30/wsuswds-debacle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get-ServerNames.ps1</title>
		<link>http://www.phishthis.com/2007/09/28/get-servernamesps1/</link>
		<comments>http://www.phishthis.com/2007/09/28/get-servernamesps1/#comments</comments>
		<pubDate>Sat, 29 Sep 2007 00:14:42 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/09/28/get-servernamesps1/</guid>
		<description><![CDATA[<p>Here&#8217;s the script I metioned a few days ago. I wrote this a while back (Pre-RC0, I think).</p> <p> Anyway, if you&#8217;ve got a bunch of servers that you need to perform a common task on (copy files, check event logs, etc), this is handy&#8230;however, it only works if you&#8217;ve got the Managed By field [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the script I metioned a few days ago. I wrote this a while back (Pre-RC0, I think).</p>
<p> Anyway, if you&#8217;ve got a bunch of servers that you need to perform a common task on (copy files, check event logs, etc), this is handy&#8230;however, it only works if you&#8217;ve got the Managed By field set in AD. Otherwise, you&#8217;re SOL. First, it makes sure the account name given exists in AD, then searches AD for and computer objects managed by that account. It uses write-output to return the list of servers. It outputs strings, not objects, since that&#8217;s all I needed out of it.</p>
<p>Syntax is: .\get-servernames.ps1 &lt;samaccountname&gt;</p>
<pre>
$root = new-object DirectoryServices.DirectoryEntry 'LDAP://dc=foo,dc=bar,dc=com'
$searcher = new-object DirectoryServices.DirectorySearcher
$searcher.SearchRoot = $root
$searcher.Filter = "(samaccountname=$($args[0]))"
$results = $searcher.findOne()
if ($results -eq $null) {
 write-host -fore 'blue' -back 'white' "`"$($args[0])`" not found"
 exit(1)
}
else {
 $dn = $results.GetDirectoryEntry().distinguishedname
 $searcher.Filter = "(&amp;(samaccounttype=805306369)(managedby=$($dn)))"
 $servers = $searcher.FindAll()
  if ($($servers.count) -gt 0) {
   foreach ($server in $servers) { write-output "$($server.GetDirectoryEntry().cn)" }
 }
}
</pre>
<p><font face="Georgia">As I mentioned, this is pretty handy for copying files to groups of servers, checking error logs via <a href="http://www.microsoft.com/technet/sysinternals/Security/PsLogList.mspx">psloglist</a>, doing inventory, and more. </font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/09/28/get-servernamesps1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Script for Server Hardware Updates</title>
		<link>http://www.phishthis.com/2007/09/25/powershell-script-for-server-hardware-updates/</link>
		<comments>http://www.phishthis.com/2007/09/25/powershell-script-for-server-hardware-updates/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 00:38:59 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/?p=6</guid>
		<description><![CDATA[<p>No. This script doesn&#8217;t do the updates for you, as awesome as that would be. I have a bunch of boxes that I have to do firmware updates on tonight. Apparently the Dell PERC4 has an issue on a certain firmware revision that will cause arrays of 5 or more disks in RAID 5 [...]]]></description>
			<content:encoded><![CDATA[<p>No. This script doesn&#8217;t do the updates for you, as awesome as that would be. I have a bunch of boxes that I have to do firmware updates on tonight. Apparently the Dell PERC4 has an issue on a certain firmware revision that will cause arrays of 5 or more disks in RAID 5 or 50 to fail during rebuild after replacing a failed disk (and I have a disk to replace). My array isn&#8217;t 5 disks but I&#8217;m playing it safe, as this is a production server. So, I thought &#8220;I don&#8217;t want to have to hit this from a file share tonight, or have to copy it tonight&#8230;&#8221; Go go lazy powers. I wanted to copy this to all of my DELL boxes, but not the VMs or HP machines. Enter, PowerShell.</p>
<pre>
 .\get-servernames.ps1 &lt;samname&gt;
  | foreach {
      if ((get-wmiobject -computer $_ win32_computersystem).manufacturer -contains "*Dell*") {
         copy-item c:\SUU \\$_\c$\suu -recurse -force
    }
}
</pre>
<p>More on get-servernames.ps1 later. But, now my SUU is on all of the servers and waiting for me tonight. I kicked it off and went home. And excuse the formatting, the layout is a work in progress!</p>
<blockquote></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/09/25/powershell-script-for-server-hardware-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

