<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Quick and Dirty Scripting</title>
	<atom:link href="http://quickanddirtyscripting.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://quickanddirtyscripting.wordpress.com</link>
	<description>A place for IT Pros to find assistance to automate their daily tasks</description>
	<lastBuildDate>Thu, 17 Feb 2011 12:17:18 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='quickanddirtyscripting.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Quick and Dirty Scripting</title>
		<link>http://quickanddirtyscripting.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://quickanddirtyscripting.wordpress.com/osd.xml" title="Quick and Dirty Scripting" />
	<atom:link rel='hub' href='http://quickanddirtyscripting.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Google vs. Microsoft</title>
		<link>http://quickanddirtyscripting.wordpress.com/2010/11/30/google-vs-microsoft/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2010/11/30/google-vs-microsoft/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 04:44:19 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Cloud]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/?p=57</guid>
		<description><![CDATA[I recently started a comparison chart between Google and Microsoft. It mainly concerns their cloud offering but I&#8217;ve included some old school applications as well. I&#8217;ll be updating the post as I learn more about each&#8217;s services and add my own thoughts as well. If I&#8217;m missing something or if anyone had some thoughts please [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=57&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently started a comparison chart between Google and Microsoft. It mainly concerns their cloud offering but I&#8217;ve included some old school applications as well.  I&#8217;ll be updating the post as I learn more about each&#8217;s services and add my own thoughts as well. If I&#8217;m missing something or if anyone had some thoughts please let me know!</p>
<div>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td></td>
<td>Google</td>
<td>Microsoft</td>
</tr>
<tr>
<td>Free Web Applications</td>
<td>Search<br />
Gmail<br />
Picasa<br />
Maps<br />
Sites<br />
Google Docs<br />
Google Calendar<br />
Google Talk<br />
N/A<br />
Google Video /   YouTube<br />
Buzz<br />
Google Voice</td>
<td>Bing<br />
Hotmail<br />
Live Photo Gallery<br />
Bing Maps<br />
N/A<br />
Docs.com<br />
Live Calendar<br />
Live Messenger<br />
SkyDrive / Live   Mesh<br />
N/A<br />
N/A<br />
N/A</td>
</tr>
<tr>
<td>Business Web Applications</td>
<td>Google Apps for Domains</p>
<ul>
<li>Free for first 50 users</li>
<li>DocVerse + Office</li>
<li>Google Docs</li>
<li>Sites / Calendar</li>
<li>Gmail</li>
<li>Google Voice (TBD)</li>
</ul>
</td>
<td>Office 365 (Closed Beta)</p>
<ul>
<li>$$$$$</li>
<li>On Premise Office 2010</li>
<li>Office Web Apps</li>
<li>SharePoint Online</li>
<li>Exchange Online</li>
<li>Linc Server Online</li>
</ul>
</td>
</tr>
<tr>
<td>Platform as a Service</td>
<td>Google App Engine</p>
<ul>
<li>N/A</li>
<li>Languages: Java and Python</li>
<li>Relation Database: Hosted SQL with GAE for Business</li>
<li>Datastore: BigTable</li>
<li>Authentication: Integrates with Google Accounts</li>
<li>Services: Memcache, Mail, Scheduled Tasks</li>
<li>Frameworks: Spring and Django (with mods)</li>
<li>N/A</li>
</ul>
</td>
<td>Azure</p>
<ul>
<li>VM from On-Premise (TBD)</li>
<li>Languages: C#, VB.NET, IronRuby, IronPython, PHP</li>
<li>Relational Database: SQL Azure</li>
<li>Datastore: Tables, Blobs, and Queues</li>
<li>Authentication: SAML but must be handled by developer</li>
<li>Services:  Web Role, Worker Role, AppFabric  Service Bus</li>
<li>Frameworks: ASP.NET MVC, PHP Zend</li>
<li>Ability to remote login to running instance</li>
</ul>
</td>
</tr>
<tr>
<td>Mobile OS</td>
<td>Android</td>
<td>Windows Phone 7</td>
</tr>
<tr>
<td>Client OS</td>
<td>Chrome OS (TBD)</td>
<td>Windows 7</td>
</tr>
<tr>
<td>Server OS</td>
<td>N/A</td>
<td>Windows 2008 R2 Server</td>
</tr>
<tr>
<td>Browser</td>
<td>Chrome</td>
<td>IE 9 Beta</td>
</tr>
<tr>
<td>On-Premise Software</td>
<td>N/A</td>
<td>SharePoint Server<br />
Exchange Server<br />
Linc Server<br />
Hyper-V<br />
Active Directory<br />
SQL Server<br />
BizTalk Server</td>
</tr>
<tr>
<td>On-Premise Search</td>
<td>Google search appliance</td>
<td>FAST Search for SharePoint</td>
</tr>
</tbody>
</table>
<ul>
<li>Update 001 &#8211; 12/1/2010: Added Google Search Appliance and FAST Search</li>
<li>Update 002 &#8211; 12/3/2010: Added updates to GAE that Google recently release</li>
</ul>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=57&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2010/11/30/google-vs-microsoft/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>Claims Based Authentication with SharePoint 2007</title>
		<link>http://quickanddirtyscripting.wordpress.com/2010/06/24/claims-based-authentication-with-sharepoint-2007/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2010/06/24/claims-based-authentication-with-sharepoint-2007/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 04:28:28 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[iis]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">https://quickanddirtyscripting.wordpress.com/2010/06/24/claims-based-authentication-with-sharepoint-2007/</guid>
		<description><![CDATA[I was recently tasked with enabling our SharePoint farm with Claims Based Authentication. It was a fun challenge as I never worked with the technology before.&#160; There is a lot to Claims and I don’t want to go into too much depth on the benefit as there are plenty of good blogs already out there.&#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=52&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was recently tasked with enabling our SharePoint farm with Claims Based Authentication. It was a fun challenge as I never worked with the technology before.&#160; There is a lot to Claims and I don’t want to go into too much depth on the benefit as there are plenty of good blogs already out there.&#160; If you are completely new to Claims then this <a href="http://blogs.technet.com/b/dmitrii/archive/2009/10/02/claims-based-authentication-part-i.aspx">article</a> should be a good starting point. </p>
<p>Microsoft has released both a <a href="http://go.microsoft.com/fwlink/?LinkId=148503">Step-by-Step Guide</a> to get SharePoint 2007 working with Claims as well as a <a href="http://msdn.microsoft.com/en-us/library/ff646913.aspx">MSDN article</a>.&#160; Personally, I found both of these lacking in detail for my situation and the goal of this post is to fills in the gaps left by these two other articles.&#160; A lot of the Microsoft documentation focused on either Windows 2008 or in single server farm, which didn’t fit my environment.&#160; Hopefully this posting will help others who would like to try Claims out.</p>
<h3>Prerequisites</h3>
<p>There are several prerequisites that are required before we get started. They are.</p>
<ol>
<li>ADFS v2 running on Windows 2008 R2. I didn’t set this up but my co-worker followed the Step-By-Step Guide linked above </li>
<li>SharePoint 2007 SP2 or SharePoint Services 3.0 SP2 or later </li>
<li>Windows 2003 R2 SP2 </li>
<li>.NET Framework 3.5 SP1 </li>
<li>An extended Web Application that is either in the Internet or Extranet Zone </li>
<li>A SSL certificate for the extended Web Application installed on all WFE servers and in IIS. </li>
<li>winhttpcertcfg.exe &#8211; <a title="http://www.microsoft.com/downloads/details.aspx?familyid=c42e27ac-3409-40e9-8667-c748e422833f&amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?familyid=c42e27ac-3409-40e9-8667-c748e422833f&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=c42e27ac-3409-40e9-8667-c748e422833f&amp;displaylang=en</a> </li>
<li>The STS Signing Certificate for the resource domain. You need to get this from your ADFS/Domain Admin.&#160; Install this into the Local Machine’s Trusted People store on all Web Front End servers. </li>
<li>The URL of the STS server, typically the ADFSv2 system. Obtain exact location from your friendly ADFS/Domain Administrator </li>
</ol>
<p>One of the most frustrated things with Claims is that the Windows Identity Foundation client that is a required component is not built for a scaled out SharePoint farm.&#160; To fix this, Microsoft provides source code for the RSACookieTransformLibrary.&#160; The issue is that their link in their MSDN article doesn’t work. I had to track down our TAM to get me the code.&#160; I am not sure if I can redistribute it or not (I need to ask our TAM) so in the mean time, you can always post a comment on this blog and I’ll try to get it to you.&#160; </p>
<p>After you get the code you have to change only one line, enable Assembly Signing (so it can be placed into the GAC), and Compile.&#160; You will need the WIF Client and the WIF SDK in order to compile. My exact steps were:</p>
<ol>
<li>Download and install <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=be4db6a0-b76d-446d-810c-ea3c25b3969a&amp;displaylang=en#filelist">WIF Client</a> (for Windows 2003 x86 only) on system </li>
<li>Download and install <a href="http://www.microsoft.com/downloads/details.aspx?familyid=C148B2DF-C7AF-46BB-9162-2C9422208504&amp;displaylang=en">WIF SDK</a> on system </li>
<li>Download RsaCookieTransformLibrary Zip File </li>
<li>Extract Zip File </li>
<li>Open in Visual Studio </li>
<li>Select the Common name for the Claim&#8217;s enable WebApplication SSL certificate , created earlier </li>
<li>Open the file RSAEncryptedSessionSecurityTokenHandler.cs </li>
<li>Replace &#8216;YourUniqueCertificateSubjectName to with Common Name copied from Step 6
<ol>
<li>Be aware. At first, I only thought this would be something like “CN=claims.example.com”. But it turns out for my certificate, the subject name was something like &quot;CN=claims.example.com, OU=Example, O=Example, L=Chicago, S=IL, C=US&quot; </li>
<li>I had to write a small console application to walk through what the Subject was </li>
</ol>
</li>
<li>Go to the Property Page of the Project </li>
<li>Select the Signing Tab &gt; Check the Sign the Assembly box </li>
<li>Click New for strong name &gt; Key Name: RsAEncryptedSessionSecurityTokenHandler &gt; Deselect Protect my key file . . . </li>
<li>Compile the code </li>
<li>Save the dll for later use </li>
</ol>
<p>There is one more piece of code that you must write before you can start configuring Claims. By default, ADFSv2 signs all of their messages with a SHA-256 bit key.&#160; Windows 2003 by default doesn’t support that but you can enable it.&#160; To do so, you have to create a console based application that calls one function. Why Microsoft didn’t include this by default is beyond me.</p>
<p>The console code is something like:</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Linq;
<span class="kwrd">using</span> System.Text;
<span class="kwrd">using</span> Security.Cryptography;

<span class="kwrd">namespace</span> RegisterSHA256_Hashing
{
    <span class="kwrd">class</span> RegisterSHA256
    {
        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
        {
            Console.WriteLine(<span class="str">&quot;Going to regiter SHA-256 on this computer . . .&quot;</span>);
            Oid2.RegisterSha2OidInformationForRsa();
            Console.WriteLine(<span class="str">&quot;Done . . .&quot;</span>);
        }
    }
}</pre>
<p><p>Create a new console application, code the code, compile and xcopy it to all of your Web Front End Servers.</p>
<p>PHEW! Finally, we are not ready to install and configure Claims-Based authentication. Each of the steps below need to be run on each SharePoint web front end server so do one then rinse and repeat.</p>
<h3>Install Windows Identity Foundation Client</h3>
<ol>
<li>Get the appropriate WIF client for your platform from <a title="http://www.microsoft.com/downloads/details.aspx?FamilyID=be4db6a0-b76d-446d-810c-ea3c25b3969a&amp;displaylang=en#filelist" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=be4db6a0-b76d-446d-810c-ea3c25b3969a&amp;displaylang=en#filelist">http://www.microsoft.com/downloads/details.aspx?FamilyID=be4db6a0-b76d-446d-810c-ea3c25b3969a&amp;displaylang=en#filelist</a> </li>
<li>Run the downloaded exe </li>
<li>Next &gt; Accept EULA &gt; Finish </li>
</ol>
<h3>Install Federation Extensions for SharePoint 3.0</h3>
<ol>
<li>Download Microsoft-Federation-Extensions-For-SharePoint3.0.msi from <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8e7b6d99-991e-44fc-a74e-9adb152ddc37">http://www.microsoft.com/downloads/details.aspx?FamilyID=8e7b6d99-991e-44fc-a74e-9adb152ddc37</a> </li>
<li>Run the downloaded MSI </li>
<li>Agree to EULA &gt; Install </li>
</ol>
<h3>Register SHA256</h3>
<ol>
<li>Copy the RegisterSH256_Hashing command line application to the server created earlier </li>
<li>Double click on the icon </li>
</ol>
<h3>RSA Cookie Transform Library</h3>
<ol>
<li>Copy the RSACookieTransformLibrary.dll to the GAC </li>
<li>Note the Public Key Token </li>
</ol>
<h3>Federation Utility for SharePoint 3.0</h3>
<ol>
<li>Run the Federation Utility from the Start Menu </li>
<li>Select Browse &gt; Select the web.config file for the Central Administration ( C:\inetpub\wwwroot\wss\VirtualDirectories\%SiteId\web.conifg ) </li>
<li>If this server is not hosting the Central Administration Web Site, select the web.config for the extended Web Application&#8217;s default zone </li>
<li>Next </li>
<li>Application Configuration Location &gt; Browse &gt; Select the web.config for the extended application create way up in the Prerequisites </li>
<li>Application URL : Enter the Url of the Extended Web Application </li>
<li>SharePoint Security Zone : Internet or Extranet depending on how the Web Application was configured </li>
<li>Select Cookie Expiration </li>
<li>Enter your STS location in the form of something similar to <a href="https://sts.example.com/FederationMetadata/2007-06/FederationMetadata.xml">https://sts.example.com/FederationMetadata/2007-06/FederationMetadata.xml</a> </li>
<li>Click Test Location to confirm. </li>
<li>Select ‘Schedule a task to perform daily …’ then Next. This will contact the STS server for any updates to its configuration </li>
<li>Enable certificate chain if this is for production, otherwise leave this as the default &gt; Next </li>
<li>Select ‘No Encryption’ if using SSL &gt; Next &gt; Next &gt; Finish </li>
<li>Enter a password of the user account to run your scheduled task. This is just a standard Windows Task so it can be updated later </li>
</ol>
<h3>Last Steps</h3>
<ol>
<li>Allow your application pool account for the web application access to the certificate key store. You do this by using winhttpcertcfg as such &#8211; cmd.exe /c Winhttpcertcfg -g -A Example\$appPoolAccount -c LOCAL_MACHINE\My -s $subject_of_certificate </li>
<li>Add&#160; the following&#160; to the &lt;Microsoft.IdentityModel&gt;&lt;service&gt; section of Web.config file of the extended web application </li>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">securityTokenHandlers</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">remove</span> <span class="attr">type</span><span class="kwrd">=&quot;Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">type</span>=&quot;<span class="attr">RsaCookieTransform</span>.<span class="attr">RsaEncryptedSessionSecurityTokenHandler</span>, <span class="attr">RsaCookieTransformLibrary</span>, <span class="attr">Version</span>=<span class="attr">1</span>.<span class="attr">0</span>.<span class="attr">0</span>.<span class="attr">0</span>, <span class="attr">Culture</span>=<span class="attr">neutral</span>, <span class="attr">PublicKeyToken</span>=&amp;<span class="attr">lt</span>;<span class="attr">tobefilledin</span><span class="kwrd">&gt;</span>&quot; <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">securityTokenHandlers</span><span class="kwrd">&gt;</span></pre>
</ol>
<ol></ol>
<ul>
<li>Replace &lt;tobefilledin&gt; with Public Key Token copied that you copied when you installed the dll to the GAC </li>
</ul>
<p>After all that, you can now follow the Step-by-Step guide. The guide will walk you through how to add users from the accounts domain to your SharePoint site. Typically this is done by using an email address.&#160; Once you get everything setup, its pretty sweet. Its just a long and winding road to get that.</p>
<p>&#160;</p>
<h3>Common Errors</h3>
<p>One last thing before I wrap up.&#160; There were a few errors that I encountered when installing this that I wanted to post with my solutions to assist others as they work their way through this.</p>
<ol>
<li>Error ID2002. Stsadm failed – I received this when I ran the Federation Utility on my second WFE.&#160; This is because the Provisioning timer job wasn’t deleted after the utility ran on the first WFE.&#160; The solution was to use the Central Administration to delete the ‘Provisioning Web Application timer job’ before running the utility on the second WFE </li>
<li>Unexpected Error has occurred &#8211; [CryptographicException: The system cannot find the file specified.]. I received this error before I ran the winhttpcertcfg utility.&#160; This is due to the AppPool service account not being able to load its profile. It needs its profile loaded so it can read the certificate store so that it can encrypt/decrypt/hash messages back and forth to ADFS </li>
<li>Failed to Execute URL System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.BeginExecuteUrl(String url, String method, String childHeaders, Boolean sendHeaders – This was a nasty error that took me a while to figure out the cause. There isn’t a lot of information on the Internet concerning this error and what little is out there, mainly concerns either IIS7 or a custom ASP.NET application. Turns out this error doesn’t have anything to do with your SharePoint setup. At least in my cause it was because ADFS was mapping claims from the account domain to unused roles in our resource domain. After we went back to the Step-By-Step guide and followed their ADFS setups it fixed our last issue. </li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=52&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2010/06/24/claims-based-authentication-with-sharepoint-2007/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>MSDeploy with IIS6</title>
		<link>http://quickanddirtyscripting.wordpress.com/2010/03/21/msdeploy-with-iis6/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2010/03/21/msdeploy-with-iis6/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 18:47:36 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[iis]]></category>
		<category><![CDATA[msdeploy]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2010/03/21/msdeploy-with-iis6/</guid>
		<description><![CDATA[One of the most common tasks an IIS admin can do (besides installing IIS and who really is still doing that if you’re doing virtualization) is to deploy code given to us by the developers.&#160; In the olden days, this wasn’t too hard. You where given a batch file or maybe an MSI and you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=51&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the most common tasks an IIS admin can do (besides installing IIS and who really is still doing that if you’re doing virtualization) is to deploy code given to us by the developers.&#160; In the olden days, this wasn’t too hard. You where given a batch file or maybe an MSI and you ran it on the one server that supported the applications.&#160; But now, most applications have 2,3 or more servers that need to be worked on.&#160; I’m a lazy admin. I hate doing things more than once so I was always looking for a way to sync multiple IIS servers. For a long time if you were using MS technologies, you had to either use nant or roll your own solution.&#160; Some continued to use AppCenter 2000 but that’s a decade old!&#160; Enter msdeploy.</p>
<p>I know that there are a lot of other blog posts out there on the Internet concerning Microsoft&#8217;s new deployment tool called Msdeploy, but most concern how it can be used with IIS7 applications. This isn&#8217;t surprising since it was really made for IIS7 and only really intended to interact with IIS6 so that you can migrate from IIS6 to IIS7. Well, it does a great job of synchronizing IIS6 applications as well! </p>
<p>All that you need to do is install MSdeploy on each server, enable the remote service &#8211; net start msdepsv &#8211; and simple command line like this: </p>
<ul>
<li><font color="#0000ff">msdeploy -verb:sync -source:metakey=lm/w3svc/1 -dest:metakey=lm/w3svc/1,computername=Server1</font> </li>
</ul>
<p>This will sync the files, AppPools, and IIS settings for your application. You can see all dependencies that will be sync via:</p>
<ul>
<li><font color="#0000ff">msdeploy.exe -verb:getDependencies,alltrigger -source:metakey=lm/w3svc/1</font> </li>
</ul>
<p>This is awesome stuff but there is one thing that was always missing from the list of dependencies for my applications.&#160; And that was my GACed DLLs.&#160; There isn’t a way for msdeploy to know if a assembly in the GAC is used by your application or not automatically.&#160; The good thing is that Microsoft does give you the ability to sync GACed DLLs by running the following two commands:</p>
<ul>
<li><font color="#0000ff">msdeploy -verb:dump -source:gacAssembly=&quot;MyTestAssembly&quot; </font></li>
<li><font color="#0000ff">msdeploy -verb:sync -source:gacassembly=&quot;MyTestAssembly&quot; -dest:metakey=lm/w3svc/1,computername=Server1</font> </li>
</ul>
<p>Again great stuff but it kind of sucks that you have to run two or more commands to sync your application if you have GACed DLLs. Never fear because Microsoft has thought of this as well.&#160; What you need to do is to create a XML file that describes your application. In it, you can include everything that you want to sync – files, IIS6 metadata settings, GACed assemblies, etc . . . Then you just have to tell MSdeply to use that file as input and you’re done!</p>
<p>For example, MyApplication has been created on the Web Site #885762418 pointing to D:\Inetpub\myapplicationroot for its file location. It also has two dlls that it needs located in the GAC.&#160; Then the XML would look like this:</p>
<p><font color="#0000ff">&lt;MyApplication&gt;      <br />&#160; &lt;metakey path=&quot;lm/w3svc/885762418&quot; /&gt;       <br />&#160; &lt;dirPath path=&quot;D:\Inetpub\myapplicationroot&quot; /&gt;       <br />&#160; &lt;gacAssembly path=&#8217;System.Web, Version=2.0.0.0, Culture=neutral, processorArchitecture=x86, PublicKeyToken=b03f5f7f11d50a3a&#8217; /&gt;       <br />&#160; &lt;gacAssembly path=&#8217;JPMCCommonServices, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL, PublicKeyToken=405319ba8665dd1a&#8217; /&gt;       <br />&lt;/MyApplication&gt;</font>     </p>
<p>And the command to deploy this application would be</p>
<ul>
<li><font color="#0000ff">msdeploy.exe -verb:sync -source:manifest=custom.xml -dest:manifest=custom.xml,computername=Server1</font> </li>
</ul>
<p>I know that some people have strong opinions about XML but in this case it is very easy to use and makes our job as IT admins much simpler so we can focus on the other things that make our jobs challenging and fun.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=51&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2010/03/21/msdeploy-with-iis6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>Compare Two Directories with Powershell</title>
		<link>http://quickanddirtyscripting.wordpress.com/2010/02/17/compare-two-directories-with-powershell/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2010/02/17/compare-two-directories-with-powershell/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 04:58:11 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/?p=41</guid>
		<description><![CDATA[Have you ever been tasked to compare two or more directories on different systems to ensure that they are the same?  This seems to come up all too often in my job – I’m afraid to find out why . . .  Most people will compare directories by looking at files and their modified date [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=41&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have you ever been tasked to compare two or more directories on different systems to ensure that they are the same?  This seems to come up all too often in my job – I’m afraid to find out why . . .  Most people will compare directories by looking at files and their modified date or byte sizes.  And this works very well. I also know that there are a lot of tools/applications that already do this, but they either cost money or not approved by my company. So the path of least resistance is to write my own and using a SHA-1 hash as the basis of comparison.</p>
<p>A little review. A hash is a cryptographically unique value of a document. In other words, every document, text, or otherwise produces a unique hash that can be computed again and again. This fact is can be utilized in comparing two different files for uniqueness.  Hashes are used every day.  For example, our passwords for applications we use online are not stored in the clear but rather hashed (or at least they should be).</p>
<p>So our first step in this quick and dirty script is to write a function to get a hash on any given file.  I found a lot of this code via Google and converting some C# code over to Powershell. The function basically opens the file, computes the hash of given type (in this case SHA-1), and then strips out any -<br />
<code><br />
    function get-hash {<br />
        param (<br />
          [string] $file = $(throw 'a filename is required'),<br />
          [string] $algorithm = "sha256"<br />
    )</p>
<p>    $fileStream = [system.io.file]::openread((resolve-path $file))<br />
    $hasher = [System.Security.Cryptography.HashAlgorithm]::create($algorithm)<br />
    $hash = $hasher.ComputeHash($fileStream)<br />
    $fileStream.Close()</p>
<p>    return ( ([system.bitconverter]::tostring($hash)).Replace("-") )</p>
<p>}<br />
</code></p>
<p>Now that we know how to get a hash on one file, we’ll have to get the hashes of all files in a directory and sub-directories.  We’ll store it in an object array which can be used by compare-object later on.  Notice the call to get-hash with an algorithm of sha1. PsIsContainer –eq $false means to skip over directory names.<br />
<code><br />
    function get-DirHash(){<br />
      begin {<br />
        $ErrorActionPreference = "silentlycontinue"<br />
      }<br />
      process {<br />
        dir -Recurse $_ | where { $_.PsIsContainer -eq $false } | select Name,DirectoryName,@{Name="SHA1 Hash"; Expression={get-hash $_.FullName -algorithm "sha1"}}<br />
      }<br />
      end  {<br />
     }<br />
}<br />
</code><br />
Now the easy part.  We store the object array in two different arrays for the two different directories and then call compare-object to do the comparison.  The flag –SyncWindow can also be used.</p>
<p><code><br />
Compare-Object $($src | get-DirHash) $($dst | get-DirHash) -property @("Name","SHA1 Hash") -includeEqual<br />
</code></p>
<p>This gives a complete script of:<br />
param (<br />
    [string] $src,<br />
    [string] $dst<br />
)    </p>
<p>function get-DirHash(){<br />
    begin {<br />
        $ErrorActionPreference = &#8220;silentlycontinue&#8221;<br />
    }<br />
    process {<br />
        dir -Recurse $_ | where { $_.PsIsContainer -eq $false } | select Name,DirectoryName,@{Name=&#8221;SHA1 Hash&#8221;; Expression={get-hash $_.FullName -algorithm &#8220;sha1&#8243; }}<br />
    }<br />
    end {<br />
    }<br />
}</p>
<p>function get-hash {<br />
    param(<br />
        [string] $file = $(throw &#8216;a filename is required&#8217;),<br />
        [string] $algorithm = &#8216;sha256&#8242;<br />
    )</p>
<p>    $fileStream = [system.io.file]::openread((resolve-path $file))<br />
    $hasher = [System.Security.Cryptography.HashAlgorithm]::create($algorithm)<br />
    $hash = $hasher.ComputeHash($fileStream)<br />
    $fileStream.Close()</p>
<p>    return ( ([system.bitconverter]::tostring($hash)).Replace(&#8220;-&#8221;) )</p>
<p>}</p>
<p>Compare-Object $($src | get-DirHash) $($dst | get-DirHash) -property @(&#8220;Name&#8221;,&#8221;SHA1 Hash&#8221;) -includeEqual<br />
</code></p>
<p>The output looks something like the following:</p>
<p><code><br />
C:\Data\E148884\Code\PowerShell\powershell.exe .\compare_directories.ps1 c:\temp\REF c:\temp\DST</p>
<p>Name                  SHA1 Hash                                SideIndicator<br />
----                  ---------                                -------------<br />
deploy-sharepoint.bat 85B5967389E5FA4BDA698AA2FA9889685B7B1CA0 ==<br />
gacutil.exe           ACBB2E6BEC6DBA8BA3E7E743A5CDC22D57CC6AD4 ==<br />
deploy-metastorm.bat  F83BFB947F8970B76115E4E0B4E5CB20DE54719  =&lt;<br />
deploy-metastorm.bat  3BB7DB50F3FEA06976C7076DD0D30585B0F702DB ;<br />
</code><br />
And there you go. Another quick script that is very useful to administrators.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=41&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2010/02/17/compare-two-directories-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint Trending with Google APIs</title>
		<link>http://quickanddirtyscripting.wordpress.com/2009/11/08/sharepoint-trending-with-google-apis/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2009/11/08/sharepoint-trending-with-google-apis/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 02:38:00 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2009/11/08/sharepoint-trending-with-google-apis</guid>
		<description><![CDATA[At my day job, I manager a fairly large SharePoint deployment. We currently have about 450GB of content spread across 6-7 content databases. Needlessly to say, because SharePoint stores all of its information inside SQL Server database and Microsoft’s recommendation for no larger than 100GB content databases, trending our growth is very important to our [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=24&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At my day job, I manager a fairly large SharePoint deployment. We currently have about 450GB of content spread across 6-7 content databases. Needlessly to say, because  SharePoint stores all of its information inside SQL Server database and Microsoft’s recommendation for no larger than 100GB content databases, trending our growth is very important to our team. For a while, we have been taking snapshots of the content database’s size, storing the information in Excel and generating Pivot table and charts.  This worked fine but I wanted better.  I’ve always liked the way Google’s Finance pages looked so I was excited to learn that you can use those same APIs in your own site.  I think I’ve come up with a pretty neat solution by utilizing the SharePoint object model ,PowerShell, a little jQuery,  Google’s APIs and an awesome course from EndUserSharepoint (Url &#8211; <a href="http://www.endusersharepoint.com/">http://www.endusersharepoint.com</a>, Twitter &#8211; @ESUP) .  I’m always open for suggestions or improvements so after you read my posting, please let me know what you think.</p>
<div class="ExternalClass81E201677E3D4F98A98C1B249071A6CA">
<p>Enough chit chat. Let’s get into how this works. To get this working for you, you’ll need three things:</p>
<ol>
<li>A SharePoint List to store the size of the SharePoint databases</li>
<li>A PowerShell script to populate the list on a nightly basis</li>
<li>A Web Part page with a Content Editor Web part + jQuery and the SharePoint List to generate the graph</li>
</ol>
<h3>SharePoint List</h3>
<p>This easiest thing to create. Its just a custom SharePoint list with the following columns.</p>
<ul>
<li>Web Application – the name of the SharePoint web application. I typically rename the default Name field.</li>
<li>Database Name – the name of the of the Content Database.</li>
<li>Database Size – a number field that will store the size of the database. The one thing that I do not like about the number field is that it inserts commas into the number. I debated about making this a string field but I decided to just handle this with a little jQuery</li>
<li>Date – this will hold the date the database snapshot was taken. I give it a default value of today’s date and only select date, not date/time.</li>
</ul>
<p>A couple other things to note about the list:</p>
<ol>
<li>You will need to grant your SharePoint farm account contribute access to the list. This is because the PowerShell script will run as the Farm account. In a locked down environment like mine the only account that can access the databases is the Farm account.</li>
<li>To keep the list from growing too large, I setup an IRM  policy to delete  a list item 90 days  after the item is created. This keeps my list nice and trim automatically.</li>
</ol>
<h3>PowerShell Script</h3>
<p>The PowerShell script utilizes the SharePoint object model so it has to run on one of the SharePoint servers in your farm. I choose my Central Admin server but it can be any server in the farm.  The idea of the script to is to loop through every Web Application and gather the size of each Content Database associated with it and then upload the information to the SharePoint list. Its pretty straight forward except for one issue with SharePoint Content Database names when working with PowerShell. This discussion thread goes into good detail on how to get around it &#8211; <a title="http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/16c06d92b2385325" href="http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/16c06d92b2385325">http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/16c06d92b2385325</a>.</p>
<div id="codeSnippetWrapper" style="border:1px solid silver;overflow:auto;text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;direction:ltr;max-height:200px;cursor:text;font-family:'Courier New',courier,monospace;font-size:8pt;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;padding:0;">
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;">   1:</span> . ..\SharePointFunctions.ps1</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;">   2:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;">   3:</span> <span style="color:#008000;">#Powershell had an issue with the SPContentDatabase assembly function Name and DiskSizeRequired. This is a work around</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;">   4:</span> <span style="color:#008000;">#See http://groups.google.com/group/microsoft.public.windows.powershell/browse_thread/thread/16c06d92b2385325 for more information </span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;">   5:</span> $nameMethod = [Microsoft.Sharepoint.Administration.SPContentDatabase].getMethod(<span style="color:#006080;">"get_Name"</span>)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;">   6:</span> $diskMethod = [Microsoft.Sharepoint.Administration.SPContentDatabase].getMethod(<span style="color:#006080;">"get_DiskSizeRequired"</span>)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;">   7:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;">   8:</span> set-variable -option constant -name TrendingList -value <span style="color:#006080;">"Trending-SPDatabase"</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;">   9:</span> set-variable -option constant -name TrendingSite  -value <span style="color:#006080;">"http://tis-collaboration.jpmchase.net/ti/shareddotnet"</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;">  10:</span> set-variable -option constant -name WebApplication  -value <span style="color:#006080;">"Web Application"</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;">  11:</span> set-variable -option constant -name DatabaseName -value <span style="color:#006080;">"Database Name"</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;">  12:</span> set-variable -option constant -name DatabaseSize  -value <span style="color:#006080;">"Database Size (MB)"</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;">  13:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;">  14:</span> $MB = 1024*1024</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;">  15:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;">  16:</span> <span style="color:#008000;">#Function main - Where all of the fun is</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum17" style="color:#606060;">  17:</span> <span style="color:#0000ff;">function</span> main() {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum18" style="color:#606060;">  18:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum19" style="color:#606060;">  19:</span>     <span style="color:#008000;">#Loop through all WebApplications</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum20" style="color:#606060;">  20:</span>     get-SPWebApplications -name * | % {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum21" style="color:#606060;">  21:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum22" style="color:#606060;">  22:</span>         <span style="color:#008000;">#Don't need to display information on the Central Admin site</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum23" style="color:#606060;">  23:</span>         <span style="color:#0000ff;">if</span>( -not $_.IsAdministrationWebApplication ) {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum24" style="color:#606060;">  24:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum25" style="color:#606060;">  25:</span>             $strWebApp = $_.Name.TrimStart()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum26" style="color:#606060;">  26:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum27" style="color:#606060;">  27:</span>             <span style="color:#008000;">#Display information about the content database attached to this WebApp</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum28" style="color:#606060;">  28:</span>             $ContentDatabaseCollection = $_.ContentDatabases</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum29" style="color:#606060;">  29:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum30" style="color:#606060;">  30:</span>             $ContentDatabaseCollection | % {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum31" style="color:#606060;">  31:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum32" style="color:#606060;">  32:</span>                 $newlistitem  = @{}</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum33" style="color:#606060;">  33:</span>                 $newlistitem[$WebApplication] = $strWebApp</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum34" style="color:#606060;">  34:</span>                 $newlistitem[$DatabaseName] = $nameMethod.Invoke($_, <span style="color:#006080;">"instance,public"</span>, $null, $null, $null)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum35" style="color:#606060;">  35:</span>                 $newlistitem[$DatabaseSize] = [math]::round( ($diskMethod.Invoke($_, <span style="color:#006080;">"instance,public"</span>, $null, $null, $null) / $MB), 0)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum36" style="color:#606060;">  36:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum37" style="color:#606060;">  37:</span>                 add-toSpList -url $TrendingSite -list $TrendingList -entry $newlistitem</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum38" style="color:#606060;">  38:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum39" style="color:#606060;">  39:</span>             }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum40" style="color:#606060;">  40:</span>         }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum41" style="color:#606060;">  41:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum42" style="color:#606060;">  42:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum43" style="color:#606060;">  43:</span> }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum44" style="color:#606060;">  44:</span> main</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>The variables TrendingSite, TrendingList, WebApplication, DatabaseName, DatabaseSize will need to be updated for your environment.</p>
<p>The function get-SPWebApplication will return a list  Web Application objects. You can limit the list to a specific Web Application by replacing “–name *” with “–name $name_of_web_application”</p>
<div id="codeSnippetWrapper" style="border:1px solid silver;overflow:auto;text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;direction:ltr;max-height:200px;cursor:text;font-family:'Courier New',courier,monospace;font-size:8pt;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;padding:0;">
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;">   1:</span> <span style="color:#0000ff;">function</span> get-SPWebApplication( [string] $name )</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;">   3:</span>     $WebServiceCollection = new-object microsoft.sharepoint.administration.SpWebServiceCollection( get-SPFarm )</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;">   4:</span>     $WebServiceCollection | % { $WebApplications += $_.WebApplications }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;">   5:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;">   6:</span>     <span style="color:#0000ff;">return</span> ( $webApplications | where { $_.Name.ToLower() <span style="color:#cc6633;">-like</span> <span style="color:#006080;">"*"</span>+$name.ToLower()+<span style="color:#006080;">"*"</span> } | select -Unique )</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;">   7:</span> }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;">   8:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;">   9:</span> <span style="color:#0000ff;">function</span> get-SPFarm()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;">  10:</span> {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;">  11:</span>     <span style="color:#0000ff;">return</span> [microsoft.sharepoint.administration.spfarm]::<span style="color:#0000ff;">local</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;">  12:</span> }</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>To add the information to the SharePoint List, we have to pass a hash table with name/value pairs to the function add-toSpList.  We also have to pass the URL of the Site that hosts the list and the List name.</p>
<div id="codeSnippetWrapper" style="border:1px solid silver;overflow:auto;text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;direction:ltr;max-height:200px;cursor:text;font-family:'Courier New',courier,monospace;font-size:8pt;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;padding:0;">
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;">   1:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;">   2:</span> <span style="color:#0000ff;">function</span> add-toSpList ( [Object] $url, [string] $list, [HashTable] $entry)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;">   3:</span> {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;">   4:</span>     <span style="color:#0000ff;">if</span>( $url.GetType().Name <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"String"</span>)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;">   5:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;">   6:</span>         $site = new-object Microsoft.SharePoint.SPSite($url)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;">   7:</span>         $web = $site.OpenWeb()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;">   8:</span>     }<span style="color:#0000ff;">else</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;">   9:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;">  10:</span>         $web = $url</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;">  11:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;">  12:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;">  13:</span>     $splist = $web.Lists[$list]</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;">  14:</span>     $newitem = $splist.items.Add()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;">  15:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;">  16:</span>     $entry.Keys.GetEnumerator() | % {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum17" style="color:#606060;">  17:</span>         $newitem[$_] = $entry[$_]</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum18" style="color:#606060;">  18:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum19" style="color:#606060;">  19:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum20" style="color:#606060;">  20:</span>     $newitem.update()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum21" style="color:#606060;">  21:</span>     $web.Dispose()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum22" style="color:#606060;">  22:</span>     $site.Dispose()</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum23" style="color:#606060;">  23:</span> }</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Now that we have to entire script, all you have to do is schedule it to run as often as you wish via the Windows Scheduler.  Make sure you run the script as the SharePoint Farm Admin.</p>
<h3>SharePoint WebPart Page + jQuery</h3>
<p>Now the fun begins.  I owe a ton of thanks to the EndUserSharepoint.com team as I used a lot of their work as a basis for what I’m trying to do.    First, what you need to do is add a Web Part page to your site.  On this page, add a Content Editor Web Part and the SharePoint List that you created earlier.  For the list, I filtered the view to only display one database name. I also only selected he database name, size, and date columns.  If I have more than one database (or web application) then I will need to create a page for each.  The view should look something like this:</p>
<p><a href="http://www.bjd145.org/uploaded_images/blog_1-737493.png"><img src="http://www.bjd145.org/uploaded_images/blog_1-737490.png" border="0" alt="" /></a></p>
<p>Next you have to get jQuery working with your site, and this means adding code to the Content Editor Web Part.  I would suggest heading over to EndUserSharepoint.com (<a title="http://www.endusersharepoint.com/?s=jquery+for+everyone" href="http://www.endusersharepoint.com/?s=jquery+for+everyone">http://www.endusersharepoint.com/?s=jquery+for+everyone</a>) for more information on jQuery, but basically jQuery is a collection of JavaScript functions and objects that make JavaScript coding a lot easier.  You need to load the jQuery engine and thankfully Google hosts it for you. All you need to do is link to their URL in your code. This is what I done for this to work.  Google also hosts the visualization APIs that we need to generate the graph. If you want to learn more about the available APIs and samples on how to use them, head over to <a title="http://code.google.com/apis/visualization/" href="http://code.google.com/apis/visualization/">http://code.google.com/apis/visualization/</a></p>
<p>The code for the Content Editor Web Part +  jQuery is as follows: (PS: This has to be added via the CEWP’s source button, not the Rich Text Editor.)</p>
<div id="codeSnippetWrapper" style="border:1px solid silver;overflow:auto;text-align:left;line-height:12pt;background-color:#f4f4f4;width:98.39%;direction:ltr;height:598px;max-height:200px;cursor:text;font-family:'Courier New',courier,monospace;font-size:8pt;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;padding:0;">
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum1" style="color:#606060;">   1:</span> &lt;script type=<span style="color:#006080;">"text/javascript"</span> src=<span style="color:#006080;">"https://www.google.com/jsapi"</span>&gt;&lt;/script&gt;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum2" style="color:#606060;">   2:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum3" style="color:#606060;">   3:</span> &lt;script type=<span style="color:#006080;">"text/javascript"</span>&gt;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum4" style="color:#606060;">   4:</span>     google.load(<span style="color:#006080;">'visualization'</span>, <span style="color:#006080;">'1'</span>, {packages: [<span style="color:#006080;">'annotatedtimeline'</span>]});</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum5" style="color:#606060;">   5:</span>     <span style="color:#0000ff;">function</span> drawVisualization() {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum6" style="color:#606060;">   6:</span>       <span style="color:#0000ff;">var</span> dataList = $(<span style="color:#006080;">"td.ms-vb2 div"</span>);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum7" style="color:#606060;">   7:</span>       <span style="color:#0000ff;">var</span> dateList = $(<span style="color:#006080;">"td.ms-vb2 nobr"</span>);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum8" style="color:#606060;">   8:</span>       <span style="color:#0000ff;">var</span> dateArray = <span style="color:#0000ff;">new</span> Array();</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum9" style="color:#606060;">   9:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum10" style="color:#606060;">  10:</span>       $.each(dateList, <span style="color:#0000ff;">function</span>(i,e)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum11" style="color:#606060;">  11:</span>       {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum12" style="color:#606060;">  12:</span>         <span style="color:#0000ff;">var</span> y = $(e).text();</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum13" style="color:#606060;">  13:</span>         dateArray[i] = y;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum14" style="color:#606060;">  14:</span>       });</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum15" style="color:#606060;">  15:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum16" style="color:#606060;">  16:</span>       <span style="color:#0000ff;">var</span> data = <span style="color:#0000ff;">new</span> google.visualization.DataTable();</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum17" style="color:#606060;">  17:</span>       data.addColumn(<span style="color:#006080;">'date'</span>, <span style="color:#006080;">'Date'</span>);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum18" style="color:#606060;">  18:</span>       data.addColumn(<span style="color:#006080;">'number'</span>, <span style="color:#006080;">'Size'</span>);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum19" style="color:#606060;">  19:</span>       data.addRows(dataList.length);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum20" style="color:#606060;">  20:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum21" style="color:#606060;">  21:</span>       $.each(dataList, <span style="color:#0000ff;">function</span>(i,e)</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum22" style="color:#606060;">  22:</span>       {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum23" style="color:#606060;">  23:</span>          <span style="color:#0000ff;">var</span> x= $(e).text().replace(<span style="color:#006080;">","</span>,<span style="color:#006080;">""</span>);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum24" style="color:#606060;">  24:</span>          data.setValue(i, 0, <span style="color:#0000ff;">new</span> Date(dateArray[i]) );</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum25" style="color:#606060;">  25:</span>          data.setValue(i, 1, parseInt(x * 1048576) );</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum26" style="color:#606060;">  26:</span>       });</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum27" style="color:#606060;">  27:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum28" style="color:#606060;">  28:</span>       <span style="color:#0000ff;">var</span> annotatedtimeline = <span style="color:#0000ff;">new</span> google.visualization.AnnotatedTimeLine(document.getElementById(<span style="color:#006080;">'trending'</span>));</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum29" style="color:#606060;">  29:</span>       annotatedtimeline.draw(data, {<span style="color:#006080;">'displayAnnotations'</span>: <span style="color:#0000ff;">true</span>});</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum30" style="color:#606060;">  30:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum31" style="color:#606060;">  31:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum32" style="color:#606060;">  32:</span>     google.setOnLoadCallback(drawVisualization);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum33" style="color:#606060;">  33:</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum34" style="color:#606060;">  34:</span> &lt;/script&gt;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;text-align:left;line-height:12pt;background-color:white;width:100%;direction:ltr;font-family:'Courier New',courier,monospace;font-size:8pt;color:black;border-style:none;margin:0;padding:0;"><span id="lnum35" style="color:#606060;">  35:</span> &lt;div id=<span style="color:#006080;">"trending"</span> style=<span style="color:#006080;">"width: 100%; height: 400px;"</span>&gt;&lt;/div&gt;</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Well there you go.  Once you have everything in place you should have a page the looks similar to this:</p>
<p><a href="http://www.bjd145.org/uploaded_images/blog_2-786119.png"><img src="http://www.bjd145.org/uploaded_images/blog_2-786116.png" border="0" alt="" /></a></p>
<p>I hope that everyone has enjoyed this post and I always look forward to any feedback.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=24&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2009/11/08/sharepoint-trending-with-google-apis/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>

		<media:content url="http://www.bjd145.org/uploaded_images/blog_1-737490.png" medium="image" />

		<media:content url="http://www.bjd145.org/uploaded_images/blog_2-786116.png" medium="image" />
	</item>
		<item>
		<title>Time zone Clocks with SharePoint using jQuery</title>
		<link>http://quickanddirtyscripting.wordpress.com/2009/10/16/time-zone-clocks-with-sharepoint-using-jquery/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2009/10/16/time-zone-clocks-with-sharepoint-using-jquery/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 04:31:00 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2009/10/16/time-zone-clocks-with-sharepoint-using-jquery</guid>
		<description><![CDATA[I work with a lot people who are spread across the global so we are always trying to find out what is their local time. While Google has a great query that will convert time for you, I wanted to see if I could create a SharePoint page that will list the times in all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=23&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I work with a lot people who are spread across the global so we are always trying to find out what is their local time. While Google has a great query that will convert time for you, I wanted to see if I could create a SharePoint page that will list the times in all the zones that we have people on the team.  I found a great blog post on ‘Path to Sharepoint’ (<a title="http://pathtosharepoint.wordpress.com/2009/01/09/world-clock/" href="http://pathtosharepoint.wordpress.com/2009/01/09/world-clock/">http://pathtosharepoint.wordpress.com/2009/01/09/world-clock/</a>) did exactly what I wanted. The one catch was that he used a lot of JavaScript to convert the calculated text column to HTML. I wondered if jQuery could make it easier.  This is what I came up with . . . </p>
<pre style="border:1px solid rgb(206,206,206);overflow:auto;background-color:rgb(251,251,251);min-height:40px;width:700px;padding:5px;">
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  1: &lt;script type="<span style="color:rgb(139,0,0);">text/javascript</span>" src="<span style="color:rgb(139,0,0);">http://www.google.com/jsapi</span>"&gt;&lt;/script&gt;</pre>
<pre style="background-color:rgb(255,255,255);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  2: &lt;script type="<span style="color:rgb(139,0,0);">text/javascript</span>"&gt;</pre>
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  3:     <span style="color:rgb(0,128,0);">//load jQuery</span></pre>
<pre style="background-color:rgb(255,255,255);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  4:     google.load("<span style="color:rgb(139,0,0);">jquery</span>", "<span style="color:rgb(139,0,0);">1.3.2</span>");</pre>
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  5: &lt;/script&gt;</pre>
<pre style="background-color:rgb(255,255,255);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  6:</pre>
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  7: &lt;script type="<span style="color:rgb(139,0,0);">text/javascript</span>"&gt;</pre>
<pre style="background-color:rgb(255,255,255);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">  8: $(<span style="color:rgb(0,0,255);">function</span>() {</pre>
<pre style="background-color:rgb(251,251,251);width:100%;margin:0;">  9:     $("<span style="color:rgb(139,0,0);">td.ms-stylebody:contains('DIV')</span>").each(<span style="color:rgb(0,0,255);">function</span>(){</pre>
<pre style="background-color:rgb(255,255,255);width:100%;margin:0;"> 10:         $(<span style="color:rgb(0,0,255);">this</span>).html($(<span style="color:rgb(0,0,255);">this</span>).text());</pre>
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;"> 11:     });</pre>
<pre style="background-color:rgb(255,255,255);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;"> 12: });</pre>
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;"> 13: &lt;/script&gt;</pre>
</pre>
<p>
<p>There are a couple requirements for this to work.</p>
<p>
<ol>
<li>The list view was set to boxed.</li>
<li>The calculated column had this equation: </li>
<pre style="border:1px solid rgb(206,206,206);overflow:auto;background-color:rgb(251,251,251);min-height:40px;width:700px;padding:5px;">
<pre style="background-color:rgb(251,251,251);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">="<span style="color:rgb(139,0,0);">&lt;DIV id='calchtml'&gt;&lt;embed src='http://www.clocklink.com/clocks/5001-blue.swf?TimeZone=</span>"&amp;TimeZone&amp;"<span style="color:rgb(139,0,0);">'</span></pre>
<pre style="background-color:rgb(255,255,255);width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:10px;margin:0;">width=<span style="color:rgb(0,128,0);">'250' height='70' wmode='transparent' type='application/x-shockwave-flash'&gt;&lt;/DIV&gt;"</span></pre>
</pre>
</ol>
<p>
<p>If you follow the instructions at ‘Path to SharePoint’ and use this jQuery you should get something like this:</p>
<p><a href="http://www.bjd145.org/uploaded_images/clock-733791.png"><img src="http://www.bjd145.org/uploaded_images/clock-733789.png" alt="" border="0" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=23&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2009/10/16/time-zone-clocks-with-sharepoint-using-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>

		<media:content url="http://www.bjd145.org/uploaded_images/clock-733789.png" medium="image" />
	</item>
		<item>
		<title>Powershell Script to Create Sharepoint Web Application</title>
		<link>http://quickanddirtyscripting.wordpress.com/2008/04/10/powershell-script-to-create-sharepoint-web-application/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2008/04/10/powershell-script-to-create-sharepoint-web-application/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 02:13:00 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2008/04/10/powershell-script-to-create-sharepoint-web-application</guid>
		<description><![CDATA[Microsoft Sharepoint 2007 has a very nice web-based UI to create Web Applications, but there is one catch. The UI creates the backend database on the fly. In a lot of companies, this is the role of a DBA, and only they are allowed to create a new database. In a way this makes sense [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=22&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Microsoft Sharepoint 2007 has a very nice web-based UI to create Web Applications, but there is one catch. The UI creates the backend database on the fly. In a lot of companies, this is the role of a DBA, and only they are allowed to create a new database. In a way this makes sense due to the fact that the DBAs must maintain the intergity of the database server. Microsoft has provided a switch within the stsadm command to create a new Web Application with an existing database, but I thought I could come up with a way to do it using Powersell.</p>
<p>What I wanted to do was to supply a script with an XML configuration that would create 1-N Web Applications with 1-N Sites. The XML looks like the following:<br />
<blockquote><span style="color:rgb(51,102,255);"></span><span style="color:rgb(51,102,255);">&lt;Sharepoint&gt;</span><br /><span style="color:rgb(51,102,255);">    &lt;WebApplication name=&#8221;Test Site #1&#8243; hostheader=&#8221;http://portal.example.net&#8221;&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;AppPoolName&gt;WebApp-Portal&lt;/AppPoolName&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;AppPoolUser&gt;Domain\myServiceAccount&lt;/AppPoolUser&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;AppPoolPass&gt;test1235&lt;/AppPoolPass&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;Port&gt;80&lt;/Port&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;DatabaseServer&gt;DBS-SERVER-NAME\MOSS&lt;/DatabaseServer&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;DatabaseName&gt;WSS_Content_Potal&lt;/DatabaseName&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;RootDirectory&gt;d:\inetpub\wwwroot\wss\portal&lt;/RootDirectory&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;Sites&gt;</span><br /><span style="color:rgb(51,102,255);">            &lt;Site Path=&#8221;/&#8221;&gt;</span><br /><span style="color:rgb(51,102,255);">                &lt;Title&gt;Root Site&lt;/Title&gt;</span><br /><span style="color:rgb(51,102,255);">                &lt;Description&gt;Root Site&lt;/Description&gt;</span><br /><span style="color:rgb(51,102,255);">                &lt;Type&gt;STS#1&lt;/Type&gt;</span><br /><span style="color:rgb(51,102,255);">                &lt;AdminAccount&gt;DOMAIN\Administrator&lt;/AdminAccount&gt;</span><br /><span style="color:rgb(51,102,255);">                &lt;AdminName&gt;Administrator1&lt;/AdminName&gt;</span><br /><span style="color:rgb(51,102,255);">                &lt;AdminEmail&gt;root@jexample.net&lt;/AdminEmail&gt;</span><br /><span style="color:rgb(51,102,255);">            &lt;/Site&gt;</span><br /><span style="color:rgb(51,102,255);">        &lt;/Sites&gt;</span><br /><span style="color:rgb(51,102,255);">    &lt;/WebApplication&gt;</span><br /><span style="color:rgb(51,102,255);">    &lt;WebApplication&gt;&lt;/WebApplication&gt;</span><br /><span style="color:rgb(51,102,255);">&lt;/Sharepoint&gt;</span><br /><span style="color:rgb(51,102,255);"></span></p>
</blockquote>
<p>The first thing that needs to be done is load the Sharepoint .NET assembly and attach to the local farm</p>
<blockquote><p>[void][System.Reflection.Assembly]::LoadWithPartialName(&#8220;Microsoft.SharePoint&#8221;)<br />$farm = [microsoft.sharepoint.administration.spfarm]::local</p></blockquote>
<p>Then  load the XML configuration file and loop through all Web Applications.</p>
<blockquote><p>function main()<br />{</p>
<p>$moss = &#8220;Sharepoint&#8221;<br />$cfg = [xml](gc $cfgFile)</p>
<p>if( $? -eq $false ) {<br />  Write-Host &#8220;Could not cleanly parase XML file. Exiting . . .&#8221;<br />  return $false<br />}</p>
<p>Write-Host &#8220;Found Sharepoint Farm on Local Host  . . &#8220;</p>
<p>Write-Host &#8220;Using $cfgFile file . . .&#8221;</p>
<p>$cfg.$moss.WebApplication | % {</p>
<p>  createWebApp( $_ )</p>
<p>}<br />}</p>
<p>main</p></blockquote>
<p>Surprisingly to create new Web Application, all you need to do is create a Powershell object of type SPWebApplicationBuilder, assign the proper variables, create and then provision.  The command can take up to 10 minutes to complete so be patient.</p>
<blockquote><p>function createWebApp( [object] $cfg )<br />{<br />$webAppBuilder = $nul<br />$webAppBuilder =  new-object _<br />    microsoft.sharepoint.administration.SPWebApplicationBuilder($farm)</p>
<p>$secureString = ConvertTo-SecureString $cfg.AppPoolPass -asPlainText -force</p>
<p>$webAppBuilder.Port = $cfg.port<br />$webAppBuilder.ApplicationPoolId =  $cfg.AppPoolName<br />$webAppBuilder.ApplicationPoolUsername = $cfg.AppPoolUser<br />$webAppBuilder.ApplicationPoolPassword = $secureString</p>
<p>$webAppBuilder.HostHeader = $cfg.hostheader<br />$webAppBuilder.ServerComment = $cfg.name<br />$webAppBuilder.DatabaseServer = $cfg.DatabaseServer<br />$webAppBuilder.DatabaseName = $cfg.DatabaseName<br />$webAppBuilder.RootDirectory = $cfg.RootDirectory</p>
<p>if( $cfg.AllowAnonymous.ToString().ToLower() -eq &#8220;true&#8221; ) {<br />  $webAppBuilder.AllowAnonymousAccess = $true<br />}</p>
<p>Write-Host &#8220;Will now Provision this Web Application.&#8221;<br />Write-Host &#8220;This may take up to 10 minutes. . .&#8221;<br />$webApp = $webAppBuilder.Create()<br />$webApp.Provision()</p></blockquote>
<p>Finally, loop through all Sites that are listed in the XML and add them to the Web Application.<br />
<blockquote>  $cfg.Sites.Site | % {<br />      $title = $_.SiteTitle.ToString()<br />      $path = $_.Path.ToString()</p>
<p>      rite-Host &#8220;Will now Provision Site &#8211; $title ($path). &#8220;<br />      Write-Host &#8220;This may take up to 10 minutes. . .&#8221;</p>
<p>      $webApp.Sites.Add( $_.Path,<br />               $_.Title,<br />               $_.Description,<br />               1033,<br />               $_.Type,<br />               $_.AdminAccount,<br />               $_.AdminName,<br />               $_.AdminEmail)<br />  }</p></blockquote>
<p>See easy as 1, 2, 3 . . .</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/quickanddirtyscripting.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/quickanddirtyscripting.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=22&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2008/04/10/powershell-script-to-create-sharepoint-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell Scriptblocks</title>
		<link>http://quickanddirtyscripting.wordpress.com/2008/02/11/powershell-scriptblocks/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2008/02/11/powershell-scriptblocks/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 05:08:00 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2008/02/11/powershell-scriptblocks</guid>
		<description><![CDATA[One of the interesting features that is, I believe, little know in Powershell is the scriptblock. What is a scriptblock? The way that I define it is a function or block of code that is assigned to a variable. Why do you need to know about this? I&#8217;ve found it most useful when using Powershell [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=21&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the interesting features that is, I believe, little know in Powershell is the scriptblock.  What is a scriptblock? The way that I define it is a function or block of code that is assigned to a variable.  Why do you need to know about this?  I&#8217;ve found it most useful when using Powershell to create a GUI.  You have to assign an action to an element on the GUI (like a Button). But the action can not be a function. It must be a script block.  You can define the block as a variable or  define it within the {} of the Add_Click method of the System.Windows.Forms.Button object.<br /><span style="font-family:monospace;"><br /></span>Now I&#8217;m probably completely wrong with this, and if I am I would love to learn more about it.  So please let me know! I want to cover how to create GUIs in Powershell in couple weeks so I will be building off this blog post.</p>
<p>So how do you create a Script block. Its easy as assigning a variable to a anything within {}.</p>
<p>A simple case would be something like<br />
<blockquote>PS C:\temp&gt; $x = { Write-Host &#8220;Hello, World!&#8221; }</p>
<p>PS C:\temp&gt; $x.GetType()</p>
<p>IsPublic IsSerial Name                                     BaseType<br />&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-                                     &#8212;&#8212;&#8211;<br />True     False    ScriptBlock                              System.Object</p></blockquote>
<p>If you just call the variable, it will return the block definition</p>
<blockquote><p>PS C:\temp&gt; $x<br />Write-Host &#8220;Hello, World!&#8221;</p></blockquote>
<p>To invoke the scriptblock, you need to call the Inovke() method of the script</p>
<blockquote><p>PS C:\temp&gt; $x.Invoke()<br />Hello, World!</p></blockquote>
<p>Within the scriptblock, you can do whatever you want to do. It can be multiple lines, you can even call functions from within the block.  For example:<br />
<blockquote><span style="color:rgb(51,102,255);">PS C:\temp&gt; function y () {</span><br /><span style="color:rgb(51,102,255);">&gt;&gt; Write-Host &#8220;Within function y&#8221;</span><br /><span style="color:rgb(51,102,255);">&gt;&gt; }</span><br /><span style="color:rgb(51,102,255);">&gt;&gt;</span><br /><span style="color:rgb(51,102,255);">PS C:\temp&gt; y</span><br /><span style="color:rgb(51,102,255);">Within function y</span><br /><span style="color:rgb(51,102,255);">PS C:\temp&gt; $x = {</span><br /><span style="color:rgb(51,102,255);">&gt;&gt; Write-Host &#8220;Within scriptblock x&#8221;</span><br /><span style="color:rgb(51,102,255);">&gt;&gt; y</span><br /><span style="color:rgb(51,102,255);">&gt;&gt; }</span><br /><span style="color:rgb(51,102,255);">&gt;&gt;</span><br /><span style="color:rgb(51,102,255);">PS C:\temp&gt; $x.Invoke()</span><br /><span style="color:rgb(51,102,255);">Within scriptblock x</span><br /><span style="color:rgb(51,102,255);">Within function y</span></p></blockquote>
<p>Here are all of the methods that Scriptblocks provides within Powershell<br />
<blockquote>PS C:\temp&gt; $x | Get-Member</p>
<p> TypeName: System.Management.Automation.ScriptBlock</p>
<p>Name             MemberType Definition<br />&#8212;-             &#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />Equals           Method     System.Boolean Equals(Object obj)<br />GetHashCode      Method     System.Int32 GetHashCode()<br />GetType          Method     System.Type GetType()<br />get_IsFilter     Method     System.Boolean get_IsFilter()<br />Invoke           Method     System.Collections.ObjectModel.Collection`1[[System.Management.Automation.PSObject, Syst...<br />InvokeReturnAsIs Method     System.Object InvokeReturnAsIs(Params Object[] args)<br />set_IsFilter     Method     System.Void set_IsFilter(Boolean value)<br />ToString         Method     System.String ToString()<br />IsFilter         Property   System.Boolean IsFilter {get;set;}</p></blockquote>
<p>I hope this gives you an introduction into scriptblocks. Next time, hopefully, we can cover the TCL/TK-like feature of Powershell &#8211; its GUI.</p>
<p>
<blockquote></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/quickanddirtyscripting.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/quickanddirtyscripting.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=21&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2008/02/11/powershell-scriptblocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>Q&amp;D Ping Function for Powershell</title>
		<link>http://quickanddirtyscripting.wordpress.com/2008/01/16/qd-ping-function-for-powershell/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2008/01/16/qd-ping-function-for-powershell/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 21:29:00 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2008/01/16/qd-ping-function-for-powershell</guid>
		<description><![CDATA[By default, Powershell does not have any built in functionality to send an ICMP ping to see if a remote computer is alive on and on the network. But never fear because Powershell is based off .NET. This means it is very easy to implement a Ping function that you can add to a Powershell [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=20&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:rgb(51,102,255);"><span style="color:rgb(0,0,0);">By default, Powershell does not have any built in functionality to send an ICMP ping to see if a remote computer is alive on and on the network.   But never fear because Powershell is based off .NET.  This means  it is very easy to implement a Ping function that you can add to a Powershell library file (along with other functions that I have blogged about previously).   The function is pretty straight forward. All that you really new to do is to create two .NET objects &#8211; Ping and PingReply.  My ping function only looks to see if a success was returned by ICMP. I am not looking for round trip time or to handle non-successful.<br /></span></p>
<pre>function Ping (  [string] $strComputer ){  $timeout=120;  trap { continue; }

  $ping = new-object System.Net.NetworkInformation.Ping   $reply = new-object System.Net.NetworkInformation.PingReply

  $reply = $ping.Send($strComputer, $timeout);  if( $reply.Status -eq "Success"  )   {     return $true;  }  return $false;

}</pre>
<p><span style="color:rgb(0,0,0);">Again that&#8217;s it.  The trap command will just ignore any errors that are throw by the $ping.Send command.  If anyone has questions than you can always email me at brian@bjd145.org.</span><br /></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/quickanddirtyscripting.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/quickanddirtyscripting.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=20&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2008/01/16/qd-ping-function-for-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell and XML Configuration Files</title>
		<link>http://quickanddirtyscripting.wordpress.com/2008/01/07/powershell-and-xml-configuration-files/</link>
		<comments>http://quickanddirtyscripting.wordpress.com/2008/01/07/powershell-and-xml-configuration-files/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 04:54:00 +0000</pubDate>
		<dc:creator>bjd145</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://quickanddirtyscripting.wordpress.com/2008/01/07/powershell-and-xml-configuration-files</guid>
		<description><![CDATA[&#160; One of the things that I almost always create when I am developing a script is a configuration file. Utilizing XML for a configuration file format is very easy with Powershell.&#160; The first thing that you need to do is to layout your XML file. I typically don&#8217;t create a DTD or verify the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=19&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>One of the things that I almost always create when I am developing a script is a configuration file. Utilizing XML for a configuration file format is very easy with Powershell.&nbsp; The first thing that you need to do is to layout your XML file. I typically don&#8217;t create a DTD or verify the XML schema because well, only my scripts will be using the XML configuration file.&nbsp; Not completely within spec, but I&#8217;ve learn to live with it. The XML does need to be well formed with proper closing brackets, root node, etc in order for Powershell to read the XML but that is the only restriction.</p>
<p>The most common XML file that I create includes a list of servers and some attribute about those servers. A simple&nbsp; example that of a test application that is made up of three web servers and a database server. The way that I would create the XML would be as follows:</p>
<blockquote><p><font color="#000080">&lt;test_app_servers&gt;<br />&nbsp;&nbsp;&nbsp; &lt;dbs server=&#8221;vm-dbs1&#8243; dbsname=&#8221;eut&#8221;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;web dir=&#8221;d$\inetpub\wwwroot&#8221;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;server&gt;vm-test1&lt;/server&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;server&gt;vm-test2&lt;/server&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;server&gt;vm-test3&lt;/server&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/web&gt;&lt;/test_app_servers&gt;</font></p>
</blockquote>
<p>Now the important part, how does Powershell read the XML.&nbsp; The code is very straight forward. You use the get-content command and cast the file as XML.&nbsp; The command is:</p>
<blockquote><p><font color="#000080">$cfgFile = &#8220;.\test_app_config.xml&#8221;<br />$root = &#8220;test_app_servers&#8221;<br />$cfg = [xml] ( gc $cfgFile )</font></p>
</blockquote>
<p>Now once you have the configuration saved in the variable $cfg then how do you use it?&nbsp; Powershell stores the information in a tree format so it is easy to get at. Some samples of how to get at the data include:</p>
<blockquote><p><font color="#000080">$strDbsName = $cfg.$root.dbs.dbsname</font>
<p><font color="#000080">$strDbsServer = $cfg.$root.dbs.server</font>
<p><font color="#000080">$strWebDir = $cfg.$root.web.dir</font>
<p><font color="#000080">$cfg.$root.web.server | % { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $strWebServer = $_<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Content of </font><a href="//\\$strWebServer\$strWebDir"><font color="#000080">\\$strWebServer\$strWebDir</font></a><font color="#000080">&#8220;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dir </font><a href="//\\$strWebServer\$strWebDir"><font color="#000080">\\$strWebServer\$strWebDir</font></a></p>
<p><font color="#000080">}</font></p></blockquote>
<p>And that is all you should need to know in order to utilize XML as a configuration file with Powershell</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/quickanddirtyscripting.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/quickanddirtyscripting.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quickanddirtyscripting.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quickanddirtyscripting.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/quickanddirtyscripting.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/quickanddirtyscripting.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quickanddirtyscripting.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quickanddirtyscripting.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quickanddirtyscripting.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quickanddirtyscripting.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quickanddirtyscripting.wordpress.com&amp;blog=11243133&amp;post=19&amp;subd=quickanddirtyscripting&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://quickanddirtyscripting.wordpress.com/2008/01/07/powershell-and-xml-configuration-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0d680a4d2d18b1cc0b307328a46874e4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bjd145</media:title>
		</media:content>
	</item>
	</channel>
</rss>
