<?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>The Code Log</title>
	<atom:link href="http://mycodelog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mycodelog.com</link>
	<description>SharePoint, OpenGL, and other random stuff...</description>
	<lastBuildDate>Thu, 26 Jan 2012 07:31:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mycodelog.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b1df6beb343cd638dd6b254b9f52c437?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>The Code Log</title>
		<link>http://mycodelog.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mycodelog.com/osd.xml" title="The Code Log" />
	<atom:link rel='hub' href='http://mycodelog.com/?pushpress=hub'/>
		<item>
		<title>Using Event Receivers in SharePoint Foundation 2010</title>
		<link>http://mycodelog.com/2011/03/29/event-receivers/</link>
		<comments>http://mycodelog.com/2011/03/29/event-receivers/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 04:10:55 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[event receivers]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=673</guid>
		<description><![CDATA[I have been working with Nick Gattuccio on authoring a two-part MSDN article about using event receivers in SharePoint 2010. The first part provides a thorough explanation of what events are and how they can be developed and deployed in SharePoint. The second part provides practical examples using Visual Studio 2010. Title: Using Event Receivers in <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=673&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been working with Nick Gattuccio on authoring a two-part MSDN article about using event receivers in SharePoint 2010. The first part provides a thorough explanation of what events are and how they can be developed and deployed in SharePoint. The second part provides practical examples using Visual Studio 2010.</p>
<p><strong>Title</strong>: Using Event Receivers in SharePoint Foundation 2010 (Part 1 of 2)<br />
<strong>URL</strong>: <a href="http://msdn.microsoft.com/en-us/library/gg749858.aspx">http://msdn.microsoft.com/en-us/library/gg749858.aspx</a></p>
<p><strong>Title</strong>: Using Event Receivers in SharePoint Foundation 2010 (Part 2 of 2)<br />
<strong>URL</strong>: <a href="http://msdn.microsoft.com/en-us/library/gg981880.aspx">http://msdn.microsoft.com/en-us/library/gg981880.aspx</a></p>
<p>Let me know how useful this is to you.</p>
<br />Filed under: <a href='http://mycodelog.com/category/sharepoint/'>SharePoint</a> Tagged: <a href='http://mycodelog.com/tag/event-receivers/'>event receivers</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/673/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/673/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/673/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/673/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/673/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/673/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/673/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/673/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=673&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2011/03/29/event-receivers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint 2010 site just got shared!</title>
		<link>http://mycodelog.com/2010/10/08/sp2010share/</link>
		<comments>http://mycodelog.com/2010/10/08/sp2010share/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 02:39:21 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[sharepoint detector]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=645</guid>
		<description><![CDATA[http://sharepoint.microsoft.com is built on top of SharePoint! Found via SharePoint Detector. Filed under: SharePoint Tagged: sharepoint detector<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=645&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://sharepoint.microsoft.com" target="_blank">http://sharepoint.microsoft.com</a> is built on top of SharePoint!</p>
<p><img class="alignnone size-full wp-image-650" title="SharePoint 2010 site shared using SharePoint Detector on WordPress" src="http://alibad.files.wordpress.com/2010/10/spsitepress.png?w=510&#038;h=364" alt="" width="510" height="364" /></p>
<p>Found via <a title="SharePoint Detector" href="https://chrome.google.com/extensions/detail/iglddabgpnbmcpdnmcbhhmggipakapck?hl=en" target="_blank">SharePoint Detector</a>.<br />
<!--a3925e713c794e02b31658758e92a366--></p>
<br />Filed under: <a href='http://mycodelog.com/category/sharepoint/'>SharePoint</a> Tagged: <a href='http://mycodelog.com/tag/sharepoint-detector/'>sharepoint detector</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/645/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=645&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/10/08/sp2010share/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/10/spsitepress.png" medium="image">
			<media:title type="html">SharePoint 2010 site shared using SharePoint Detector on Wordpress</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint Detector &#8211; Chrome Extension</title>
		<link>http://mycodelog.com/2010/10/08/sharepoint-detector/</link>
		<comments>http://mycodelog.com/2010/10/08/sharepoint-detector/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 02:36:54 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[Browser Extension]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[sharepoint detector]]></category>
		<category><![CDATA[stumbleupon]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=629</guid>
		<description><![CDATA[Ever wondered whether a site is built on top of SharePoint? Now, there is an easy way to find out. Install the &#8220;SharePoint Detector&#8221; Chrome extension located at https://chrome.google.com/extensions/detail/iglddabgpnbmcpdnmcbhhmggipakapck?hl=en, and you will get the SharePoint icon displayed in Chrome&#8217;s address bar every time you browse to a SharePoint site. You can then click on the SharePoint <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=629&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ever wondered whether a site is built on top of SharePoint? Now, there is an easy way to find out. Install the &#8220;SharePoint Detector&#8221; Chrome extension located at <a title="SharePoint Detector Chrome Extension" href="https://chrome.google.com/extensions/detail/iglddabgpnbmcpdnmcbhhmggipakapck?hl=en" target="_blank">https://chrome.google.com/extensions/detail/iglddabgpnbmcpdnmcbhhmggipakapck?hl=en</a>, and you will get the SharePoint icon displayed in Chrome&#8217;s address bar every time you browse to a SharePoint site. You can then click on the SharePoint icon and choose to share the site by email, on your WordPress blog, LinkedIn, Twitter, Facebook and\or StumbleUpon.</p>
<p>For example, here is what happens when you browse to <a href="http://www.wssdemo.com/">http://www.wssdemo.com</a>.</p>
<p><img class="alignnone size-full wp-image-632" title="wssdemo" src="http://alibad.files.wordpress.com/2010/10/wssdemo.png?w=510&#038;h=168" alt="" width="510" height="168" /></p>
<p>If you decide to share on Twitter, you will get the following popup.</p>
<p><img class="alignnone size-full wp-image-633" title="twittershare" src="http://alibad.files.wordpress.com/2010/10/twittershare.png?w=510&#038;h=283" alt="" width="510" height="283" /></p>
<p>You can edit it as you like then post to your Twitter account. Same goes for all the other different methods of sharing..</p>
<p>Enjoy sharing SharePoint!</p>
<br />Filed under: <a href='http://mycodelog.com/category/browser-extension/'>Browser Extension</a>, <a href='http://mycodelog.com/category/sharepoint/'>SharePoint</a> Tagged: <a href='http://mycodelog.com/tag/chrome/'>chrome</a>, <a href='http://mycodelog.com/tag/email/'>email</a>, <a href='http://mycodelog.com/tag/extension/'>extension</a>, <a href='http://mycodelog.com/tag/facebook/'>Facebook</a>, <a href='http://mycodelog.com/tag/linkedin/'>linkedin</a>, <a href='http://mycodelog.com/tag/sharepoint-detector/'>sharepoint detector</a>, <a href='http://mycodelog.com/tag/stumbleupon/'>stumbleupon</a>, <a href='http://mycodelog.com/tag/twitter/'>twitter</a>, <a href='http://mycodelog.com/tag/wordpress/'>wordpress</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/629/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/629/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=629&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/10/08/sharepoint-detector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/10/wssdemo.png" medium="image">
			<media:title type="html">wssdemo</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/10/twittershare.png" medium="image">
			<media:title type="html">twittershare</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2010 &#8211; Unattended Silent Install</title>
		<link>http://mycodelog.com/2010/09/28/silentvs/</link>
		<comments>http://mycodelog.com/2010/09/28/silentvs/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 10:16:43 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[Setup]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[createunattend]]></category>
		<category><![CDATA[unattendfile]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=613</guid>
		<description><![CDATA[You can find on MSDN How to: Create and Run an Unattended Visual Studio Setup. This post focuses on unattended installation of VS 2010 product only (without SDK) along with screenshots and hints on what to avoid. Below are the steps I have followed to create a silent unattended installation script for VS 2010. Create the VS 2010 unattend configuration <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=613&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You can find on MSDN <a href="http://msdn.microsoft.com/en-us/library/ee225237.aspx" target="_blank">How to: Create and Run an Unattended Visual Studio Setup</a>. This post focuses on unattended installation of VS 2010 product only (without SDK) along with screenshots and hints on what to avoid. Below are the steps I have followed to create a silent unattended installation script for VS 2010.</p>
<ul>
<li>Create the VS 2010 unattend configuration file<br />
<pre class="brush: plain;">&lt;path to VS installation folder&gt;\setup\setup.exe /createunattend c:\VS2010Config.ini</pre></p>
<p><strong>Note</strong>: Make sure you run the <strong>\setup\setup.exe</strong> and not \setup.exe directly.</li>
<li>The wizard will launch&#8230; Accept license terms, select the feature you want to install, then click Save Settings.<a href="http://alibad.files.wordpress.com/2010/09/createunattend.png"><img class="alignnone size-full wp-image-615" title="CreateUnattend" src="http://alibad.files.wordpress.com/2010/09/createunattend.png?w=510&#038;h=387" alt="" width="510" height="387" /></a></li>
<li>Once you click &#8220;Save Settings&#8221;, the VS config file will be created at c:\VS2010Config.ini</li>
<li>Now, do the unattended installation with the command below<br />
<pre class="brush: plain;">&lt;path to VS installation folder&gt;\setup\setup.exe /unattendfile c:\VS2010Config.ini</pre></li>
</ul>
<p>As you can see, the steps are pretty straight-forward. Enjoy!</p>
<br />Filed under: <a href='http://mycodelog.com/category/setup/'>Setup</a>, <a href='http://mycodelog.com/category/visual-studio/'>Visual Studio</a> Tagged: <a href='http://mycodelog.com/tag/createunattend/'>createunattend</a>, <a href='http://mycodelog.com/tag/unattendfile/'>unattendfile</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/613/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=613&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/09/28/silentvs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/09/createunattend.png" medium="image">
			<media:title type="html">CreateUnattend</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server 2008 R2 &#8211; Unattended Silent Install</title>
		<link>http://mycodelog.com/2010/09/28/sqlsilent/</link>
		<comments>http://mycodelog.com/2010/09/28/sqlsilent/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 08:43:49 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Setup]]></category>
		<category><![CDATA[Features]]></category>
		<category><![CDATA[IACCEPTSQLSERVERLICENSETERMS]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[quiet]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[silent]]></category>
		<category><![CDATA[sql server 2008 r2]]></category>
		<category><![CDATA[SQLSYSADMINACCOUNTS]]></category>
		<category><![CDATA[unattended]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=599</guid>
		<description><![CDATA[There is existing documentation on MSDN about How to: Install SQL Server 2008 R2 from the Command Prompt, but this post focuses on creating a silent unattended install of SQL Server 2008 R2 (Standard or Enterprise) using a configuration file. With the instructions below, you&#8217;ll be able to create a new customized SQL silent installation in minimal <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=599&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is existing documentation on MSDN about <a href="http://msdn.microsoft.com/en-us/library/ms144259.aspx" target="_blank">How to: Install SQL Server 2008 R2 from the Command Prompt</a>, but this post focuses on creating a silent unattended install of SQL Server 2008 R2 (Standard or Enterprise) using a configuration file. With the instructions below, you&#8217;ll be able to create a new customized SQL silent installation in minimal time. Note that the configuration below doesn&#8217;t work with the Express edition of SQL Server 2008 R2.</p>
<ul>
<li>Run setup.exe</li>
<li>Click on the installtion tab</li>
<li>Click &#8220;New Installation&#8221;</li>
<li>Go through the wizard: Enter product key, accept license, install setup support files, and select the features you want to install:<a href="http://alibad.files.wordpress.com/2010/09/sqlfeatures.jpg"><img title="Select SQL Features" src="http://alibad.files.wordpress.com/2010/09/sqlfeatures.jpg?w=510&#038;h=382" alt="" width="510" height="382" /></a></li>
</ul>
<ul>
<li>Continue the installation until you reach the &#8220;Ready To Install&#8221; step. Notice the path to the configuration file highlighted below in blue.<br />
<a href="http://alibad.files.wordpress.com/2010/09/readytoinstall1.jpg"><br />
<img class="alignnone size-full wp-image-602" title="Ready To Install" src="http://alibad.files.wordpress.com/2010/09/readytoinstall1.jpg?w=510&#038;h=382" alt="" width="510" height="382" /></a></li>
<li>Now that you have the configuration file, copy it to your own folder or network share where you want to start the unattended installation.</li>
<li>Cancel setup since we&#8217;re interested in the unattended silent mode of installation; not the UI one.</li>
<li>Edit the configuration file as follows:
<ul>
<li>Set QUIET to &#8220;True&#8221;. This specifies that Setup will run in a quiet mode without any user interface (i.e. unattended installation)<br />
<pre class="brush: bash;">QUIET=&quot;True&quot;</pre></li>
<li>Set SQLSYSADMINACCOUNTS to &#8220;BUILTIN\ADMINISTRATORS&#8221;. This will ensure that administrators on the machine are added as members of the sysadmin role. You can set its value based on your needs (Ex: SQLSYSADMINACCOUNTS=&#8221;domain\YourUser&#8221;), but this is the more generic approach.<br />
<pre class="brush: bash;">SQLSYSADMINACCOUNTS=&quot;BUILTIN\ADMINISTRATORS&quot;</pre></li>
<li>Add PID and set its value to your product license key. If your setup.exe already comes preloaded with the key, there is no need to add this option to the configuration file.</li>
<li>Add IACCEPTSQLSERVERLICENSETERMS and set its value to &#8220;True&#8221;. This is to required to acknowledge acceptance of the license terms when the /Q (i.e. QUIET) parameter is specified for unattended installations.<br />
<pre class="brush: bash;">IACCEPTSQLSERVERLICENSETERMS=&quot;True&quot;</pre></li>
<li>Remove the ADDCURRENTUSERASSQLADMIN parameter. The reason is that this parameter can&#8217;t be used when SQLSYSADMINACCOUNTS is specified, and it only applies to Express installations.</li>
<li>Remove the UIMODE parameter as it can&#8217;t be used with the QUITE parameter.</li>
<li>Remove INSTALLSHAREDDIR, INSTALLSHAREDWOWDIR, INSTANCEDIR parameters since we want to install on the default installation directories.</li>
<li>That&#8217;s it. If you want to change the features that this setup will install, there is no need to go with the full steps again. You can simply change the value for the FEATURES parameter. For example, the features I selected (shown in first screenshot above) will generate FEATURES=SQLENGINE,SSMS,ADV_SSMS in the configuration file.  You can change that based on your needs. The full list of available feature parameters and their descriptions is located <a href="http://msdn.microsoft.com/en-us/library/ms144259.aspx#Feature" target="_blank">here</a>.</li>
</ul>
</li>
</ul>
<p>After getting the configuration file ready, you&#8217;ll need to create a batch file that will run the silent unattended setup. Simply, create a new file  &#8221;InstallSQL2008R2.bat&#8221; with extension = &#8220;.bat&#8221; with the following content, and make sure you replace &lt;path to SQL setup folder&gt; and &lt;path to config file&gt; with the proper values.</p>
<p><pre class="brush: bash;">@ECHO off
echo Installing SQL Server 2008 R2
date/t
time /t
&quot;&lt;path to SQL setup folder&gt;\setup.exe&quot; /ConfigurationFile=&quot;&lt;path to config file&gt;&quot;
date/t
time /t</pre></p>
<p>All we&#8217;re doing in the script above is running SQL setup.exe and passing the configuration file as an argument to it. You can download both the batch and config files <a href="http://cid-e38f9fc6490b29d9.office.live.com/browse.aspx/Public/Scripts/SQL%20Server%202008%20R2%20Install" target="_blank">here</a>.</p>
<br />Filed under: <a href='http://mycodelog.com/category/database/'>Database</a>, <a href='http://mycodelog.com/category/setup/'>Setup</a> Tagged: <a href='http://mycodelog.com/tag/features/'>Features</a>, <a href='http://mycodelog.com/tag/iacceptsqlserverlicenseterms/'>IACCEPTSQLSERVERLICENSETERMS</a>, <a href='http://mycodelog.com/tag/install/'>install</a>, <a href='http://mycodelog.com/tag/quiet/'>quiet</a>, <a href='http://mycodelog.com/tag/setup-2/'>setup</a>, <a href='http://mycodelog.com/tag/silent/'>silent</a>, <a href='http://mycodelog.com/tag/sql-server-2008-r2/'>sql server 2008 r2</a>, <a href='http://mycodelog.com/tag/sqlsysadminaccounts/'>SQLSYSADMINACCOUNTS</a>, <a href='http://mycodelog.com/tag/unattended/'>unattended</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/599/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=599&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/09/28/sqlsilent/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/09/sqlfeatures.jpg" medium="image">
			<media:title type="html">Select SQL Features</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/09/readytoinstall1.jpg" medium="image">
			<media:title type="html">Ready To Install</media:title>
		</media:content>
	</item>
		<item>
		<title>Content DB Attach using PowerShell</title>
		<link>http://mycodelog.com/2010/09/18/spdbps/</link>
		<comments>http://mycodelog.com/2010/09/18/spdbps/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 07:49:50 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Get-SPWebApplication]]></category>
		<category><![CDATA[Invoke-Command]]></category>
		<category><![CDATA[Microsoft.SharePoint.PowerShell]]></category>
		<category><![CDATA[Mount-SPContentDatabase]]></category>
		<category><![CDATA[New-SPContentDatabase]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=590</guid>
		<description><![CDATA[In this post, I&#8217;ll talk about how to attach\mount a SharePoint content database to a SharePoint web application after it has been restored\attached to the SQL server. See my previous post for details on how to restore a database using PowerShell. SharePoint provides a cmdlet to do the content db attach. This cmdlet is called <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=590&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this post, I&#8217;ll talk about how to attach\mount a SharePoint content database to a SharePoint web application after it has been restored\attached to the SQL server. See my <a href="http://mycodelog.com/2010/09/18/psdb/" target="_blank">previous post</a> for details on how to restore a database using PowerShell.</p>
<p>SharePoint provides a cmdlet to do the content db attach. This cmdlet is called <a href="http://technet.microsoft.com/en-us/library/ff628582.aspx" target="_blank">Mount-SPContentDatabase</a>. I will create a script block wrapper for this cmdlet and show how to call it remotely. The script block below adds the SharePoint PowerShell snapin if it&#8217;s not already added, selects a web application in the farm, then calls the Mount-SPContentDatabase to do the content db attach.</p>
<p><pre class="brush: powershell;">[ScriptBlock] $global:AttachSPContentDB =
{
    param([string] $dbName, [string] $dbServer)

    try
    {
        # Load the Sharepoint Cmdlets
        Write-Host &quot;Loading SharePoint PowerShell Snapin&quot;
        $spSnapin = Get-PSSnapin | where {$_.Name -eq &quot;Microsoft.SharePoint.PowerShell&quot;}
        if($spSnapin -eq $null)
        {
            Add-PSSnapin Microsoft.SharePoint.PowerShell
            Write-Host -ForegroundColor &quot;Green&quot; -Object &quot;SharePoint PowerShell Snapin loaded&quot;
        }
        else
        {
            Write-Host -ForegroundColor &quot;Gray&quot; -Object &quot;SharePoint PowerShell Snapin already loaded&quot;
        }

        # Get  web applciation url
        Write-Host &quot;Selecting a web application in the farm&quot;
        $webAppUrl = (Get-SPWebApplication | select -Index 0).Url

        # Mount the database at the specified SQL server to the web application
        Write-Host &quot;Mounting database '$dbName' at SQL server '$dbServer' to web application '$webAppUrl'&quot;
        $newDB = Mount-SPContentDatabase $dbName -DatabaseServer $dbServer -WebApplication $webAppUrl -AssignNewDatabaseId
        Write-Host -ForegroundColor &quot;Green&quot; -Object &quot;Database mounted successfully with ID: &quot; + ($newDB.Id)

        # Return content DB Id
        return $newDB.Id.ToString()
    }
    catch [Exception]
    {
        Write-Host -ForegroundColor &quot;Red&quot; -Object $_.Exception

        return $null
    }
}</pre></p>
<p>To call this script block, pass the name of the Sql server and the name of the content database. Make sure that the content database is already restored\attached to the SQL server.</p>
<p><pre class="brush: powershell;">.$AttachSPContentDB &quot;ContentDBName&quot; &quot;SqlServerName&quot;</pre></p>
<p>To call the script block on a remote SharePoint WFE, you can simply run</p>
<p><pre class="brush: powershell;">Invoke-Command -ComputerName &quot;WFEName&quot; -ScriptBlock { .$AttachSPContentDB &quot;ContentDBName&quot; &quot;SqlServerName&quot; }</pre></p>
<p>Note that the <a href="http://technet.microsoft.com/en-us/library/ff607572.aspx" target="_blank">New-SPContentDatabase</a> cmdlet has the same effect as Mount-SPContentDatabase. The only difference is that New-SPContentDatabase creates a new SQL database if there is no database with the same name already available on the SQL server.</p>
<br />Filed under: <a href='http://mycodelog.com/category/database/'>Database</a>, <a href='http://mycodelog.com/category/powershell/'>PowerShell</a>, <a href='http://mycodelog.com/category/sharepoint/'>SharePoint</a> Tagged: <a href='http://mycodelog.com/tag/get-spwebapplication/'>Get-SPWebApplication</a>, <a href='http://mycodelog.com/tag/invoke-command/'>Invoke-Command</a>, <a href='http://mycodelog.com/tag/microsoft-sharepoint-powershell/'>Microsoft.SharePoint.PowerShell</a>, <a href='http://mycodelog.com/tag/mount-spcontentdatabase/'>Mount-SPContentDatabase</a>, <a href='http://mycodelog.com/tag/new-spcontentdatabase/'>New-SPContentDatabase</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/590/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=590&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/09/18/spdbps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL DB Restore using PowerShell</title>
		<link>http://mycodelog.com/2010/09/18/psdb/</link>
		<comments>http://mycodelog.com/2010/09/18/psdb/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 02:38:22 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Add-PSSnapin]]></category>
		<category><![CDATA[attach]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Invoke-Command]]></category>
		<category><![CDATA[Invoke-Sqlcmd]]></category>
		<category><![CDATA[LogicalFileName]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[network path]]></category>
		<category><![CDATA[New-PSSession]]></category>
		<category><![CDATA[PhysicalFileName]]></category>
		<category><![CDATA[ReadFileList]]></category>
		<category><![CDATA[RelocateFiles]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[scriptblock]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[Smo.Restore]]></category>
		<category><![CDATA[Smo.Server]]></category>
		<category><![CDATA[SqlRestore]]></category>
		<category><![CDATA[SqlServerCmdletSnapin100]]></category>
		<category><![CDATA[_Data.mdf]]></category>
		<category><![CDATA[_Log.ldf]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=576</guid>
		<description><![CDATA[If you are looking for a PowerShell script that lets you restore a database from a backup (.bak) file to MSSQL server, then this is the right place for you. Database Restore - SQL Let&#8217;s say you have a .bak file (Ex: AdventureWorks), and you would like to restore it to an SQL server using PowerShell. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=576&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are looking for a PowerShell script that lets you restore a database from a backup (.bak) file to MSSQL server, then this is the right place for you.</p>
<h3>Database Restore - SQL</h3>
<p>Let&#8217;s say you have a .bak file (Ex: <a href="http://cid-e38f9fc6490b29d9.office-df.live.com/self.aspx/Public/Code/PowerShell/SPDBRestore/AdventureWorksLT2008R2.bak" target="_blank">AdventureWorks</a>), and you would like to restore it to an SQL server using PowerShell. If you use SQL Server 2008 Management Studio and click on the &#8220;Script&#8221; button, you will get th SQL statement that will do that restore for you.</p>
<p><img class="alignnone size-full wp-image-577" title="DBRestore" src="http://alibad.files.wordpress.com/2010/09/dbrestore.png?w=510&#038;h=459" alt="" width="510" height="459" /></p>
<p>Here is the SQL RESTORE statement that will allow you to restore the AdventureWorksLT2008R2.bak to the new database &#8216;NewDatabaseName&#8217;.</p>
<p><pre class="brush: sql;">RESTORE DATABASE [NewDatabaseName]
FROM DISK = N'C:\.etc..\AdventureWorksLT2008R2.bak'
WITH FILE = 1,
MOVE N'AdventureWorksLT2008R2_Data'
TO N'C:\.etc..\MSSQL\DATA\NewDatabaseName.mdf',
MOVE N'AdventureWorksLT2008R2_Log'
TO N'C:\.etc..\MSSQL\DATA\NewDatabaseName_1.ldf',
NOUNLOAD, STATS = 10</pre></p>
<p>If you use SQL Server 2008 <strong>R2</strong> Management Studio, the generated SQL statement would look like this.</p>
<p><pre class="brush: sql;">RESTORE DATABASE [NewDatabaseName]
FROM  DISK = N'C:\.etc..\AdventureWorksLT2008R2.bak'
WITH  FILE = 1,  NOUNLOAD,  STATS = 10</pre></p>
<p>Running this statement is almost the same as the previous statement, except that the MDF and LDF files would be named AdventureWorksLT2008R2_Data.mdf and AdventureWorksLT2008R2_Log.ldf respectively (instead of having NewDatabaseName in the file names).</p>
<p>If we want to create a simple PowerShell function to run the SQL Restore command, we can do so using the <a href="http://msdn.microsoft.com/en-us/library/ms162806(v=SQL.100).aspx" target="_blank">OSQL Utility</a>:</p>
<p><pre class="brush: powershell;">function global:RestoreDB ([string] $newDBName, [string] $backupFilePath)
{
    [string] $dbCommand = &quot;RESTORE DATABASE [$newDBName] &quot; +
    &quot;FROM    DISK = N'$backupFilePath' &quot; +
    &quot;WITH    FILE = 1, NOUNLOAD, STATS = 10&quot;

    OSQL.EXE -E -Q $dbCommand
}</pre></p>
<p>We can also take advantage of the <a href="http://msdn.microsoft.com/en-us/library/cc281720.aspx" target="_blank">Invoke-Sqlcmd</a> command to do the same thing. Here is how the function would look like:</p>
<p><pre class="brush: powershell;">function global:RestoreDB ([string] $newDBName, [string] $backupFilePath)
{
    [string] $dbCommand = &quot;RESTORE DATABASE [$newDBName] &quot; +
                          &quot;FROM    DISK = N'$backupFilePath' &quot; +
                          &quot;WITH    FILE = 1, NOUNLOAD, STATS = 10&quot;

    Invoke-Sqlcmd -Query $dbCommand
}</pre></p>
<p>If using Invoke-Sqlcmd fails, make sure the SqlServerCmdletSnapin100 snapin is added. You can put the below snippet in the function above before the call to Invoke-Sqlcmd.</p>
<p><pre class="brush: powershell;">$sqlSnapin = Get-PSSnapin | where {$_.Name -eq &quot;SqlServerCmdletSnapin100&quot;}
if($sqlSnapin -eq $null)
{
Add-PSSnapin SqlServerCmdletSnapin100
}</pre></p>
<p>Calling this function is as simple as:</p>
<p><pre class="brush: powershell;">RestoreDB &quot;NewDatabaseName&quot; &quot;C:\.etc..\AdventureWorksLT2008R2.bak&quot;</pre></p>
<h4>Remote SQL Server</h4>
<p>In case your SQL Server is on a remote machine that <a href="http://msdn.microsoft.com/en-us/library/cc281962.aspx" target="_blank">doesn&#8217;t have</a> the SQL client installed, you can use the Invoke-Command to restore the database on the remote machine. However, the function needs to be loaded to be invoked on the remote machine, so either put it in a separate file and load it remotely or convert it to a script block that can be directly passed to Invoke-Command.</p>
<p>Assuming the remote SQL server name is SQLServer01, here are the two approaches to do this.</p>
<h5>Using a Function</h5>
<p>Put the RestoreDB function in a new PowerShell file; Let&#8217;s call it DatabaseRestore.ps1. To call remotely, first we need to create a PowerShell session on the remote SQL Server machine.</p>
<p><pre class="brush: powershell;">$session = New-PSSession -ComputerName &quot;SQLServer01&quot;</pre></p>
<p>If you are using SQL Server 2008 R2, you might get the following error: &#8220;<em>Connecting to remote server failed with the following error message : The WinRM client cannot complete the operation within the time specified. Check if the machine name is valid and is reachable over the network and firewall exception for Windows Remote Management service is enabled</em>&#8220;. The resolution is located <a href="http://support.microsoft.com/kb/976839" target="_blank">here</a>. In short, go to your SQL Server 2008 R2 machine, launch the Command Prompt as administrator then run this command: <strong>winrm quickconfig</strong>.</p>
<p>After creating the session, we need to load the DatabaseRestore.ps1 script on the remote machine to be able to call the RestoreDB function.</p>
<p><pre class="brush: powershell;">$scriptPath = &quot;C:\..etc..\DatabaseRestore.ps1&quot;
Invoke-Command -Session $session -FilePath $scriptPath</pre></p>
<p>If you get an error that the file cannot be loaded because the execution of scripts is disabled on the system, then you should make sure that the execution policy is remotesigned or unrestricted (<a href="http://technet.microsoft.com/en-us/library/ee176961.aspx" target="_blank">Set-ExecutionPolicy</a> unrestricted).</p>
<p>Next step would be to simply call the function. Note that the path to the backup file must be accessible to the remote SQL machine.</p>
<p><pre class="brush: powershell;">Invoke-Command -Session $session -ScriptBlock { RestoreDB &quot;NewDatabaseName&quot; &quot;C:\..etc..\AdventureWorksLT2008R2.bak&quot; }</pre></p>
<h5>Using a Script Block</h5>
<p>In our case, using a script block is simpler. All we need to do is define the script block, then run one single Invoke-Command to do the database restore. The script block definition is almost the same as the function definition, as shown below:</p>
<p><pre class="brush: powershell;">[ScriptBlock] $global:RestoreDB = {

    param ([string] $newDBName, [string] $backupFilePath)

    [string] $dbCommand = &quot;RESTORE DATABASE [$newDBName] &quot; +
                          &quot;FROM    DISK = N'$backupFilePath' &quot; +
                          &quot;WITH    FILE = 1, NOUNLOAD, STATS = 10&quot;

    $sqlSnapin = Get-PSSnapin | where {$_.Name -eq &quot;SqlServerCmdletSnapin100&quot;}
    if($sqlSnapin -eq $null)
    {
         Add-PSSnapin SqlServerCmdletSnapin100
    }

    Invoke-Sqlcmd -Query $dbCommand
}</pre></p>
<p>Make sure you don&#8217;t forget the equal sign (=) in the first line of the above script block definition. Now, to restore the DB, we call a single Invoke-Command cmdlet. Make sure that the -ArgumentList parameters are separated by comma (,) or the script will fail.</p>
<p><pre class="brush: powershell;">Invoke-Command -ComputerName &quot;SQLServer01&quot; -ScriptBlock $RestoreDB -ArgumentList &quot;NewDatabaseName&quot;, &quot;C:\AdventureWorksLT2008R2.bak&quot; </pre></p>
<h5>Function vs. Script Block</h5>
<p>Here are some simple guidelines on when to use a function and when to use a script block.</p>
<ul>
<li>To call a function on a remote machine, it must first be defined on the remote machine. That&#8217;s why we need an Invoke-Command to load the PowerShell file containing the function, then another Invoke-Command to call the function.</li>
<li>To call a script block remotely, it doesn&#8217;t have to be defined on the remote machine. When the script block is passed as a parameter to Invoke-Command, the whole script block actually gets copied to the remote machine.</li>
<li>If your logic has any dependency on any global variable or function (Ex: it calls another script block or it calls a helper function), then it makes most sense to use a function. Define the function, global variables and helper functions in one file, then load them on the remote machine.</li>
<li>If your logic is self-contained, then use a script block. The whole logic will get copied to the remote machine.</li>
</ul>
<h3>Database Restore &#8211; SMO</h3>
<p>To have more control on how we do the database restore, we should use the <a href="http://msdn.microsoft.com/en-us/library/ms162169.aspx" target="_blank">SMO</a> object model. For example, our script above restores the database with name &#8220;NewDatabaseName&#8221; but the MDF and LDF file names are still AdventureWorksLT2008R2_Data.mdf and AdventureWorksLT2008R2_Log.ldf. Now, you would think, why not use the SQL statement below in our script?</p>
<p><pre class="brush: sql;">RESTORE DATABASE [NewDatabaseName]
FROM DISK = N'C:\.etc..\AdventureWorksLT2008R2.bak'
WITH FILE = 1,
MOVE N'AdventureWorksLT2008R2_Data'
TO N'C:\.etc..\MSSQL\DATA\NewDatabaseName.mdf',
MOVE N'AdventureWorksLT2008R2_Log'
TO N'C:\.etc..\MSSQL\DATA\NewDatabaseName_1.ldf',
NOUNLOAD, STATS = 10</pre></p>
<p>To put this in a script block, it will look as follows:</p>
<p><pre class="brush: powershell;">[ScriptBlock] $global:RestoreDB = {

param ([string] $newDBName, [string] $backupFilePath, [string] $sqlDataPath, [string] $dataLogicalName, [string] $logLogicalName)

[string] $dbCommand = &quot;RESTORE DATABASE [$newDBName] &quot; +
&quot;FROM    DISK = N'$backupFilePath' &quot; +
&quot;WITH    FILE = 1, &quot; +
&quot;MOVE N'$dataLogicalName' &quot; +
&quot;TO N'$sqlDataPath\$newDBName.mdf', &quot; +
&quot;MOVE N'$logLogicalName' &quot; +
&quot;TO N'$sqlDataPath\$newDBName.ldf', &quot; +
&quot;NOUNLOAD, STATS = 10&quot;

$sqlSnapin = Get-PSSnapin | where {$_.Name -eq &quot;SqlServerCmdletSnapin100&quot;}
if($sqlSnapin -eq $null)
{
Add-PSSnapin SqlServerCmdletSnapin100
}

Invoke-Sqlcmd -Query $dbCommand
}</pre></p>
<p>Ok, this might be good enough, but it&#8217;s not dynamic\generic. You can get the SQL data path from the registry, but you cannot get the logical names of the data and log files unless you find a way to open the .bak file and read the logical names of those files. Instead of hardcoding the logical names of the Data and Log files (i.e. pass &#8220;AdventureWorksLT2008R2_Data&#8221; and &#8220;AdventureWorksLT2008R2_Log&#8221;), we can read the file list from the .bak file using SMO (<a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.readfilelist.aspx" target="_blank">ReadFileList() </a>method).</p>
<p>PowerShell comments below provide enough details. Note that if the backup file is on a network share, the ReadFileList() method would fail. So in that case, we need to copy the file locally. That&#8217;s why the script block takes &#8220;$isNetworkPath&#8221; boolean variable to take that into consideration.</p>
<p><pre class="brush: powershell;">[ScriptBlock] $global:RestoreDBSMO = {
    param([string] $newDBName, [string] $backupFilePath, [bool] $isNetworkPath = $true)

    try
    {
        # Load assemblies
        [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.SMO&quot;) | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.SmoExtended&quot;) | Out-Null
        [Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.ConnectionInfo&quot;) | Out-Null
        [Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SqlServer.SmoEnum&quot;) | Out-Null

        # Create sql server object
        $server = New-Object (&quot;Microsoft.SqlServer.Management.Smo.Server&quot;) &quot;(local)&quot;

        # Copy database locally if backup file is on a network share
        if($isNetworkPath)
        {
            $fileName = [IO.Path]::GetFileName($backupFilePath)
            $localPath = Join-Path -Path $server.DefaultFile -ChildPath $fileName
            Copy-Item $backupFilePath $localPath
            $backupFilePath = $localPath
        }

        # Create restore object and specify its settings
        $smoRestore = new-object(&quot;Microsoft.SqlServer.Management.Smo.Restore&quot;)
        $smoRestore.Database = $newDBName
        $smoRestore.NoRecovery = $false;
        $smoRestore.ReplaceDatabase = $true;
        $smoRestore.Action = &quot;Database&quot;

        # Create location to restore from
        $backupDevice = New-Object(&quot;Microsoft.SqlServer.Management.Smo.BackupDeviceItem&quot;) ($backupFilePath, &quot;File&quot;)
        $smoRestore.Devices.Add($backupDevice)

        # Give empty string a nice name
        $empty = &quot;&quot;

        # Specify new data file (mdf)
        $smoRestoreDataFile = New-Object(&quot;Microsoft.SqlServer.Management.Smo.RelocateFile&quot;)
        $defaultData = $server.DefaultFile
        if (($defaultData -eq $null) -or ($defaultData -eq $empty))
        {
            $defaultData = $server.MasterDBPath
        }
        $smoRestoreDataFile.PhysicalFileName = Join-Path -Path $defaultData -ChildPath ($newDBName + &quot;_Data.mdf&quot;)

        # Specify new log file (ldf)
        $smoRestoreLogFile = New-Object(&quot;Microsoft.SqlServer.Management.Smo.RelocateFile&quot;)
        $defaultLog = $server.DefaultLog
        if (($defaultLog -eq $null) -or ($defaultLog -eq $empty))
        {
            $defaultLog = $server.MasterDBLogPath
        }
        $smoRestoreLogFile.PhysicalFileName = Join-Path -Path $defaultLog -ChildPath ($newDBName + &quot;_Log.ldf&quot;)

        # Get the file list from backup file
        $dbFileList = $smoRestore.ReadFileList($server)

        # The logical file names should be the logical filename stored in the backup media
        $smoRestoreDataFile.LogicalFileName = $dbFileList.Select(&quot;Type = 'D'&quot;)[0].LogicalName
        $smoRestoreLogFile.LogicalFileName = $dbFileList.Select(&quot;Type = 'L'&quot;)[0].LogicalName

        # Add the new data and log files to relocate to
        $smoRestore.RelocateFiles.Add($smoRestoreDataFile)
        $smoRestore.RelocateFiles.Add($smoRestoreLogFile)

        # Restore the database
        $smoRestore.SqlRestore($server)

        &quot;Database restore completed successfully&quot;
    }
    catch [Exception]
    {
        &quot;Database restore failed:`n`n &quot; + $_.Exception
    }
    finally
    {
        # Clean up copied backup file after restore completes successfully
        if($isNetworkPath)
        {
            Remove-Item $backupFilePath
        }
    }
}</pre></p>
<p>Here is how to call this script block (Don&#8217;t forget the dot (.) infront of the script block variable):</p>
<p><pre class="brush: powershell;">.$RestoreDBSMO &quot;NewDatabaseName&quot; &quot;C:\.etc..\AdventureWorksLT2008R2.bak&quot; $false</pre></p>
<p>Same story goes for calling this function remotely.</p>
<br />Filed under: <a href='http://mycodelog.com/category/database/'>Database</a>, <a href='http://mycodelog.com/category/powershell/'>PowerShell</a> Tagged: <a href='http://mycodelog.com/tag/add-pssnapin/'>Add-PSSnapin</a>, <a href='http://mycodelog.com/tag/attach/'>attach</a>, <a href='http://mycodelog.com/tag/database-2/'>database</a>, <a href='http://mycodelog.com/tag/function/'>function</a>, <a href='http://mycodelog.com/tag/invoke-command/'>Invoke-Command</a>, <a href='http://mycodelog.com/tag/invoke-sqlcmd/'>Invoke-Sqlcmd</a>, <a href='http://mycodelog.com/tag/logicalfilename/'>LogicalFileName</a>, <a href='http://mycodelog.com/tag/mssql/'>MSSQL</a>, <a href='http://mycodelog.com/tag/network-path/'>network path</a>, <a href='http://mycodelog.com/tag/new-pssession/'>New-PSSession</a>, <a href='http://mycodelog.com/tag/physicalfilename/'>PhysicalFileName</a>, <a href='http://mycodelog.com/tag/powershell/'>PowerShell</a>, <a href='http://mycodelog.com/tag/readfilelist/'>ReadFileList</a>, <a href='http://mycodelog.com/tag/relocatefiles/'>RelocateFiles</a>, <a href='http://mycodelog.com/tag/restore/'>restore</a>, <a href='http://mycodelog.com/tag/scriptblock/'>scriptblock</a>, <a href='http://mycodelog.com/tag/smo/'>SMO</a>, <a href='http://mycodelog.com/tag/smo-restore/'>Smo.Restore</a>, <a href='http://mycodelog.com/tag/smo-server/'>Smo.Server</a>, <a href='http://mycodelog.com/tag/sqlrestore/'>SqlRestore</a>, <a href='http://mycodelog.com/tag/sqlservercmdletsnapin100/'>SqlServerCmdletSnapin100</a>, <a href='http://mycodelog.com/tag/_data-mdf/'>_Data.mdf</a>, <a href='http://mycodelog.com/tag/_log-ldf/'>_Log.ldf</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/576/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/576/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=576&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/09/18/psdb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/09/dbrestore.png" medium="image">
			<media:title type="html">DBRestore</media:title>
		</media:content>
	</item>
		<item>
		<title>SharePoint Foundation 2010 on Windows 7</title>
		<link>http://mycodelog.com/2010/06/08/spwin7/</link>
		<comments>http://mycodelog.com/2010/06/08/spwin7/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 07:08:04 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[Setup]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[AllowWindowsClientInstall]]></category>
		<category><![CDATA[optimizeCompilations]]></category>
		<category><![CDATA[SharePoint Designer]]></category>
		<category><![CDATA[SharePointFoundation]]></category>
		<category><![CDATA[standalone]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">https://alibad.wordpress.com/2010/06/08/sharepoint-foundation-2010-on-windows-7/</guid>
		<description><![CDATA[This MSDN article describes in detail how to install SharePoint Foundation 2010 for development purposes on Windows Vista, Windows 7 and Windows Server 2008. The purpose of this post is to focus on the SharePoint installation on Window 7 only and clear out all the details for the other operating systems. Download SharePoint Foundation 2010 <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=569&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://msdn.microsoft.com/en-us/library/ee554869.aspx" target="_blank">MSDN article</a> describes in detail how to install SharePoint Foundation 2010 for development purposes on Windows Vista, Windows 7 and Windows Server 2008. The purpose of this post is to focus on the SharePoint installation on Window 7 only and clear out all the details for the other operating systems.</p>
<ol>
<li>Download <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=49c79a8a-4612-4e7d-a0b4-3bb429b46595&amp;displaylang=en" target="_blank">SharePoint Foundation 2010 x64</a> for free. Note that there is no x86 version of SharePoint Server, so don’t bother setting it up if you have a 32-bit machine.</li>
<li>Create a new folder “C:\SharePointFiles” and copy “SharePointFoundation.exe” to it.</li>
<li>Start command prompt, change directory to C:\SharePointFiles and run the following command to extract the “SharePointFoundation.exe” to C:\SharePointFiles<br />
<em>SharePointFoundation.exe /extract:C:\SharePointFiles</em></li>
<li>Open C:\SharePointFiles\files\Setup\config.xml, add a new &lt;Setting&gt; tag under the &lt;Configuration&gt; element, then save the file. Make sure you copy the below element as is since all of the text in the configuration file is case-sensitive.<br />
<em>&lt;Setting Id=&#8221;AllowWindowsClientInstall&#8221; Value=&#8221;True&#8221;/&gt;</em></li>
<li>Install the following Prerequisites:
<ul>
<li>Microsoft FilterPack 2.0: C:\SharePointFiles\PrerequisiteInstallerFiles\FilterPack\FilterPack.msi</li>
<li>Microsoft Sync Framework: <a title="http://go.microsoft.com/fwlink/?LinkID=141237" href="http://go.microsoft.com/fwlink/?LinkID=141237">http://go.microsoft.com/fwlink/?LinkID=141237</a></li>
<li>SQL Server Native Client: <a title="http://go.microsoft.com/fwlink/?LinkId=123718" href="http://go.microsoft.com/fwlink/?LinkId=123718">http://go.microsoft.com/fwlink/?LinkId=123718</a></li>
<li>Windows Identity Foundation: <a title="http://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu" href="http://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu">http://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu</a></li>
<li>WCF Hotfix (KB971831): <a title="http://go.microsoft.com/fwlink/?LinkID=166231" href="http://go.microsoft.com/fwlink/?LinkID=166231">http://go.microsoft.com/fwlink/?LinkID=166231</a></li>
<li>ADO.NET Data Services Update for .NET Framework 3.5 SP1 to enable REST-based data services: <a title="http://download.microsoft.com/download/1/3/C/13CBF47A-15D0-4237-ABFC-ED6E3E3A6520/Windows6.1-KB976127-v6-x64.msu" href="http://download.microsoft.com/download/1/3/C/13CBF47A-15D0-4237-ABFC-ED6E3E3A6520/Windows6.1-KB976127-v6-x64.msu">http://download.microsoft.com/download/1/3/C/13CBF47A-15D0-4237-ABFC-ED6E3E3A6520/Windows6.1-KB976127-v6-x64.msu</a></li>
</ul>
</li>
<li>Enable the required windows features by running this batch file: <a href="http://cid-e38f9fc6490b29d9.skydrive.live.com/self.aspx/Public/Scripts/EnableSPWinFeatures.bat">http://cid-e38f9fc6490b29d9.skydrive.live.com/self.aspx/Public/Scripts/EnableSPWinFeatures.bat</a></li>
<li>Restart your computer to complete the changes that you made to Windows Features.</li>
<li>Install SharePoint 2010
<ul>
<li>Run Setup.exe under C:\SharePointFiles</li>
<li>Select standalone (Windows 7 can’t be used for production deployments of SharePoint 2010 and it’s recommended that you use Standalone only)</li>
<li>After the installation is complete, you will be prompted to start the SharePoint Products and Technologies Configuration Wizard.<br />
<img style="display:inline;border-width:0;" title="InstallSP" src="http://alibad.files.wordpress.com/2010/06/installsp.jpg?w=620&#038;h=503" border="0" alt="InstallSP" width="620" height="503" /></li>
</ul>
</li>
<li>After a SharePoint solution (.wsp file) is deployed, it recycles the application pool. To improve the initial page load times, set the optimizeCompilations property of the &lt;compilation&gt; tag in your web.config file (C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config) to true.<br />
<em>&lt;compilation optimizeCompilations=&#8221;true&#8221;&gt;</em><em><a href="http://alibad.files.wordpress.com/2010/06/sp1.jpg" target="_blank"><img class="alignnone size-large wp-image-571" title="SharePoint Home Page" src="http://alibad.files.wordpress.com/2010/06/sp1.jpg?w=512&#038;h=243" alt="" width="512" height="243" /></a></em></li>
</ol>
<p>SharePoint Designer 2010 is also free and can help you better design your SharePoint site(s). You can download it <a href="http://www.microsoft.com/downloads/details.aspx?familyid=566D3F55-77A5-4298-BB9C-F55F096B125D&amp;displaylang=en" target="_blank">here</a>.</p>
<p><a href="http://alibad.files.wordpress.com/2010/06/spd1.png" target="_blank"><img class="alignnone size-full wp-image-572" title="SharePoint Designer" src="http://alibad.files.wordpress.com/2010/06/spd1.png?w=510" alt=""   /></a></p>
<br />Filed under: <a href='http://mycodelog.com/category/setup/'>Setup</a>, <a href='http://mycodelog.com/category/sharepoint/'>SharePoint</a> Tagged: <a href='http://mycodelog.com/tag/allowwindowsclientinstall/'>AllowWindowsClientInstall</a>, <a href='http://mycodelog.com/tag/optimizecompilations/'>optimizeCompilations</a>, <a href='http://mycodelog.com/tag/sharepoint-designer/'>SharePoint Designer</a>, <a href='http://mycodelog.com/tag/sharepointfoundation/'>SharePointFoundation</a>, <a href='http://mycodelog.com/tag/standalone/'>standalone</a>, <a href='http://mycodelog.com/tag/windows-7/'>windows 7</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/569/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/569/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/569/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/569/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/569/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/569/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/569/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/569/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=569&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/06/08/spwin7/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/06/installsp.jpg" medium="image">
			<media:title type="html">InstallSP</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/06/sp1.jpg?w=1024" medium="image">
			<media:title type="html">SharePoint Home Page</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/06/spd1.png" medium="image">
			<media:title type="html">SharePoint Designer</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenGL Camera</title>
		<link>http://mycodelog.com/2010/05/28/glcamera/</link>
		<comments>http://mycodelog.com/2010/05/28/glcamera/#comments</comments>
		<pubDate>Fri, 28 May 2010 23:52:13 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Back]]></category>
		<category><![CDATA[Bottom]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[Front]]></category>
		<category><![CDATA[glOrtho]]></category>
		<category><![CDATA[glRotatef]]></category>
		<category><![CDATA[glScalef]]></category>
		<category><![CDATA[glTranslatef]]></category>
		<category><![CDATA[gluLookAt]]></category>
		<category><![CDATA[gluPerspective]]></category>
		<category><![CDATA[GL_MODELVIEW]]></category>
		<category><![CDATA[GL_PROJECTION]]></category>
		<category><![CDATA[Left]]></category>
		<category><![CDATA[Right]]></category>
		<category><![CDATA[Top]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=520</guid>
		<description><![CDATA[The concept of a camera in a Graphics application is simple. Just imagine that what you see is the view of the camera. So adjusting the camera lens or moving\rotating it should affect your view. In the base OpenGL library, there is no concept of a camera. However, it can be simulated by applying the <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=520&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The concept of a camera in a Graphics application is simple. Just imagine that what you see is the view of the camera. So adjusting the camera lens or moving\rotating it should affect your view. In the base OpenGL library, there is no concept of a camera. However, it can be simulated by applying the inverse of the camera transformation on the objects\pixels in the scene. Instead of having to build the matrix and invert it ourselves, the GLU library provides the <a title="See specification of gluLookAt and how it is implemented" href="http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.xml" target="_blank">gluLookAt</a> function, which would do the work for us. This function takes as a parameter the location (x, y, z) of the camera\eye, the location (x, y, z) of the point to look at, and the coordinates (x, y, z) of the Up vector (rotation of the camera around <em>its </em>origin). Note that this function should be called on the ModelView matrix before any transformation is applied on objects in the scene. Avoid calling this function on the Projection matrix (more details <a href="http://sjbaker.org/steve/omniv/projection_abuse.html" target="_blank">here</a>).</p>
<p>Given the description above, after specifying the camera attributes with a call to <em>gluLookAt </em>then drawing the objects in the scene, one would expect to see the objects in the scene based on the view of the camera. This expectation is completely valid, however, there is one more variable that affects what we see: the viewing volume (similar to real-world camera <a href="http://en.wikipedia.org/wiki/Camera#Focus" target="_blank">focus</a>), which is controlled by calls on the <a href="http://glprogramming.com/red/chapter03.html#name3" target="_blank">projection</a> matrix. Try to imagine what you&#8217;ll see if you run the code below:</p>
<p><pre class="brush: cpp;">GLdouble eyeX = 0, eyeY = 0, eyeZ = 2;
GLdouble centerX = 0, centerY = 0, centerZ = 0;
GLdouble upX = 0, upY = 1, pZ = 0;

void display()
{
    //  Set up camera properties
    glMatrixMode (GL_MODELVIEW);
    gluLookAt (eyeX, eyeY, eyeZ,
               centerX, centerY, centerZ,
               upX, upY, upZ);

    //  Draw an Object at the origin
    drawObject ();
}</pre></p>
<p>The answer to the question above is that you&#8217;ll see <em>nothing</em>! The reason is that <em>eyeZ </em>= 2, the viewing volume is <em>glOrtho</em>(-1, 1, -1, 1, -1, 1) by default, and the object is drawn at the origin. Here is a visual demonstration using Nate Robin&#8217;s <a href="http://www.xmission.com/~nate/tutors.html" target="_blank">interactive OpenGL tutorial</a> (projection.exe).</p>
<p><img class="alignnone size-full wp-image-544" title="Projection - Object Not Visible" src="http://alibad.files.wordpress.com/2010/05/projectionnv.png?w=510&#038;h=528" alt="" width="510" height="528" /></p>
<p>If we change <em>zFar </em>(last parameter of <em>glOrtho</em>) of projection to 3 or if we change <em>eyeZ </em>of the camera to 0.5, then we&#8217;ll be able to see the object.</p>
<p><img class="alignnone size-full wp-image-545" title="Projection - Object Visible" src="http://alibad.files.wordpress.com/2010/05/projectionv.png?w=510&#038;h=528" alt="" width="510" height="528" /></p>
<p>To summarize all of this, I am taking advantage of one of the slides of the Siggraph OpenGL <a href="http://www.opengl.org/resources/code/samples/s2001/notes/opengl.pdf" target="_blank">tutorial</a>.</p>
<p><img class="alignnone size-full wp-image-546" title="Siggraph Camera Slide" src="http://alibad.files.wordpress.com/2010/05/siggraphcameraslide.gif?w=510&#038;h=378" alt="" width="510" height="378" /></p>
<p>If you&#8217;ve used one of those 3D modeling software out there (like 3ds Max, Maya, etc&#8230;), then you&#8217;ve certainly seen multiple orthogonal views (Front, Back, Top, Bottom, Left, Right) of your 3D drawing. Here is a screenshot from 3ds Max.</p>
<p><img class="alignnone size-full wp-image-548" title="3dsMaxViews" src="http://alibad.files.wordpress.com/2010/05/3dsmaxviews.png?w=510&#038;h=364" alt="" width="510" height="364" /></p>
<p>Using the OpenGL camera, I&#8217;m going to create an OpenGL app that has 6 sub-windows each displaying the same object, but from a different camera angle. The world coordinates will be glOrtho(-1, 1, -1, 1, -2, 2) and the views will be: Front, Back, Top, Bottom, Left, and Right. The parameters that are going to be passed to <em>gluLookAt </em>will vary based on the view:</p>
<p><img class="alignnone size-full wp-image-549" title="Camera Views Table" src="http://alibad.files.wordpress.com/2010/05/cameraviewstable.png?w=510&#038;h=283" alt="" width="510" height="283" /></p>
<p>The program looks as follows.</p>
<p><img class="alignnone size-full wp-image-550" title="OpenGL Camera Views" src="http://alibad.files.wordpress.com/2010/05/cameraviews.png?w=510&#038;h=365" alt="" width="510" height="365" /></p>
<p>Note that you can use the left mouse button to rotate the object, right mouse button to translate the object, and middle mouse button to scale it. Also, the &#8216;r&#8217; key will reset the object transformations in the scene. You can find the full source code <a href="http://cid-e38f9fc6490b29d9.skydrive.live.com/self.aspx/Public/Code/OpenGL%20Camera/Camera.zip" target="_blank">here</a>. If you have any issues compiling or running the app, check out this <a href="http://www.codeproject.com/KB/openGL/GLUT_WINDOW_TEMPLATE.aspx#Usage4" target="_blank">section</a> for details about compiling and running an OpenGL app that uses the GLUT library. <a style="display:none;" rel="tag" href="http://www.codeproject.com/script/Articles/BlogArticleList.aspx?amid=2040670">CodeProject</a></p>
<br />Filed under: <a href='http://mycodelog.com/category/c/'>C</a>, <a href='http://mycodelog.com/category/opengl/'>OpenGL</a> Tagged: <a href='http://mycodelog.com/tag/back/'>Back</a>, <a href='http://mycodelog.com/tag/bottom/'>Bottom</a>, <a href='http://mycodelog.com/tag/camera/'>camera</a>, <a href='http://mycodelog.com/tag/front/'>Front</a>, <a href='http://mycodelog.com/tag/glortho/'>glOrtho</a>, <a href='http://mycodelog.com/tag/glrotatef/'>glRotatef</a>, <a href='http://mycodelog.com/tag/glscalef/'>glScalef</a>, <a href='http://mycodelog.com/tag/gltranslatef/'>glTranslatef</a>, <a href='http://mycodelog.com/tag/glulookat/'>gluLookAt</a>, <a href='http://mycodelog.com/tag/gluperspective/'>gluPerspective</a>, <a href='http://mycodelog.com/tag/gl_modelview/'>GL_MODELVIEW</a>, <a href='http://mycodelog.com/tag/gl_projection/'>GL_PROJECTION</a>, <a href='http://mycodelog.com/tag/left/'>Left</a>, <a href='http://mycodelog.com/tag/right/'>Right</a>, <a href='http://mycodelog.com/tag/top/'>Top</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/520/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/520/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/520/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=520&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/05/28/glcamera/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/projectionnv.png" medium="image">
			<media:title type="html">Projection - Object Not Visible</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/projectionv.png" medium="image">
			<media:title type="html">Projection - Object Visible</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/siggraphcameraslide.gif" medium="image">
			<media:title type="html">Siggraph Camera Slide</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/3dsmaxviews.png" medium="image">
			<media:title type="html">3dsMaxViews</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/cameraviewstable.png" medium="image">
			<media:title type="html">Camera Views Table</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/cameraviews.png" medium="image">
			<media:title type="html">OpenGL Camera Views</media:title>
		</media:content>
	</item>
		<item>
		<title>GLUT Menu World</title>
		<link>http://mycodelog.com/2010/05/27/glut-menu/</link>
		<comments>http://mycodelog.com/2010/05/27/glut-menu/#comments</comments>
		<pubDate>Fri, 28 May 2010 05:14:57 +0000</pubDate>
		<dc:creator>Ali BaderEddin</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://mycodelog.com/?p=516</guid>
		<description><![CDATA[This post demonstrates how to create a GLUT menu and add to it sub-menus and menu items. In the above sample app, clicking on a menu item in the popup menu will log that menu item&#8217;s ID to the console window. Below is the function setupMenus() that creates the main menu and adds to it <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=516&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post demonstrates how to create a GLUT menu and add to it sub-menus and menu items.</p>
<p><img class="alignnone size-full wp-image-517" title="GLUT Menu World" src="http://alibad.files.wordpress.com/2010/05/menuworld.gif?w=510" alt=""   /></p>
<p>In the above sample app, clicking on a menu item in the popup menu will log that menu item&#8217;s ID to the console window. Below is the function <em>setupMenus() </em>that creates the main menu and adds to it all the sub-menus and menu items. You can change it based on your needs then call it in the <em>init()</em> method.</p>
<p><pre class="brush: cpp;">//-------------------------------------------------------------------------
//  Set up the GLUT Menus.
//-------------------------------------------------------------------------
void setupMenus ()
{
    int subMenuCount;  //  Count of sub menus
    int menuItemCount; //  Count of menu items in a submenu
    int *menuIds;      //  Submenu IDs
    char str[256];     //  The string of the current menu item
    int i, j;          //  Iterators

    //  Generate a random value for submenu count
    subMenuCount = rand() % 20;

    //  Allocate memory for the submenu IDs
    menuIds = (int *) xmalloc (subMenuCount * sizeof (int));

    //  Create all the sub menus
    for (i = 0; i &lt; subMenuCount; i++)
        menuIds[i] = glutCreateMenu (showMenuItem);

    for (i = 1; i &lt; subMenuCount; i++)
    {
        //  Set sub menu string
        sprintf (str, &quot;SubMenu %d&quot;, i);

        //  Add the current submenu to previous submenu
        glutSetMenu (menuIds[i-1]);
        glutAddSubMenu (str, menuIds[i]);

        //  New menu item count for the new submenu
        menuItemCount = rand () % 20;

        //  Add menu items to the current submenu
        for (j = 1; j &lt; menuItemCount; j++)
        {
            sprintf (str, &quot;Menu Item %d&quot;, j);
            glutAddMenuEntry (str, j);
        }
    }

    //  Set main menu as the current menu
    glutSetMenu (menuIds[0]);

    //  Attach the menu to the RMB
    glutAttachMenu(GLUT_RIGHT_BUTTON);
}</pre></p>
<p>Major GLUT functions briefly explained:</p>
<ul>
<li><em>glutCreateMenu </em>creates the main menu or sub-menu and returns its ID. It takes as a parameter a pointer to a function with the signature<em> void func (int menuItemId). <span style="font-style:normal;">This function is called every time the  user clicks a menu item in the menu and the parameter </span>menuItemId <span style="font-style:normal;">passed to it represents the id of the menu item.</span></em></li>
<li><em>glutAddSubMenu</em> adds another menu to current menu<em>.</em></li>
<li><em>glutAddMenuEntry</em> adds a menu item to the current menu.</li>
<li><em>glutSetMenu </em>sets the current menu. So when we call <em>glutAddSubMenu </em>or g<em>lutAddMenuEntry</em>, they get added to the current menu.</li>
<li><em>glutAttachMenu(GLUT_RIGHT_BUTTON)</em> attaches the &#8220;current&#8221; menu to the right click button. So when you right click the mouse, the popup menu will show up.</li>
</ul>
<p>This is the function that we are passing to <em>glutCreateMenu </em>in our sample app. Every time the user clicks on a menu item, this function is called and it will simply display the menu item id on the console window.</p>
<p><pre class="brush: cpp;">//-------------------------------------------------------------------------
//  Displays the menu item id on the console window
//-------------------------------------------------------------------------
void showMenuItem (int val)
{
    printf (&quot;Menu Item: %d\n&quot;, val);
}</pre></p>
<p>Download the full source code <a href="http://cid-e38f9fc6490b29d9.skydrive.live.com/self.aspx/Public/Code/GLUT%20Menu%20World/MenuWorld.zip" target="_blank">here</a>.</p>
<br />Filed under: <a href='http://mycodelog.com/category/c/'>C</a>, <a href='http://mycodelog.com/category/opengl/'>OpenGL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/alibad.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/alibad.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/alibad.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/alibad.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/alibad.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/alibad.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/alibad.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/alibad.wordpress.com/516/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelog.com&amp;blog=2121200&amp;post=516&amp;subd=alibad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelog.com/2010/05/27/glut-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/61ffef88679fbbf5c23f55562d3ebca7?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">alibad</media:title>
		</media:content>

		<media:content url="http://alibad.files.wordpress.com/2010/05/menuworld.gif" medium="image">
			<media:title type="html">GLUT Menu World</media:title>
		</media:content>
	</item>
	</channel>
</rss>
