<?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>AndrewMorgan.ie</title>
	<atom:link href="http://andrewmorgan.ie/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewmorgan.ie</link>
	<description>Programs, scripts, fixes... and a rant from time to time.</description>
	<lastBuildDate>Fri, 27 Jan 2012 14:58:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='andrewmorgan.ie' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>AndrewMorgan.ie</title>
		<link>http://andrewmorgan.ie</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://andrewmorgan.ie/osd.xml" title="AndrewMorgan.ie" />
	<atom:link rel='hub' href='http://andrewmorgan.ie/?pushpress=hub'/>
		<item>
		<title>Removing users access to &#8220;Devices and Printers&#8221; in a Server 2008 R2 / Win 7 Environment.</title>
		<link>http://andrewmorgan.ie/2012/01/27/removing-users-access-to-devices-and-printers-in-a-server-2008-r2-win-7-environment/</link>
		<comments>http://andrewmorgan.ie/2012/01/27/removing-users-access-to-devices-and-printers-in-a-server-2008-r2-win-7-environment/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 11:49:58 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[PowerShell Scripting]]></category>
		<category><![CDATA[Workspace Manager]]></category>
		<category><![CDATA[XenApp]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[RES Software]]></category>
		<category><![CDATA[RES WorkspaceManager]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1312</guid>
		<description><![CDATA[I love a good challenge. Recently I read the following article from Microsoft about how to tackle the title of this blog. This hack didn&#8217;t actually stop the users from accessing the cpl as clever users will just use rundll32 to get around the limitation. This also knocked other &#8220;show the following control panel items&#8221; policies out. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1312&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://andymorgan.files.wordpress.com/2012/01/winlogo.png?w=75&#038;h=75&#038;h=75" alt="" width="75" height="75" />I love a good challenge. Recently I read the<a href="http://support.microsoft.com/kb/2018577" target="_blank"> following article</a> from Microsoft about how to tackle the title of this blog. This hack didn&#8217;t actually stop the users from accessing the cpl as clever users will just use rundll32 to get around the limitation. This also knocked other &#8220;show the following control panel items&#8221; policies out.</p>
<p>This really inst a huge issue to most environments, as users will probably want to enumerate their printers at one stage or another. But in a RES Workspace manager environment, RES provide a much better interface for printer management which really defunct&#8217;s and eliminates the need for the windows method.</p>
<p>The culprit can be seen below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/culprit.png"><img class="aligncenter size-full wp-image-1325" title="culprit" src="http://andymorgan.files.wordpress.com/2012/01/culprit.png?w=600" alt=""   /></a></p>
<p>This problem for me, all stems from the &#8220;<a href="http://technet.microsoft.com/en-us/library/cc938271.aspx" target="_blank">NoSetFolders</a>&#8221; chestnut, anyone who&#8217;s tried to lock down a Terminal services environment from Windows Server 2000 onwards will be aware that this <em>&#8220;handy&#8221;</em> group policy removes the users ability to use [Windows Key] and [E] to open explorer. This issue still isn&#8217;t fixed in 2008 R2 and I&#8217;m beginning to think Microsoft just wont fix it. Hey no big deal right? Yes, quite a big deal if you ask pedantic users.</p>
<p><em>Anyway</em>, I digress. Once you remove the NoSetFolders key, the user has the ability to see the devices and printers as below on the start menu, hence my situation.</p>
<p>To remove this folder view for all users, its time to hack the registry!</p>
<p>The Class ID belonging to this start menu item can be found here:</p>
<pre>HKEY_CLASSES_ROOT\CLSID\{A8A91A66-3A7D-4424-8D24-04E180695C7A}</pre>
<p>This dastardly key also has a 32bit relation that can be found here:</p>
<pre>HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{A8A91A66-3A7D-4424-8D24-04E180695C7A}</pre>
<p>As with my previous post about removing <a href="http://andrewmorgan.ie/2012/01/16/removing-screen-resolution-and-personalize-shell-extensions-from-a-users-desktop-session/" target="_blank">screen resolution and personalise</a>, its just a matter of removing the users ability to see this registry key.</p>
<p>So below you will find the steps to take to remove this item:</p>
<ol>
<li>Take a backup of this key, you’ll thank me if you get it wrong!</li>
<li>Browse down to HKEY_CLASSES_ROOT\CLSID\{A8A91A66-3A7D-4424-8D24-04E180695C7A}</li>
<li>right click this key, choose permissions, click advanced then owner</li>
<li>Select administrators from the list, then choose “Apply”.</li>
<li>browse to the permissions tab and remove the “users” group. (you may need to remove inheritance)</li>
<li>Click “apply”, then “ok”.</li>
<li>Repeat step 2 to 6 on HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{A8A91A66-3A7D-4424-8D24-04E180695C7A}</li>
<li>Tada! go grab a coffee to celebrate your domination over the windows operating system.</li>
</ol>
<p>And that&#8217;s it, even if the user tries to view the option theres a blank place on the start menu where devices and printers should be. Check back next week and I&#8217;ll show you how to replace this shell icon with PowerPrint from RES software.</p>
<p>PS: You can also quite easily script this, <a href="http://www.remkoweijnen.nl/blog/" target="_blank">Remko</a> provided me with a great script that I&#8217;ve modified below to suit this purpose.</p>
<p><span id="more-1312"></span></p>
<p><pre class="brush: powershell;">

## #############################################################################
## 	Restrict certain Explorer items via registry key.
## #############################################################################
if (!(get-psdrive hkcr -ea 0)){New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | out-null}

 function get-elevatedprivileges{
$definition = @&quot;
    using System;
    using System.Runtime.InteropServices;

    namespace Win32Api
    {

       public class NtDll
       {
          [DllImport(&quot;ntdll.dll&quot;, EntryPoint=&quot;RtlAdjustPrivilege&quot;)]
          public static extern int RtlAdjustPrivilege(ulong Privilege, bool Enable, bool CurrentThread, ref bool Enabled);
       }
    }
&quot;@
    Add-Type -TypeDefinition $definition -PassThru | out-null

    $bEnabled = $false

    # Enable SeTakeOwnershipPrivilege
    $res = [Win32Api.NtDll]::RtlAdjustPrivilege(9, $true, $false, [ref]$bEnabled)
}

function take-ownership{
    param(
        [Parameter(Mandatory = $true,Position = 0,valueFromPipeline=$true)]
        [string]$regkey)
    $key = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey($regkey, [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree,[System.Security.AccessControl.RegistryRights]::takeownership)
    $acl = $key.GetAccessControl()
    $acl.SetOwner([System.Security.Principal.NTAccount]&quot;Administrators&quot;)

    #taking ownership first
    $key.SetAccessControl($acl)

    #my bit - give admin full access
    $rule = New-Object System.Security.AccessControl.RegistryAccessRule(&quot;Administrators&quot;,&quot;FullControl&quot;,&quot;allow&quot;)
    $acl.addaccessrule($rule)
    $key.SetAccessControl($acl)
    #end bit

}#end ownership function.

function remove-useracl{
     param(
        [Parameter(Mandatory = $true,Position = 0,valueFromPipeline=$true)]
        [string]$regkey)
    write-host &quot;$regkey&quot;
    $acl = Get-Acl $regkey
    foreach ($rule in $acl.access){if ($rule.identityreference -eq &quot;BUILTIN\Users&quot;){$acl.RemoveAccessRuleSpecific($rule)}}
    set-acl $regkey -AclObject $acl
}#end acl function.

#define keys to be restricted
$keys=@(&quot;CLSID\{A8A91A66-3A7D-4424-8D24-04E180695C7A}&quot;, # printers and devices
&quot;Wow6432Node\CLSID\{A8A91A66-3A7D-4424-8D24-04E180695C7A}&quot; # 32bit Printers and devices
)

#elevate priviledges

get-elevatedprivileges

#restrict each key
foreach ($key in $keys){
    if (test-path &quot;hkcr:\$key&quot;){
        take-ownership -regkey $key
        remove-useracl -regkey &quot;hkcr:\$key&quot;
    }
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1312/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1312&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2012/01/27/removing-users-access-to-devices-and-printers-in-a-server-2008-r2-win-7-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/winlogo.png?w=75&#38;h=75" medium="image" />

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/culprit.png" medium="image">
			<media:title type="html">culprit</media:title>
		</media:content>
	</item>
		<item>
		<title>Using my Citrix Edgesight Powershell module with Active directory OU&#8217;s.</title>
		<link>http://andrewmorgan.ie/2012/01/27/using-my-citrix-edgesight-powershell-module-with-active-directory-ous/</link>
		<comments>http://andrewmorgan.ie/2012/01/27/using-my-citrix-edgesight-powershell-module-with-active-directory-ous/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 08:52:03 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Edgesight]]></category>
		<category><![CDATA[PowerShell Scripting]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[Citrix]]></category>
		<category><![CDATA[Egesight]]></category>
		<category><![CDATA[Micrsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Quest]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1315</guid>
		<description><![CDATA[I received a request on twitter late last night and it was an interesting one. The person in question wanted to use my current edgesight module to import users from active directory into the static Citrix Edgesight groups, but instead of group membership in Active Directory, they wanted to use Active Directory Organisational Units. All the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1315&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://andymorgan.files.wordpress.com/2011/11/es-logo.jpg?w=112&#038;h=112&#038;h=112" alt="" width="112" height="112" />I received a request on twitter late last night and it was an interesting one. The person in question wanted to use my current <a href="http://andrewmorgan.ie/2011/11/25/importing-users-to-citrix-edgesight-user-groups-from-active-directory/#more-1017" target="_blank">edgesight module</a> to import users from active directory into the static Citrix Edgesight groups, but instead of group membership in Active Directory, they wanted to use Active Directory Organisational Units.</p>
<p>All the information on how to use the module is included in the previous post, so I wont re-invent the wheel. Have a read of the previous post for any caveats or pre-emptive misunderstandings.</p>
<p>Below are two code snippets to use OU membership with either the Quest or Microsoft cmdlets for active directory, just modify the OU Path below, I&#8217;ve tried to include a long example to ensure there&#8217;s no confusion.</p>
<h2> Quest Active directory Snap-in:</h2>
<p><pre class="brush: powershell;">
#Quest Active directory module
import-module &quot;C:\citrix.edgesight.cmdlets.psm1&quot;
add-pssnapin Quest.ActiveRoles.ADManagement
$ADOU='domain.domain.com/Country/Users/advanced/Helpdesk'
$esgroupid=20

#clear the group before import
clear-esgroupmembers -groupid $esgroupid

#get users from group, then import them into edgesight
foreach ($user in get-QADUser -SearchRoot $ADOU -SizeLimit 0){
    $prid = get-ESUserPrid $user.logonname
    if ($prid -NE $null){
    Add-ESGroupMember -groupid $ESgroupid -prid $prid
    }
}#end For
</pre></p>
<h2>Microsoft Active directory module:</h2>
<p>&nbsp;</p>
<p><pre class="brush: powershell;">
#Microsoft active directory module
import-module &quot;C:\citrix.edgesight.cmdlets.psm1&quot;
import-module activedirectory
$ADOU=&quot;OU=helpdesk,OU=advanced,OU=Users,OU=Country,DC=domain,DC=domain,DC=com&quot;
$esgroupid=20

#clear the group before import
clear-esgroupmembers -groupid $esgroupid

#get users from group, then import them into edgesight
foreach ($user in get-ADUser -filter * -searchbase $ADOU){
    $prid = get-ESUserPrid $user.samaccountname
    if ($prid -NE $null){
        Add-ESGroupMember -groupid $ESgroupid -prid $prid
    }
}#end For
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1315/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1315/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1315/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1315/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1315/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1315/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1315/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1315/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1315&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2012/01/27/using-my-citrix-edgesight-powershell-module-with-active-directory-ous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/es-logo.jpg?w=112&#38;h=112" medium="image" />
	</item>
		<item>
		<title>Pulling detailed thin client reports from Igel&#8217;s UMS with Powershell.</title>
		<link>http://andrewmorgan.ie/2012/01/26/pulling-detailed-thin-client-reports-from-igels-ums-with-powershell/</link>
		<comments>http://andrewmorgan.ie/2012/01/26/pulling-detailed-thin-client-reports-from-igels-ums-with-powershell/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 14:37:57 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[Igel]]></category>
		<category><![CDATA[PowerShell Scripting]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1304</guid>
		<description><![CDATA[I needed a full and detailed list recently of all Igel thin client devices and was disapointed with Igels built in views and reporting options. As with my previous Powershell and SQL scripts I set about getting into the Igel database and pulling the information I required. This script is fairly &#8220;Niché&#8221; so I&#8217;ve not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1304&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1305" title="igel-thin-client-devices" src="http://andymorgan.files.wordpress.com/2012/01/igel-thin-client-devices.png?w=600" alt=""   />I needed a full and detailed list recently of all Igel thin client devices and was disapointed with Igels built in views and reporting options. As with my previous Powershell and SQL scripts I set about getting into the Igel database and pulling the information I required.</p>
<p>This script is fairly &#8220;<em>Niché</em>&#8221; so I&#8217;ve not included my usual list of options and explanations, feel free to request more detail if needed.</p>
<p>This script will pull alot of useful information of the device, from mac address to firmware id and return a full table of contents from your Universal Management Server. as below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/report.png"><img class="aligncenter size-full wp-image-1306" title="report" src="http://andymorgan.files.wordpress.com/2012/01/report.png?w=600&#038;h=139" alt="" width="600" height="139" /></a></p>
<p>This script only supports trusted connections, so the account you run the script as needs access to the database. If you need to configure non trusted connections, have a look at my Edgesight or SQL backup scripts for inspiration.</p>
<p>The only options you need to configure are the SQL <strong>servername</strong> and <strong>database name</strong>, these can be found at the start of the script as below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/config.png"><img class="aligncenter size-full wp-image-1307" title="config" src="http://andymorgan.files.wordpress.com/2012/01/config.png?w=600" alt=""   /></a></p>
<p>The script itself can be found after the jump:</p>
<p><span id="more-1304"></span></p>
<p>&nbsp;</p>
<p><pre class="brush: powershell;">

$SQLServer = &quot;servername&quot;
$SQLDatabase = &quot;rmlogin&quot;

$SQLTrustedConnection=$true
$SQLConn = New-Object System.Data.SQLClient.SQLConnection
$SQLConn.ConnectionString = &quot;Server=$SQLServer; Database=$SQLDatabase; Trusted_Connection=True&quot;

if ($SQLserver -eq &quot;&quot;){write-warning &quot;The SQL Server variable must be defined, Closing without fully loading module, please ensure you've defined this entry and try import this module again.&quot;;break}
if ($SQLDatabase -eq &quot;&quot;){write-warning &quot;The SQL Database variable must be defined, Closing without fully loading module, please ensure you've defined this entry and try import this module again.&quot;;break}
write-host &quot;Attempting to connect to the EdgeSight Database: &quot; -nonewline -foregroundcolor yellow
try {$SQLConn.Open()}
catch {
write-host &quot;Failed!&quot; -foregroundcolor Red
Write-warning &quot;An exception was caught while attempting to open the SQL connection, please confirm the login details are correct and attempt to Re-Import this module.&quot;
Break}
write-host &quot;Success!&quot; -foregroundcolor Green
$sqlconn.close()

function get-thinclients{

    if ($SQLconn.state -ne &quot;Open&quot;){
        $SQLConn.Open()}

    $SQLCmd = New-Object System.Data.SQLClient.SQLCommand
    $SQLCmd.CommandText =&quot;SELECT s.tcname,s.macaddress,s.site,s.tccomment,s.lastknownip,p.devicetype,s.Productid,p.ostype,p.cpu_speed,p.cpu_type,p.flashsize,p.memorysize,p.graphicschipset0,f.modelname,f.version
				FROM rmlogin.ADDITIONAL_SYSTEM_INFORMATION AS p
                INNER JOIN rmlogin.THINCLIENT AS s ON s.macaddress = p.mac
                INNER JOIN rmlogin.firmware as f on s.firmwareid = f.firmwareid&quot;
    $SQLCmd.Connection = $SQLConn
    $SQLAdapter = New-Object System.Data.SQLClient.SQLDataAdapter
    $SQLAdapter.SelectCommand = $SQLCmd
    $DataSet = New-Object System.Data.DataSet
    $SQLAdapter.Fill($DataSet) | out-null
    $dataset.tables[0] | % {$members+=@($_)}
    $SQLconn.close()
    return $members
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1304/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1304/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1304/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1304&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2012/01/26/pulling-detailed-thin-client-reports-from-igels-ums-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/igel-thin-client-devices.png" medium="image">
			<media:title type="html">igel-thin-client-devices</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/report.png" medium="image">
			<media:title type="html">report</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/config.png" medium="image">
			<media:title type="html">config</media:title>
		</media:content>
	</item>
		<item>
		<title>Removing Screen Resolution and Personalize shell extensions from a users desktop session.</title>
		<link>http://andrewmorgan.ie/2012/01/16/removing-screen-resolution-and-personalize-shell-extensions-from-a-users-desktop-session/</link>
		<comments>http://andrewmorgan.ie/2012/01/16/removing-screen-resolution-and-personalize-shell-extensions-from-a-users-desktop-session/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 13:33:04 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[Batch Scripting]]></category>
		<category><![CDATA[Remote Desktop Services (RDS)]]></category>
		<category><![CDATA[XenApp]]></category>
		<category><![CDATA[Citrix]]></category>
		<category><![CDATA[Remote Desktop services]]></category>
		<category><![CDATA[SBC]]></category>
		<category><![CDATA[xenapp]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1281</guid>
		<description><![CDATA[While working in a XenApp 6 proof of concept I came accross this little feature and decided its time to share it! When a user right clicks on the desktop, by default they get access to commands to manipulate the appearance of the desktop. As I restricted access to the control panel, the two options [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1281&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://andymorgan.files.wordpress.com/2012/01/shell.png"><img class="alignright size-thumbnail wp-image-1285" style="border-color:initial;border-style:initial;" title="winlogo" src="http://andymorgan.files.wordpress.com/2012/01/winlogo.png?w=75&#038;h=75" alt="" width="75" height="75" /></a></p>
<p>While working in a XenApp 6 proof of concept I came accross this little feature and decided its time to share it!</p>
<p>When a user right clicks on the desktop, by default they get access to commands to manipulate the appearance of the desktop. As I restricted access to the control panel, the two options below were generating errors in the users sessions:</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/shell.png"><img class="aligncenter size-full wp-image-1282" title="shell" src="http://andymorgan.files.wordpress.com/2012/01/shell.png?w=600" alt=""   /></a></p>
<p>The error generated is your standard group policy restrictions error message as below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/error.png"><img class="aligncenter size-full wp-image-1283" title="error" src="http://andymorgan.files.wordpress.com/2012/01/error.png?w=600" alt=""   /></a></p>
<p>While digging into this further I found the following registry key that corresponds to the two prompts we see above.</p>
<pre>HKEY_CLASSES_ROOT\DesktopBackground</pre>
<p>Under this key, you can see both entries that appear on the shell extension menu;</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/reg-entry.png"><img class="aligncenter size-full wp-image-1284" title="reg entry" src="http://andymorgan.files.wordpress.com/2012/01/reg-entry.png?w=600" alt=""   /></a></p>
<p>The problem with this key is, its owned by the TrustedInstaller account, and by default administrators cannot modify it. To modify this  key and hide this menu from users (but maintain it for administators) please follow the below steps.</p>
<p><em>Please note, any hotfixes from microsoft may remove your hard work, so be prepared to redo this work if Microsoft decide to work with this key in future.</em></p>
<ol>
<li>Take a backup of this key, you&#8217;ll thank me if you get it wrong!</li>
<li>Browse down to desktopbackground\shell\display</li>
<li>right click this key, choose permissions, click advanced then owner</li>
<li>Select administrators from the list, then choose &#8220;Apply&#8221;.</li>
<li>browse to the permissions tab and remove the &#8220;users&#8221; group.</li>
<li>Click &#8220;apply&#8221;, then &#8220;ok&#8221;.</li>
<li>The &#8220;screen resolution&#8221; menu should now disappear from any current and future sessions.</li>
<li>Repeat step 2 to 8 on DesktopBackground\Shell\Personalize.</li>
<li>Tada! go grab a coffee to celebrate your domination over the windows operating system.</li>
</ol>
<p>And that&#8217;s it, you should now have a lean, clean and  error free shell extension menu when right clicking on the desktop.</p>
<p><strong>Pedantic, begrudging scripters note:</strong></p>
<p>Now if you&#8217;re a pedantic scripting so and so like me, you wont be satisfied to leave this job as a manual task. And despite spending more time than I&#8217;d like to admit, I couldn&#8217;t perform this work in powershell despite what I tried. Luckily the task was extremely easy to do with <a href="http://helgeklein.com/" target="_blank">Helge Klein</a>&#8216;s setacl program.</p>
<p>Below is an example of a script to achieve this:</p>
<p>setacl.exe -on HKLM\software\classes\DesktopBackground -ot reg -actn setprot -op dacl:p_nc;sacl:p_nc -rec yes</p>
<p>SetACL.exe -on HKLM\software\classes\DesktopBackground -ot reg -actn ace -ace &#8220;n:system;p:read&#8221; -ace &#8220;n:administrators;p:read&#8221; -actn clear -clr &#8220;dacl,sacl&#8221; -actn rstchldrn -rst &#8220;dacl,sacl&#8221; -rec yes</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1281/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1281&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2012/01/16/removing-screen-resolution-and-personalize-shell-extensions-from-a-users-desktop-session/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/winlogo.png?w=150" medium="image">
			<media:title type="html">winlogo</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/shell.png" medium="image">
			<media:title type="html">shell</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/error.png" medium="image">
			<media:title type="html">error</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/reg-entry.png" medium="image">
			<media:title type="html">reg entry</media:title>
		</media:content>
	</item>
		<item>
		<title>The curious case of missing file shares on a Microsoft File Server Cluster.</title>
		<link>http://andrewmorgan.ie/2012/01/13/the-curious-case-of-missing-file-shares-on-a-microsoft-file-server-cluster/</link>
		<comments>http://andrewmorgan.ie/2012/01/13/the-curious-case-of-missing-file-shares-on-a-microsoft-file-server-cluster/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 12:56:28 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[Clustering]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1271</guid>
		<description><![CDATA[I had a very unusual issue recently where, after a fail over one of my file cluster resources didn&#8217;t publish all shares to the users. Some shares did come up, but many of the shares were missing resulting in users being locked out of their network drives. I immediately jumped to the registry HKEY_LOCAL_MACHINE\Cluster\Resources and found the resource by guid [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1271&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://andymorgan.files.wordpress.com/2012/01/cluster-icon.png"><img class="alignright size-full wp-image-1273" title="cluster icon" src="http://andymorgan.files.wordpress.com/2012/01/cluster-icon.png?w=600" alt=""   /></a>I had a very unusual issue recently where, after a fail over one of my file cluster resources didn&#8217;t publish all shares to the users. Some shares did come up, but many of the shares were missing resulting in users being locked out of their network drives.</p>
<p>I immediately jumped to the registry HKEY_LOCAL_MACHINE\Cluster\Resources and found the resource by guid of my misbehaving file cluster. I could see all the shares missing were still published as resources as below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/registry-entry.png"><img class="aligncenter size-full wp-image-1272" title="registry entry" src="http://andymorgan.files.wordpress.com/2012/01/registry-entry.png?w=600&#038;h=153" alt="" width="600" height="153" /></a></p>
<p>Upon reviewing the event logs, each time the cluster was failed over, each missing share was logging the following event:</p>
<pre>Log Name: System
Source: Microsoft-Windows-FailoverClustering
Date: xx/xx/xxxx 08:00:27
Event ID: 1068
Task Category: File Server Resource
Level: Warning
Keywords:
User: SYSTEM
Computer: XXXXXXXXXXX.Domain.com
Description:
Cluster file share resource 'File Server FileServer' cannot be brought online. Creation of file share 'Vedeni' (scoped to network name Fileserver) failed due to error '5'. This operation will be automatically retried.</pre>
<p>Upon reviewing the share permissions, an over zealous administrator had trimmed the NTFS permissions, removing the local system account. Upon each cluster resource coming online, the cluster uses the local system account to enumerate the shares and present them. Remove this account and your shares wont come online!</p>
<p>This  account doesnt need to be on every folder, just each folder a share is based on. E.g. if you share d:\share\finance as \\server\finance, only the finance folder needs access granted to the system account.</p>
<p><a href="http://andymorgan.files.wordpress.com/2012/01/perms.png"><img class="aligncenter size-full wp-image-1275" title="perms" src="http://andymorgan.files.wordpress.com/2012/01/perms.png?w=600" alt=""   /></a></p>
<p>To resolve, configure the system account to have access to the folder on &#8220;this folder only&#8221; then restart the file server resource. The resource will come on-line and your shares will be available again!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1271&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2012/01/13/the-curious-case-of-missing-file-shares-on-a-microsoft-file-server-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/cluster-icon.png" medium="image">
			<media:title type="html">cluster icon</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/registry-entry.png" medium="image">
			<media:title type="html">registry entry</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2012/01/perms.png" medium="image">
			<media:title type="html">perms</media:title>
		</media:content>
	</item>
		<item>
		<title>Retrieve adobe flash version with PowerShell</title>
		<link>http://andrewmorgan.ie/2012/01/09/retrieve-adobe-flash-version-with-powershell/</link>
		<comments>http://andrewmorgan.ie/2012/01/09/retrieve-adobe-flash-version-with-powershell/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 15:56:23 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[PowerShell Scripting]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1266</guid>
		<description><![CDATA[Just a quick powershell script to start the year. I recently needed to audit the version of adobe flash on the machines a script was running. This code was originally written for visual studio but translates well to powershell. to retrieve the version of adobe flash on the local machine, use get-adobeflashversion. The code for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1266&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://andymorgan.files.wordpress.com/2011/03/windows_powershell_icon.png?w=68&#038;h=68&#038;h=68" alt="" width="68" height="68" />Just a quick powershell script to start the year.</p>
<p>I recently needed to audit the version of adobe flash on the machines a script was running. This code was originally written for visual studio but translates well to powershell.</p>
<p>to retrieve the version of adobe flash on the local machine, use get-adobeflashversion. The code for the get-adobeflashversion can be found below:</p>
<p><pre class="brush: powershell;">
function get-adobeflashversion{
    try{
        $flashobject = new-object -ComObject &quot;shockwaveflash.shockwaveflash&quot;
        $version=(($flashobject.getvariable(&quot;`$version&quot;)).replace(&quot;,&quot;,&quot;.&quot;)).trimstart(&quot;WIN &quot;)
    }
    Catch{
        write-warning &quot;Could not create Com Object, are you sure Adobe Flash is installed?&quot;
    }
    return $version
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1266/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1266&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2012/01/09/retrieve-adobe-flash-version-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/03/windows_powershell_icon.png?w=68&#38;h=68&#38;h=68" medium="image" />
	</item>
		<item>
		<title>Backup and restore SQL databases using powershell</title>
		<link>http://andrewmorgan.ie/2011/12/14/backup-and-restore-sql-databases-using-powershell/</link>
		<comments>http://andrewmorgan.ie/2011/12/14/backup-and-restore-sql-databases-using-powershell/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 12:05:50 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[PowerShell Scripting]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1236</guid>
		<description><![CDATA[I needed a powershell script to quickly backup or restore SQL database&#8217;s before doing maintenance work, but without having to remote into an SQL server. With this task in hand I wrote the below module. I&#8217;ve sealed this as a module to be imported on runtime so you can quickly run a backup before making [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1236&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I<img class="alignright" src="http://andymorgan.files.wordpress.com/2011/03/windows_powershell_icon.png?w=68&#038;h=68&#038;h=68" alt="" width="68" height="68" /> needed a powershell script to quickly backup or restore SQL database&#8217;s before doing maintenance work, but without having to remote into an SQL server. With this task in hand I wrote the below module. I&#8217;ve sealed this as a module to be imported on runtime so you can quickly run a backup before making any changes to infrastructure utilising sql, safe with the knowledge you have a backup, and more importantly restore if you make a mess of it!</p>
<p>This module should be used before using my xenapp 6 backup, reset and restore commands or Edgesight scripts. You can get a copy of it <a href="http://www.box.com/s/qucqye0sgbk7z5s2705m" target="_blank">here.</a></p>
<p>To import the module, run the below command (assuming you have saved the module to c:\).</p>
<pre>import-module c:\sql.backup.psm1</pre>
<h2><strong>Module functions:</strong></h2>
<ul>
<li>Backup-SQLdatabase</li>
<li>Restore-SQLdatabase</li>
</ul>
<h3>Backup-SQLdatabase</h3>
<p>This module allows you to connect to an SQL server and use native SQL commands to perform the backup to a file from pretty much any windows machine with powershell installed.</p>
<p>This module supports trusted and untrusted connections and has built in error checking to catch typical problems and returns a job report as an object. The module will first try to connect and ensure you have the neccessary access rights, attempt to create the backup file, and assuming all has gone well then perform the task at hand:</p>
<p><pre class="brush: powershell;">
Backup-SQLdatabase -SQLServer &quot;sqlserver&quot; -SQLDatabase &quot;database&quot; -Path &quot;\\server\share$\backup.bak&quot; -SQLTrustedConnection
</pre></p>
<p style="text-align:center;"><a href="http://andymorgan.files.wordpress.com/2011/12/trusted-backup.png"><img class="size-full wp-image-1242 aligncenter" title="trusted backup" src="http://andymorgan.files.wordpress.com/2011/12/trusted-backup.png?w=600&#038;h=107" alt="" width="600" height="107" /></a><em>(Private information ommitted)</em></p>
<h3 style="text-align:left;">Restore-SQLDatabase</h3>
<p>This module allows you to connect to an SQL server and use native SQL commands to perform a restore from a file from pretty much any windows machine with powershell installed.</p>
<p>This module supports trusted and untrusted connections and has built in error checking to catch typical problems and returns a job report as an object. The module will first try to connect and ensure you have the neccessary access rights, attempt to locate the backup file, set the sql database to single user mode and assuming all has gone well then perform the task at hand.</p>
<p><pre class="brush: powershell;">
restore-SQLdatabase -SQLServer &quot;sqlserver&quot; -SQLDatabase &quot;database&quot; -Path &quot;\\server\share$\backup.bak&quot; -SQLTrustedConnection
</pre></p>
<p style="text-align:center;"><a href="http://andymorgan.files.wordpress.com/2011/12/untrusted-restore.png"><img class="aligncenter  wp-image-1243" title="untrusted restore" src="http://andymorgan.files.wordpress.com/2011/12/untrusted-restore.png?w=600&#038;h=84" alt="" width="600" height="84" /></a><em>(Private information ommitted)</em></p>
<p style="text-align:left;">If for any reason, the restore doesn&#8217;t work correctly the function will take the corrective action of setting the database back to multi-user.</p>
<p style="text-align:left;">A full copy of the module to be viewed can be found after the jump below:</p>
<p style="text-align:left;"><span id="more-1236"></span></p>
<p><pre class="brush: powershell;">
&lt;#
    Author: Andrew Morgan (@andyjmorgan on Twitter, http://www.andrewmorgan.ie)
    Allows backup of sql servers to disk and restoration
    Version: 1.0
    Any comments/ feedback welcome, ping me on twitter, drop me a comment on the blog or via e-mail (andrew at andrewmorgan dot ie)
#&gt;

Function Backup-SQLdatabase{
    &lt;#
        .SYNOPSIS
            Backs up an sql database to local or remote disk.

        .DESCRIPTION
            This script will perform a full backup of the specified database and save it to a local or network disk.

        .PARAMETER  SQLServer
            Specifies the sqlserver or instance name you wish to connect to and backup.

        .PARAMETER SQLDatabase
            Specifies the Database name you wish to connect to and backup.

        .PARAMETER Path
            Specifies the path to which you wish to backup the database, it can be the local disk on the sql server or network share.

        .PARAMETER TrustedConnection
            Specifies to the function that you wish to connect via your current credentials.

        .PARAMETER SQLusername
            Specifies the username you wish to use to connect to the SQL server. Use this when you dont wish to use a trusted connection.

         .PARAMETER SQLpassword
            Specifies the password you wish to use to connect to the SQL server. Use this when you dont wish to use a trusted connection.

        .EXAMPLE
            PS C:\&gt; Backup-SQLdatabase -SQLServer &quot;sqlserver&quot; -SQLDatabase &quot;database&quot; -Path &quot;\\server\share$\backup.bak&quot; -SQLTrustedConnection

            This command backs up the database &quot;database&quot; on sql server &quot;sqlserver&quot; to the specified path using the local credentials.

        .EXAMPLE
            PS C:\&gt; Backup-SQLdatabase -SQLServer &quot;sqlserver&quot; -SQLDatabase &quot;database&quot; -Path &quot;\\server\share$\backup.bak&quot; -SQLusername &quot;user&quot; -sqlpassword &quot;password&quot;

            This command backs up the database &quot;database&quot; on sql server &quot;sqlserver&quot; to the specified path using the account name user and password of password.

        .INPUTS
            Switch

        .OUTPUTS
            Results

        .NOTES
             http://www.andrewmorgan.ie for support information.

        .LINK
            http://www.andrewmorgan.ie for more information
            backup-sqldatabase
            restore-sqldatabase
    #&gt;

    param(
        [Parameter(Mandatory=$true)]
        [string]$SQLServer,
        [Parameter(Mandatory=$true)]
        [string]$SQLDatabase,
        [parameter(Mandatory=$true)]
        [string]$Path,
        [switch]$TrustedConnection,
        [string]$SQLusername,
        [string]$SQLpassword
    )

    ## Performing error checking ##

    if ($path -notlike &quot;*.bak&quot;){
        write-warning &quot;the file extension should be .bak, Closing.&quot;
        break}

    if ($TrustedConnection -eq $false){
        if ($SQLUsername -eq &quot;&quot;){
            write-warning &quot;The SQL Username variable must be defined, Closing without fully loading module, please ensure you've defined this entry and try import this module again.&quot;
            break}

        if ($SQLPassword -eq &quot;&quot;){
            write-warning &quot;The SQL Password variable must be defined, Closing without fully loading module, please ensure you've defined this entry and try import this module again.&quot;
            break}
    }

    new-item $path -itemtype File -ErrorAction SilentlyContinue | OUT-NULL
    if (!(test-path $path)){
        write-warning &quot;Could not create the backup file, closing&quot;
        break
    }

    $SQLConn = New-Object System.Data.SQLClient.SQLConnection

    #checks for a trusted SQL connection
    if ($TrustedConnection -eq $false){
        #Using an SQL account for login
        $SQLConn.ConnectionString = &quot;Server=$SQLServer; user id=$SQLusername ; Password=$SQLpassword; Trusted_Connection=False&quot;}
    Else {
        #Using a trusted connection
        $SQLConn.ConnectionString = &quot;Server=$SQLServer; Trusted_Connection=True&quot;
    }

## Trying a connection and capture a failure ##

    write-host &quot;Attempting to connect to the Specified SQL server: &quot; -nonewline -foregroundcolor yellow
    try {
        $SQLConn.Open()
        write-host &quot;Success&quot; -foregroundcolor Green
    }
    catch {
        write-host &quot;Failed!&quot; -foregroundcolor Red
        Write-warning &quot;An exception was caught while attempting to open the SQL connection, please confirm the login details are correct and try again.&quot;
        Break
    }

    $SQLCmd = New-Object System.Data.SQLClient.SQLCommand
    $SQLcmd = $SQLconn.CreateCommand()
    $sqlcmd.commandtimeout=0
    $SQLcmd.CommandText=&quot;BACKUP DATABASE $sqldatabase TO DISK = '$path' WITH INIT&quot;
    $starttime = Get-date
    try{
            $SQLcmd.Executenonquery() | out-null
            $backupsize=[math]::round((Get-ItemProperty $path).LENGTH / 1048576,0)
            $result=&quot;Success&quot;
        }
    catch{
            $result=&quot;Failed&quot;
            write-warning &quot;An Exception was caught while backing up the database!&quot;
            write-warning &quot;$_&quot;
        }
    finally{

            $timetaken=[math]::round(((get-date) - $starttime).totalseconds,0)
            $SQLconn.close()
            $report=new-object PSObject -Property @{
                SQLServer=$SQLserver;
                Database=$sqlDatabase;
                Result=$result;
                Timetaken=&quot;$timetaken Seconds&quot;;
                BackupSize=&quot;$backupsize MB&quot;;
                BackupFile=$path
            }
        }
        return $report

}

Function Restore-SQLdatabase{
    &lt;#
        .SYNOPSIS
            Restore an sql database from local or remote disk.

        .DESCRIPTION
            This script will perform a full restore of the specified database from a local or network disk.

        .PARAMETER  SQLServer
            Specifies the sqlserver or instance name you wish to connect to and restore.

        .PARAMETER SQLDatabase
            Specifies the Database name you wish to connect to and restore.

        .PARAMETER Path
            Specifies the path to which you wish to restore the database from, it can be the local disk on the sql server or network share.

        .PARAMETER TrustedConnection
            Specifies to the function that you wish to connect via your current credentials.

        .PARAMETER SQLusername
            Specifies the username you wish to use to connect to the SQL server. Use this when you dont wish to use a trusted connection.

         .PARAMETER SQLpassword
            Specifies the password you wish to use to connect to the SQL server. Use this when you dont wish to use a trusted connection.

        .EXAMPLE
            PS C:\&gt; restore-SQLdatabase -SQLServer &quot;sqlserver&quot; -SQLDatabase &quot;database&quot; -Path &quot;\\server\share$\backup.bak&quot; -SQLTrustedConnection

            This command restores the database &quot;database&quot; on sql server &quot;sqlserver&quot; from the specified path using the local credentials.

        .EXAMPLE
            PS C:\&gt; restore-SQLdatabase -SQLServer &quot;sqlserver&quot; -SQLDatabase &quot;database&quot; -Path &quot;\\server\share$\backup.bak&quot; -SQLusername &quot;user&quot; -sqlpassword &quot;password&quot;

            This command restores the database &quot;database&quot; on sql server &quot;sqlserver&quot; from the specified path using the account name user and password of password.

        .INPUTS
            Switch

        .OUTPUTS
            Results

        .NOTES
             http://www.andrewmorgan.ie for support information.

        .LINK
            http://www.andrewmorgan.ie for more information
            backup-sqldatabase
            restore-sqldatabase
    #&gt;
    param(
        [Parameter(Mandatory=$true)]
        [string]$SQLServer,
        [Parameter(Mandatory=$true)]
        [string]$SQLDatabase,
        [parameter(Mandatory=$true)]
        [string]$Path,
        [switch]$TrustedConnection,
        [string]$SQLusername,
        [string]$SQLpassword
    )

    ## Performing error checking ##

    if ($path -notlike &quot;*.bak&quot;){
        write-warning &quot;the file extension should be .bak&quot;
        break}

    if ($TrustedConnection -eq $false){
        if ($SQLUsername -eq &quot;&quot;){
            write-warning &quot;The SQL Username variable must be defined, Closing without fully loading module, please ensure you've defined this entry and try import this module again.&quot;
            break}

        if ($SQLPassword -eq &quot;&quot;){
            write-warning &quot;The SQL Password variable must be defined, Closing without fully loading module, please ensure you've defined this entry and try import this module again.&quot;
            break}
    }

    if (!(test-path $path)){
        write-warning &quot;Could not find the backup file, closing&quot;
        break
    }

    $SQLConn = New-Object System.Data.SQLClient.SQLConnection

    #checks for a trusted SQL connection
    if ($TrustedConnection -eq $false){
        #Using an SQL account for login
        $SQLConn.ConnectionString = &quot;Server=$SQLServer; user id=$SQLusername ; Password=$SQLpassword; Trusted_Connection=False&quot;}
    Else {
        #Using a trusted connection
        $SQLConn.ConnectionString = &quot;Server=$SQLServer; Trusted_Connection=True&quot;
    }

## Trying a connection and capture a failure ##

    write-host &quot;Attempting to connect to the Specified SQL server: &quot; -nonewline -foregroundcolor yellow
    try {
        $SQLConn.Open()
        write-host &quot;Success&quot; -foregroundcolor Green
    }
    catch {
        write-host &quot;Failed!&quot; -foregroundcolor Red
        Write-warning &quot;An exception was caught while attempting to open the SQL connection, please confirm the login details are correct and try again.&quot;
        Break
    }

    $SQLCmd = New-Object System.Data.SQLClient.SQLCommand
    $SQLcmd = $SQLconn.CreateCommand()
    $sqlcmd.commandtimeout=0
    $SQLcmd.CommandText=&quot;ALTER DATABASE $SQLDatabase
                        SET SINGLE_USER WITH
                        ROLLBACK IMMEDIATE
                        RESTORE DATABASE $SQLDatabase
                        FROM DISK = '$path'
                        WITH REPLACE&quot;
    $starttime = Get-date
    try{
            $SQLcmd.Executenonquery() | out-null
            $result=&quot;Success&quot;
        }
    catch{
            write-warning &quot;An Exception was caught while restoring the database!&quot;
            write-warning &quot;$_&quot;
            write-warning &quot;attempting to recover the database&quot;
            $SQLcmd.CommandText=&quot;ALTER DATABASE $SQLDatabase SET MULTI_USER&quot;
            $SQLcmd.Executenonquery() | out-null
            $result=&quot;Failed&quot;
        }
    finally{
            $SQLconn.close()
            $timetaken=[math]::round(((get-date) - $starttime).totalseconds,0)
            $report=new-object PSObject -Property @{
                SQLServer=$SQLserver;
                Database=$sqlDatabase;
                Result=$result;
                Timetaken=&quot;$timetaken Seconds&quot;;
            }

    }
    Return $Report

}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1236/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1236/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1236/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1236&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2011/12/14/backup-and-restore-sql-databases-using-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/03/windows_powershell_icon.png?w=68&#38;h=68&#38;h=68" medium="image" />

		<media:content url="http://andymorgan.files.wordpress.com/2011/12/trusted-backup.png" medium="image">
			<media:title type="html">trusted backup</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/12/untrusted-restore.png" medium="image">
			<media:title type="html">untrusted restore</media:title>
		</media:content>
	</item>
		<item>
		<title>Move objects in active directory which have been inactive for x days.</title>
		<link>http://andrewmorgan.ie/2011/12/13/move-objects-in-active-directory-which-have-been-inactive-for-x-days/</link>
		<comments>http://andrewmorgan.ie/2011/12/13/move-objects-in-active-directory-which-have-been-inactive-for-x-days/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 14:39:07 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell Scripting]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1210</guid>
		<description><![CDATA[This is just a quick script I was asked for assistance with recently. The person in question wanted to move all computers and users to defined ou&#8217;s when they were inactive for 90 days. The script is fairly self explanatory but quite scary if you get it wrong, for that reason I&#8217;ve included the -whatif [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1210&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" src="http://andymorgan.files.wordpress.com/2011/03/windows_powershell_icon.png?w=68&#038;h=68&#038;h=68" alt="" width="68" height="68" />This is just a quick script I was asked for assistance with recently. The person in question wanted to move all computers and users to defined ou&#8217;s when they were inactive for 90 days.</p>
<p>The script is fairly self explanatory but quite scary if you get it wrong, for that reason I&#8217;ve included the <strong>-whatif</strong> parameter to show you what will happen if you overzealously just copy and paste the code. Once you are happy it works, remove the whatif parameters.</p>
<p>This script relies on the powershell module for active directory, you can see if its installed as below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2011/11/rsat.png"><img class="aligncenter size-full wp-image-1216" title="rsat" src="http://andymorgan.files.wordpress.com/2011/11/rsat.png?w=600&#038;h=237" alt="" width="600" height="237" /></a></p>
<p style="text-align:center;"><em>I&#8217;m also aware this code is quite inefficient by searching twice, but it was the cleanest appearance I could muster to ensure the end user understands what is happening.</em></p>
<p><pre class="brush: powershell;">

#Load the required Snapins
if (!(import-module &quot;activedirectory&quot; -ea 0)) {
	    Write-Host &quot;Loading active directory module.&quot; -ForegroundColor Yellow
	    import-module &quot;activedirectory&quot; -ea Stop
}#endif

#users
foreach ($user in search-adaccount -UsersOnly -AccountInactive -TimeSpan 90.00:00:00){
    move-adobject -identity $user.DistinguishedName -targetpath &quot;OU=Old Users,DC=some,DC=domain,dc=net&quot; -whatif
}

#computers
foreach ($computer in search-adaccount -Computersonly -AccountInactive -TimeSpan 90.00:00:00){
    move-adobject -identity $computer.DistinguishedName -targetpath &quot;OU=Old Computers,DC=some,DC=domain,dc=net&quot; -whatif
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1210&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2011/12/13/move-objects-in-active-directory-which-have-been-inactive-for-x-days/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/03/windows_powershell_icon.png?w=68&#38;h=68&#38;h=68" medium="image" />

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/rsat.png" medium="image">
			<media:title type="html">rsat</media:title>
		</media:content>
	</item>
		<item>
		<title>The idiots guide to load balancing App-V LWS via a Citrix Netscaler:</title>
		<link>http://andrewmorgan.ie/2011/12/05/the-idiots-guide-to-load-balancing-app-v-lws-via-a-citrix-netscaler/</link>
		<comments>http://andrewmorgan.ie/2011/12/05/the-idiots-guide-to-load-balancing-app-v-lws-via-a-citrix-netscaler/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 14:47:41 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[App-V]]></category>
		<category><![CDATA[Application Virtualisation.]]></category>
		<category><![CDATA[Netscaler]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1038</guid>
		<description><![CDATA[I set about recently to load balance app-v lightweight streaming servers traffic across Netscalers. I found this task a little more tricky than I had hoped and decided it would be useful to break this task down to its most basic steps and publish this to help anyone else who needs to do this in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1038&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1039" title="index" src="http://andymorgan.files.wordpress.com/2011/11/index.jpg?w=600" alt=""   /></p>
<p>I set about recently to load balance app-v lightweight streaming servers traffic across Netscalers. I found this task a little more tricky than I had hoped and decided it would be useful to break this task down to its most basic steps and publish this to help anyone else who needs to do this in future.</p>
<p>Despite great articles on <a href="http://blogs.technet.com/b/appv/archive/2011/06/08/app-v-fix-streaming-rtsp-may-fail-with-the-citrix-netscaler-load-balancer.aspx" target="_blank">Technet</a> and <a href="http://www.hakabo.com/web/2011/06/load-balancing-app-v-with-netscalers/" target="_blank">hakabo.com</a>, the sooner doesn&#8217;t have any fault tolerance for RTSP specific issues and focuses on the command line, which many administrators morbidly fear on the Netscaler. The later is geared at management servers which have slightly different requirements to LWS servers, the monitor recommended utilises commands which the LWS server does not support. Which results in downstate App-V servers at all times.</p>
<p>So below you will find an idiot proof guide (tested by this idiot) to marry two of my favourite pieces of technology into a kick ass solution.</p>
<p><strong>What you will need:</strong></p>
<ul>
<li>Netscalers!</li>
<li>at least 2 App-V Light Weight streaming servers!</li>
<li>One netscaler Virtual IP address to load balance the traffic</li>
<li>About 30 minutes of time (including testing).</li>
</ul>
<p><strong>1:</strong> To start, take a note of the ip addresses currently configured on your App-V LWS servers.</p>
<p><strong>2:</strong> Log into your wonderful netscalers.</p>
<p><em>First up, we&#8217;ll configure the monitor. This monitor will poll your App-V servers and ensure they are up and working.</em></p>
<p><strong>3:</strong> From the configuration page, select <strong>Load Balancing &gt; Monitors &gt; Add:</strong></p>
<p><strong></strong><a href="http://andymorgan.files.wordpress.com/2011/11/open-monitors-add.png"><img class="aligncenter size-full wp-image-1040" title="open monitors, add" src="http://andymorgan.files.wordpress.com/2011/11/open-monitors-add.png?w=600" alt=""   /></a></p>
<p><strong>4:</strong> Name the monitor something specific and easily identifed, then configure the below options:</p>
<ul>
<li>type = RTSP</li>
<li>Interval =20</li>
<li>Destination port = 554</li>
</ul>
<p><img class="aligncenter size-full wp-image-1043" title="monitor page 1" src="http://andymorgan.files.wordpress.com/2011/11/monitor-page-11.png?w=600&#038;h=413" alt="" width="600" height="413" /></p>
<p><strong>5:</strong> Click the <strong>Special Parameters</strong> tab, Then set the below values:</p>
<ul>
<li>RTSP Request = Options *</li>
<li>Response Codes: 401</li>
</ul>
<p><em>(yes yes, 401 is an error response, but the LWS server has to be actively accepting connections to throw this error)</em></p>
<p><strong>6:</strong> Once finished, hit <strong>Create:</strong></p>
<p><img class="aligncenter size-full wp-image-1044" title="monitor page 2" src="http://andymorgan.files.wordpress.com/2011/11/monitor-page-2.png?w=600&#038;h=422" alt="" width="600" height="422" /></p>
<p>And that&#8217;s it, monitor configured!</p>
<p><em>Next, we&#8217;ll create a service group, this service group is a logical collection of our App-V servers. Here we will configure the ports and monitoring configuration to catch outages.</em></p>
<p><strong>7:</strong> Browse to <strong>Load Balancing &gt; Service Groups,</strong> then choose <strong>Add:</strong></p>
<p><strong><br />
<img class="aligncenter size-full wp-image-1062" title="open service groups, ade" src="http://andymorgan.files.wordpress.com/2011/11/open-service-groups-ade1.png?w=600" alt=""   /><br />
</strong></p>
<p><strong>8:</strong> Name the Service group something specific and easily identifed, then define the following options:</p>
<ul>
<li>Protocol = Any</li>
</ul>
<p><strong>9:</strong> Enter each IP address of the App-V server, ensure to choose * as the port and click <strong>Add. </strong>Repeat this step for each subsequent App-V server.</p>
<p><img class="aligncenter size-full wp-image-1060" title="Service Group page 1" src="http://andymorgan.files.wordpress.com/2011/11/service-group-page-1.png?w=600&#038;h=289" alt="" width="600" height="289" /></p>
<p><strong>10:</strong> Once you&#8217;ve entered all your IP addresses, it should look as below: (ip addresses omitted)</p>
<p><img class="aligncenter size-full wp-image-1059" title="Service Group page 1 - added servers" src="http://andymorgan.files.wordpress.com/2011/11/service-group-page-1-added-servers.png?w=600&#038;h=146" alt="" width="600" height="146" /></p>
<p><strong>11:</strong> Now flick to the <strong>Monitors</strong> tab and select the service group we created earlier:</p>
<p><img class="aligncenter size-full wp-image-1057" title="Service Group page 2" src="http://andymorgan.files.wordpress.com/2011/11/service-group-page-2.png?w=600&#038;h=134" alt="" width="600" height="134" /></p>
<p><strong>12:</strong> Once finished, save your changes, the service group is done.</p>
<p><em>We&#8217;re on the home straight, now we&#8217;ll tie it all to a virtual IP and configure the load balancing specific settings:</em></p>
<p><strong>13:</strong> Now to the Virtual server, browse to <strong>Load Balancing &gt; Virtual Servers &gt; Add.</strong></p>
<p><img class="aligncenter size-full wp-image-1064" title="virtual servers, add" src="http://andymorgan.files.wordpress.com/2011/11/virtual-servers-add1.png?w=600" alt=""   /></p>
<p><strong>14:</strong> Name the Virtual Server something specific and easily identifed, then define the following options:</p>
<ul>
<li>Protocol = Any</li>
<li>IP address = the virtual ip address to be hosted by the netscaler.</li>
<li>Port = *</li>
</ul>
<p><strong>15:</strong> Flick to the <strong>Service Groups </strong>tab, then select the service group we just created:</p>
<p><img class="aligncenter size-full wp-image-1056" title="Virtual server, page 1" src="http://andymorgan.files.wordpress.com/2011/11/virtual-server-page-1.png?w=600&#038;h=205" alt="" width="600" height="205" /></p>
<p><strong>16:</strong> Flick to the <strong>Method and Persistence</strong> tab, then configure the following options:</p>
<ul>
<li>Method = Least connection</li>
<li>Persistence = Source IP</li>
<li>ipv4 Netmask = 255.255.255.255</li>
</ul>
<p><img class="aligncenter size-full wp-image-1055" title="Virtual server, page 2" src="http://andymorgan.files.wordpress.com/2011/11/virtual-server-page-2.png?w=600&#038;h=348" alt="" width="600" height="348" /></p>
<p><strong>17:</strong> Now flick to the <strong>Advanced</strong> tab, then configure the following options:</p>
<ul>
<li>Redirection mode = IP Based</li>
</ul>
<p><img class="aligncenter size-full wp-image-1054" title="Virtual server, page 3" src="http://andymorgan.files.wordpress.com/2011/11/virtual-server-page-3.png?w=600&#038;h=204" alt="" width="600" height="204" /></p>
<p><em>Thats it, we&#8217;re done! time to test.</em></p>
<p><strong>18:</strong> Open up a telnet client, and attempt to telnet to the newly configured virtual server:</p>
<p><img class="aligncenter size-full wp-image-1053" title="telnet to server" src="http://andymorgan.files.wordpress.com/2011/11/telnet-to-server.png?w=600" alt=""   /></p>
<p><strong>19:</strong> If all has gone to plan, the window should empty its contents and appear as below:</p>
<p><img class="aligncenter size-full wp-image-1052" title="telnet success" src="http://andymorgan.files.wordpress.com/2011/11/telnet-success.png?w=600&#038;h=158" alt="" width="600" height="158" /></p>
<p><strong>20:</strong> Now go celebrate your success and genius. If for some reason it has not worked, feel free to drop a comment and I&#8217;ll see what I can assist you with.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1038/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1038/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1038/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1038/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1038/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1038/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1038/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1038/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1038&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2011/12/05/the-idiots-guide-to-load-balancing-app-v-lws-via-a-citrix-netscaler/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/index.jpg" medium="image">
			<media:title type="html">index</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/open-monitors-add.png" medium="image">
			<media:title type="html">open monitors, add</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/monitor-page-11.png" medium="image">
			<media:title type="html">monitor page 1</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/monitor-page-2.png" medium="image">
			<media:title type="html">monitor page 2</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/open-service-groups-ade1.png" medium="image">
			<media:title type="html">open service groups, ade</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/service-group-page-1.png" medium="image">
			<media:title type="html">Service Group page 1</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/service-group-page-1-added-servers.png" medium="image">
			<media:title type="html">Service Group page 1 - added servers</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/service-group-page-2.png" medium="image">
			<media:title type="html">Service Group page 2</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/virtual-servers-add1.png" medium="image">
			<media:title type="html">virtual servers, add</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/virtual-server-page-1.png" medium="image">
			<media:title type="html">Virtual server, page 1</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/virtual-server-page-2.png" medium="image">
			<media:title type="html">Virtual server, page 2</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/virtual-server-page-3.png" medium="image">
			<media:title type="html">Virtual server, page 3</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/telnet-to-server.png" medium="image">
			<media:title type="html">telnet to server</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/11/telnet-success.png" medium="image">
			<media:title type="html">telnet success</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring an &#8220;Unattended Install&#8221; shell extension for quick msi installation.</title>
		<link>http://andrewmorgan.ie/2011/12/01/configuring-an-unattended-install-shell-extension-for-quick-msi-installation/</link>
		<comments>http://andrewmorgan.ie/2011/12/01/configuring-an-unattended-install-shell-extension-for-quick-msi-installation/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 09:03:50 +0000</pubDate>
		<dc:creator>Andrew Morgan</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://andrewmorgan.ie/?p=1221</guid>
		<description><![CDATA[We&#8217;ve all been there, A list of msi&#8217;s necessary for a clients application and clicking next next next begins to wear thin. For me I had 7 servers to install 4 msi&#8217;s and scripting wasn&#8217;t an option as the software in question couldn&#8217;t be run in a non-interactive session. To alleviate the issue, I added [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1221&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all been there, A list of msi&#8217;s necessary for a clients application and clicking next next next begins to wear thin. For me I had 7 servers to install 4 msi&#8217;s and scripting wasn&#8217;t an option as the software in question couldn&#8217;t be run in a non-interactive session.</p>
<p>To alleviate the issue, I added a simple shell extension to perform unattended installs of each of the msi&#8217;s:</p>
<p><a href="http://andymorgan.files.wordpress.com/2011/12/unattended-install.png"><img class="aligncenter size-full wp-image-1222" title="unattended install" src="http://andymorgan.files.wordpress.com/2011/12/unattended-install.png?w=600" alt=""   /></a></p>
<p>I&#8217;ve made the registry file available <a href="http://www.box.com/s/hfchfxh1o75dr583gj97">here</a> for download should you also be stuck with this task at some point.</p>
<p>The registry file is very simple as you can see below:</p>
<p><a href="http://andymorgan.files.wordpress.com/2011/12/regdetails.png"><img class="aligncenter size-full wp-image-1223" title="regdetails" src="http://andymorgan.files.wordpress.com/2011/12/regdetails.png?w=600&#038;h=127" alt="" width="600" height="127" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/andymorgan.wordpress.com/1221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/andymorgan.wordpress.com/1221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/andymorgan.wordpress.com/1221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/andymorgan.wordpress.com/1221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/andymorgan.wordpress.com/1221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/andymorgan.wordpress.com/1221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/andymorgan.wordpress.com/1221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/andymorgan.wordpress.com/1221/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=andrewmorgan.ie&amp;blog=3794180&amp;post=1221&amp;subd=andymorgan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://andrewmorgan.ie/2011/12/01/configuring-an-unattended-install-shell-extension-for-quick-msi-installation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c545af60a31f7dc666bfca92e2ac0c0b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Andy</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/12/unattended-install.png" medium="image">
			<media:title type="html">unattended install</media:title>
		</media:content>

		<media:content url="http://andymorgan.files.wordpress.com/2011/12/regdetails.png" medium="image">
			<media:title type="html">regdetails</media:title>
		</media:content>
	</item>
	</channel>
</rss>
