<?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>.\Matthew Long</title>
	<atom:link href="http://matthewlong.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://matthewlong.wordpress.com</link>
	<description>{An unsorted collection of thoughts}</description>
	<lastBuildDate>Sat, 12 Nov 2011 18:02:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='matthewlong.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>.\Matthew Long</title>
		<link>http://matthewlong.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://matthewlong.wordpress.com/osd.xml" title=".\Matthew Long" />
	<atom:link rel='hub' href='http://matthewlong.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Scripting Series – Interesting things you can do with VBScript and Powershell &#8211; Part 5, Issues with Copy-item and Remove-Item</title>
		<link>http://matthewlong.wordpress.com/2011/10/13/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-5-issues-with-copy-item-and-remove-item/</link>
		<comments>http://matthewlong.wordpress.com/2011/10/13/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-5-issues-with-copy-item-and-remove-item/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 23:01:55 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=208</guid>
		<description><![CDATA[In the final part of this series I&#8217;m going to show two strange behaviours you can get when running the Remove-Item and Copy-Item powershell cmdlets on the file system provider. Remove-Item This one is fairly simple &#8211; essentially what happens is you may find when you ask Remove-Item to delete a folder structure using the -Recurse  switch that it has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=208&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the final part of <a title="Scripting Series – Interesting things you can do with VBScript and Powershell" href="http://matthewlong.wordpress.com/2011/02/25/script-series-title/">this series</a> I&#8217;m going to show two strange behaviours you can get when running the <em>Remove-Item</em> and <em>Copy-Item</em> powershell cmdlets on the file system provider.</p>
<h2>Remove-Item</h2>
<p>This one is fairly simple &#8211; essentially what happens is you may find when you ask Remove-Item to delete a folder structure using the <strong>-Recurse</strong>  switch that it has a tendency to trip over itself and leave folders behind as they are still marked in use.. by the cmdlet!  To overcome this we can simply setup a Do While loop to check if the folder exists and attempt to remove it (and all contents) continuously until we succeed (usually completes within 2 loops).</p>
<p><pre class="brush: powershell;">

Do
{
      Write-Host &quot;Attempting to remove Files Recursively..&quot;
      Start-Sleep -Seconds 1
      Remove-Item $FilesLocation -Recurse -Force -ErrorAction SilentlyContinue
}
While (Test-Path $FilesLocation -ErrorAction SilentlyContinue)

</pre></p>
<p>For those unfamiliar, the <em><strong>Do..While</strong></em> construct will attempt an action once, and then check the criteria to see if the action should be repeated.  In this case <em>Test-Path</em> will return true if the path exists and false if it does not.  So if the folder has been deleted, another attempt will be made.  The <strong>-ErrorAction SilentlyContinue</strong> parameters simply stop the commands from writing out either the error condition we are explicitly handling (files locked in use) or that the path does not exist (which is what we want in this scenario, so lets not raise an error for that state).</p>
<h2>Copy-Item</h2>
<p>This one has been around the internet a few times already, and in this case the solution was one I came across.  Unfortunately I&#8217;m not sure who the original author is, but if anyone knows I&#8217;ll gladly accredit it.  Anyway, the issue is that Copy-Item has a slight behavioural quirk; if you try to copy a folder, and the destination folder name already exists, the item(s) to be copied are instead placed <em>inside</em> the pre-existing destination folder, in a subfolder.</p>
<p>The result is that if you tried to copy the contents of c:\foo to c:\bar, and bar already existed you&#8217;d wind up with all your files from c:\foo inside the c:\bar\bar folder!</p>
<p>Thankfully, the function below sorts this behaviour out -</p>
<p><pre class="brush: powershell;">
Function Copy-Directory
{
       Param(
       [System.String]$Source,
       [System.String]$Destination)
       $Source = $Source -replace '\*$'
       If (Test-Path $Destination)
       {
              Switch -regex ($Source)
              {
                  '\\$' {$Source = &quot;$Source*&quot;; break}
                  '\w$' {$Source = &quot;$Source\*&quot;; break}
                  Default {break}
              }
      }
      Copy-Item $Source $Destination -recurse -force
}
</pre></p>
<p>Now you can call Copy-Directory folder1 folder2 and get consistent results &#8211; if the destination does not exist, it is created. If the destination does exist, then all files are copied into the pre-existing folder.</p>
<p>The function works by testing if the destination folder already exists, and if it does, modifying the source criteria so that copy-item is instead looking for a wildcard match on the folders contents, rather than the source folder itself.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=208&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/10/13/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-5-issues-with-copy-item-and-remove-item/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting Series – Interesting things you can do with VBScript and Powershell Part 4 &#8211; Setting up HyperV host networking</title>
		<link>http://matthewlong.wordpress.com/2011/10/11/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-4-setting-up-hyperv-host-networking/</link>
		<comments>http://matthewlong.wordpress.com/2011/10/11/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-4-setting-up-hyperv-host-networking/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 14:14:43 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Hyper-V]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=200</guid>
		<description><![CDATA[As you may recall from the introduction to this series, I was tasked with creating a script that would handle the setup/tear down of student lab machines that were to be used for short training courses.  The PCs belong to the training provider and it&#8217;s up to the instructor to come in before the course [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=200&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As you may recall from the <a href="http://matthewlong.wordpress.com/2011/02/25/script-series-title/">introduction to this series</a>, I was tasked with creating a script that would handle the setup/tear down of student lab machines that were to be used for short training courses.  The PCs belong to the training provider and it&#8217;s up to the instructor to come in before the course and set all of the student machines up.  Often 15 times, on a sunday.</p>
<p>This post deals with the (relatively simple) task of setting up the virtual network adapter that is normally nearly always provided as an internal/external network on the student machines, specifically the IP settings so that the guest VMs can communicate with the host HyperV server.</p>
<p>Let&#8217;s take a look at the script first, and then i&#8217;ll walk you through it.  As noted in the first article, I used James O&#8217; Neill&#8217;s fantastic <a title="HyperV Module" href="http://pshyperv.codeplex.com/" target="_blank">HyperV Module</a> to accomplish the HyperV lifting!</p>
<h2>The Script</h2>
<p><pre class="brush: powershell;">

#Setup Internal HyperV Network if it doesn't already exist

If (!(Get-VMSwitch $NetworkName))
{
New-VMInternalSwitch -VirtualSwitchName $NetworkName -Force | Out-Null
}
Else
{
Write-Host &quot;`nVirtual Network '$NetworkName' already exists, Skipping...&quot;
}

#Setup Local Loopback adapter
$vSwitch = Get-WmiObject -Query ('Select * from Win32_PnPEntity where name = &quot;' + $NetworkName +'&quot;')
$Query = &quot;Associators of {$vSwitch} where ResultClass=Win32_NetworkAdapter&quot;
$NicName = (Get-WmiObject -query $Query ).NetConnectionID
Invoke-Expression 'netsh interface ip set address &quot;$NicName&quot; static 192.168.1.150 255.255.255.0'
Write-Host &quot;Server now has IP on internal network of '192.168.1.150'&quot;

</pre></p>
<p>The code is fairly self explanatory, but i&#8217;ll walk through it anyway.  First we use the HyperV module to determine if there is an Internal network with the given name in $NetworkName already in existence, and if not we create it.  If you haven&#8217;t seen it before, Out-Null is a powershell command to send pipeline information into the aether, and is useful when you don&#8217;t want a cmdlet writing back objects or text to the console during execution (a lot of people just instead write to a variable they have no intention of using).</p>
<p>This will create a Virtual network card on the host HyperV system, which can be seen in network connections.  The name you set in HyperV for the name of the network will be the PNP device name, as shown below..</p>
<p><a href="http://matthewlong.files.wordpress.com/2011/10/untitled.png"><img class="aligncenter size-full wp-image-201" title="Network Adapters" src="http://matthewlong.files.wordpress.com/2011/10/untitled.png" alt="" width="718" height="165" /></a></p>
<p>We then use that name to associate the PNP device to the network adapter, and then invoke good old netsh to set the adapter for us automatically.</p>
<h2>Why use those methods</h2>
<p>I realize that the PNP device name is actually a property directly available on the Win32_NetworkAdapter class, so why didn&#8217;t I use it?  The short answer is that the NetworkAdapter can have some very odd behaviours sometimes (watch what happens to your MAC address when you disable the network adapter..) and to avoid those issue&#8217;s I only used properties of the class I knew I could rely on &#8211; namely the NetConnectionId.</p>
<p>I could have also used WMI to set the IP address information, but it&#8217;s nowhere near as easy as calling netsh and certainly isn&#8217;t accomplished in a single neat line.  There is no harm in doing it using WMI if you so wish (and that will be easier if you were doing complex configuration changes).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=200&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/10/11/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-4-setting-up-hyperv-host-networking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>

		<media:content url="http://matthewlong.files.wordpress.com/2011/10/untitled.png" medium="image">
			<media:title type="html">Network Adapters</media:title>
		</media:content>
	</item>
		<item>
		<title>Integrating Operations Manager 2012 beta with Opalis / Orchestrator</title>
		<link>http://matthewlong.wordpress.com/2011/10/10/integrating-operations-manager-2012-beta-with-opalis-orchestrator/</link>
		<comments>http://matthewlong.wordpress.com/2011/10/10/integrating-operations-manager-2012-beta-with-opalis-orchestrator/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 06:18:35 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Opalis]]></category>
		<category><![CDATA[Operations Manager 2007]]></category>
		<category><![CDATA[Operations Manager 2012]]></category>
		<category><![CDATA[Orchestrator 2012]]></category>
		<category><![CDATA[SCO 2012]]></category>
		<category><![CDATA[SCOM 2007]]></category>
		<category><![CDATA[SCOM 2012]]></category>
		<category><![CDATA[SCORCH]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=195</guid>
		<description><![CDATA[I&#8217;m lucky enough in my lab environment to have access to both the Orchestrator beta and both SCOM 2007 and SCOM 2012 beta.  I was recently tasked with creating a demo for a customer focused around SCOM 2012 and Orchestrator.  Whilst an updated integration pack for SCOM 2012 has yet to be released for Orchestrator (or indeed, Opalis 6.3) you can use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=195&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m lucky enough in my lab environment to have access to both the Orchestrator beta and both SCOM 2007 and SCOM 2012 beta.  I was recently tasked with creating a demo for a customer focused around SCOM 2012 and Orchestrator.  Whilst an updated integration pack for SCOM 2012 has yet to be released for Orchestrator (or indeed, Opalis 6.3) you can use the existing IP just fine, providing you complete a few work arounds.</p>
<h2>Requirements</h2>
<p>First thing &#8211; you&#8217;re going to need access to the SCOM 2007 R2 media to be able to complete this.  As directed by the SCOM Integration pack, install the <strong>SCOM 2007 R2 </strong>console on your action/runbook servers and your Client/Designer machines.  If you attempt to use the SCOM 2012 console in it&#8217;s place you will (in my experience) receive connection errors when attempting to use the IP.</p>
<h2>Create Alert object workaround</h2>
<p>Secondly &#8211; In order to use the <strong>Create Alert</strong> object the Integration pack will normally deploy a management pack into SCOM automatically the first time it is used.  Unfortunately the SDK for SCOM has changed and the method previously employed no longer works (you will receive an error stating as such when the object attempts to run).  In order to resolve this, you will need to :</p>
<ol>
<li>Have Opalis/Orchestrator raise an alert in a SCOM 2007 environment</li>
<li>Export the management pack from the SCOM 2007 environment that has been automatically imported.  Note that as the MP is sealed, you will need to use the Export-ManagementPack powershell command as the GUI will have the export option grayed out.  The management pack is called <strong>Opalis Integration Library</strong>.Get-ManagementPack | ? {$_.name -match &#8217;Opalis&#8217;} | Export-ManagementPack -path c:\Folder\</li>
<li>Import the management pack into your SCOM 2012 environment</li>
</ol>
<p>Following this, you will now be able to use all of the IP objects in both SCOM 2007 and SCOM 2012.</p>
<p>For those without access to SCOM 2007, i&#8217;ve attached a copy of the management pack that you can import into your environment.  <strong>Note :</strong> The management pack is <em>unsealed</em> as it&#8217;s been exported from within a SCOM environment.  If you are uncomfortable importing an unsealed MP into your environment, do not do so, and instead utilize the method above to obtain your own (still unsealed) version of the MP.</p>
<p><a title="Opalis.Integration.Library.zip" href="https://docs.google.com/viewer?a=v&amp;pid=explorer&amp;chrome=true&amp;srcid=0B6ckvck8UtQ6ZTczM2M5MmYtNDkwOC00MjdiLTgwMWQtMjRiZDY2MGZkNDFl&amp;hl=en_US">Link to Opalis.Integration.Library.zip</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/195/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=195&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/10/10/integrating-operations-manager-2012-beta-with-opalis-orchestrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
		<item>
		<title>Book Review : System Center Opalis Integration Server 6.3</title>
		<link>http://matthewlong.wordpress.com/2011/10/10/book-review-system-center-opalis-integration-server-6-3/</link>
		<comments>http://matthewlong.wordpress.com/2011/10/10/book-review-system-center-opalis-integration-server-6-3/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 05:39:59 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Opalis]]></category>
		<category><![CDATA[Orchestrator 2012]]></category>
		<category><![CDATA[SCO 2012]]></category>
		<category><![CDATA[SCORCH]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=192</guid>
		<description><![CDATA[Introduction Penned by an all-star cast of Microsoft Evangelists and community MVPs, System Center Opalis Integration Server 6.3 Unleashed is a dedicated resource for all things Opalis.  The book is published by Sams, and is available in physical (paperback) and Kindle editions. Review For those looking for a thorough and in-depth resource on Opalis Integration Server, this is definitely it.  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=192&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2><a href="http://matthewlong.files.wordpress.com/2011/10/ois-6-3-unleashed.jpg"><img class="size-medium wp-image-193 alignleft" title="System Center Opalis Integration Server 6.3" src="http://matthewlong.files.wordpress.com/2011/10/ois-6-3-unleashed.jpg?w=240&#038;h=240" alt="" width="240" height="240" /></a><strong>Introduction</strong></h2>
<p>Penned by an all-star cast of Microsoft Evangelists and community MVPs, System Center Opalis Integration Server 6.3 Unleashed is a dedicated resource for all things Opalis.  The book is published by Sams, and is available in physical (paperback) and Kindle editions.</p>
<h2><strong>Review</strong></h2>
<p>For those looking for a thorough and in-depth resource on Opalis Integration Server, this is definitely it.  The book starts out discussing the history and concepts of Opalis integration server, introducing the product to new users and relating users of previous versions to the current product with ease.</p>
<p>The book then goes on to discuss the Architectural design, installation, implementation and best practises when setting up Opalis in your environment, complete with design discussions and important questions that you should consider before touching the installer binaries.</p>
<p>Key foundation objects and common/advanced tasks are covered, always with examples, including Data Manipulation, Data Persistence, Scheduling, calling external systems error control and more.  The book is not afraid to point to community Integration packs to ensure that you can get the most out of your environment, and I&#8217;d be surprised if you&#8217;ve heard of them all.</p>
<p>The 3rd party integration packs included with the product are then discussed, with object listings and installation requirements.  This is followed by dedicated chapters for integrating Opalis with each System Center product, covering the installation of the IP and then their object uses.  Sample workflows are included with step-by-step construction examples.  It would have been nice if a bit more time had been spent with the 3rd party IPs, but the breadth of products available in this category would have easily turned this 500 page book into a huge hulking tome).</p>
<p>An entire chapter is then dedicated to Data Center scenarios and workflows, with many challenges to/for private cloud tackled and demonstrated.  While the challenges in this chapter are solved primarily to System Center products, you can easily see how they could be resolved with comparable technologies (Swap out System Center Service Manager for your own CMDB and Service desk product, for example).</p>
<p>Finally, the book discusses the Quick Integration Kit, and unlike many other resources I&#8217;ve seen out there actually covers the QIK/Opalis SDK.  This chapter is a good compliment to the QIK SDK documentation and if you are interested in IP development is definitely a must read.</p>
<p>The appendices are full of useful links to various online resources, many of which readers will already (or should) be familiar with.</p>
<h2>Looking ahead &#8211; System Center Orchestrator 2012</h2>
<p>The book is very careful with the topic of Orchestrator and does not attempt to muddy the waters &#8211; it is firmly an Opalis 6.3 book.  However nearly all the topics discussed and skills learned are directly applicable to Orchestrator and i&#8217;d still recommend the book to anyone using scorch as aside from the system requirements and Operators console, everything else is directly transferable (albiet with a slightly different dictionary &#8211; Policies are now Runbooks, Objects are now activities, etc).</p>
<h2>Summary</h2>
<p>In closing, I felt this was a good resource with lots of practical, helpful example workflows.  The subject matter is discussed in-depth and limitations with the product are addressed, with best practise being discussed throughout.  There are unfortunately some editorial errors in the book (in one case a displaced paragraph!) but the technical content remains error free.  This is a book I am glad to own and one I&#8217;d recommend to anyone interested in or working with Opalis 6.3 or the upcoming Orchestrator 2012.</p>
<p><strong></strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=192&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/10/10/book-review-system-center-opalis-integration-server-6-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>

		<media:content url="http://matthewlong.files.wordpress.com/2011/10/ois-6-3-unleashed.jpg?w=300" medium="image">
			<media:title type="html">System Center Opalis Integration Server 6.3</media:title>
		</media:content>
	</item>
		<item>
		<title>Courseware : 50507A Designing IT Process Automation with Opalis Integration Server</title>
		<link>http://matthewlong.wordpress.com/2011/10/10/courseware-50507a-designing-it-process-automation-with-opalis-integration-server/</link>
		<comments>http://matthewlong.wordpress.com/2011/10/10/courseware-50507a-designing-it-process-automation-with-opalis-integration-server/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 04:50:59 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Opalis]]></category>
		<category><![CDATA[Orchestrator 2012]]></category>
		<category><![CDATA[SCO 2012]]></category>
		<category><![CDATA[SCORCH]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=189</guid>
		<description><![CDATA[I recently had the fortune to take part in the Microsoft official course 50507A - Designing IT Process Automation with Opalis Integration Server, and thought I would briefly share my views on the courseware. For those of you looking for a solid introduction or rounding out of your Opalis knowledge/skills, this is a very good, hands on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=189&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently had the fortune to take part in the Microsoft official course 50507A - Designing IT Process Automation with Opalis Integration Server, and thought I would briefly share my views on the courseware.</p>
<p>For those of you looking for a solid introduction or rounding out of your Opalis knowledge/skills, this is a very good, hands on course.  The ratio of time spent in hands on labs to lecture/discussion is almost 2:1, so for those of you who like getting your hands on the product and learning for yourself, this is a great course.</p>
<p>Many of the powerful foundation objects are covered, with practical examples of the application of each.  The courseware also covers integrating with the entire system center suite, though labs neglect SCCM and SCDPM unless you/the instructor choose to set a challenge lab.  Also discussed (though not to a huge depth, given the courseware requirements and general accessibility) is the production of one&#8217;s own Integration Packs using the Quick Integration Kit, including a lab on the QIK CLI.</p>
<p>Finally, for those of you considering Orchestrator this course is completely applicable &#8211; all of the knowledge transfers directly across with only a few modifications (namely terminology, system requirements, and the Operations Console, the latter of which is only discussed but not featured in the courseware/labs).  A good instructor will point out these where appropriate so that you are ready to go when Orchestrator goes RTM (currently Orchestrator 2012 is in public beta).</p>
<p>In closing, this is one of the higher rated MOC in recent times, and it&#8217;s clear to see why.  I wouldn&#8217;t recommend taking every MOC, but I&#8217;d definitely recommend this one.</p>
<p><a title="Course 50507A: Designing IT Process Automation with Opalis Integration Server" href="http://www.microsoft.com/learning/en/us/course.aspx?ID=50507A&amp;Locale=en-us" target="_blank">Course 50507A: Designing IT Process Automation with Opalis Integration Server</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/189/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/189/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/189/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=189&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/10/10/courseware-50507a-designing-it-process-automation-with-opalis-integration-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting Series – Interesting things you can do with VBScript and Powershell – Post 3, embedded scripts</title>
		<link>http://matthewlong.wordpress.com/2011/03/15/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-%e2%80%93-post-3-embedded-scripts/</link>
		<comments>http://matthewlong.wordpress.com/2011/03/15/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-%e2%80%93-post-3-embedded-scripts/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 23:28:40 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=165</guid>
		<description><![CDATA[In the third article in this series, i&#8217;m going to discuss embedding scripts inside each other so that you can have a library of scripts deployed from a single script.  This can also be useful if you need to say use Powershell to create and execute a different kind of script (in my case, so we can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=165&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the <a title="Scripting Series – Interesting things you can do with VBScript and Powershell" href="http://matthewlong.wordpress.com/2011/02/25/script-series-title/">third article in this series</a>, i&#8217;m going to discuss embedding scripts inside each other so that you can have a library of scripts deployed from a single script.  This can also be useful if you need to say use Powershell to create and execute a different kind of script (in my case, so we can use a VBScript to perform self deletion).  In addition, when we write out the embedded script we can take arguments for the current script and modify the embedded script to &#8220;remember&#8221; those runtime parameters. </p>
<p>In powershell this is a fairly trivial task, as depending on the script language you wish to embed you can either use a script block or a Here-String.  A Here-String is a powershell construct you can use to declare a string where all formatting, special characters are ignored.  This includes carriage returns, so you can easily create multiline strings.  You can also use a variant to suspend string substitution.  The block below shows an example..</p>
<p><pre class="brush: powershell;">

$Script = @&quot;
'This is the first line of a 'String'' without any matching &quot;quote` marks.
'This is the second line of the string with a         tab in it
option explicit
Dim someVar, otherVar
'Do some work here
WScript.Echo &quot;Some output&quot;
WScript.Quit

&quot;@
$Script | Set-Content '.\VBScript.vbs'

</pre></p>
<p>Unfortunately wordpresses code block doesn&#8217;t recognise the here-string, but i assure you it works! Note that because tabs are captured inside the here-string, if you choose to indent the string, the tabs will be captured into the middle of your string.  Note that if you use speechmarks string substitution will still take place, so if you want to use $ in your here-string, use apostrophes instead ( @&#8217; this is my string &#8216;@ )</p>
<p>Once you&#8217;ve got your string, all that you have to do is output the string to a file using Set-Content or Add-Content.</p>
<p>If you&#8217;re embedding a powershell script, you can instead use a scriptblock.  This is quite nice if you are writing your script inside an IDE like Powershell ISE, PowerGUI or PrimalScript, as now you can have syntax highlighting which hopefully will help reduce the number of errors inside your embedded script.  I&#8217;ve given an example below..</p>
<p><pre class="brush: powershell;">

$Script = {

                  Write-Host &quot;inside scripblock..&quot;

}

$Script | Set-content .\Powershell.ps1

</pre></p>
<p>If you want to persist or setup arguments into your embedded script, you can use string replacement with here-strings to modify your script. Just put unique placeholder text into your string (such as ARG1_PLACEHOLDER) and then use pattern matching (or string substitution) to replace this with your value.  See the below example..</p>
<p><pre class="brush: powershell;">

$Script = @&quot;
'This is the first line of a 'String'' without any matching &quot;quote` marks.
'This is the second line of the string with a         tab in it
option explicit
Dim someVar, otherVar
someVar = SOMEVAR_VALUE
otherVar = OTHERVAR_VALUE
'Do some work here
WScript.Echo &quot;Some output&quot;
WScript.Quit

&quot;@
$Script = $Script -replace 'SOMEVAR_VALUE', &quot;myValue&quot;
$Script = $Script -replace 'OTHERVAR_VALUE', &quot;myOtherValue&quot;
$Script | Set-Content '.\VBScript.vbs'

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=165&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/03/15/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-%e2%80%93-post-3-embedded-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting Series &#8211; Interesting things you can do with VBScript and Powershell &#8211; Post 2, UAC Elevation</title>
		<link>http://matthewlong.wordpress.com/2011/03/06/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-2-uac-elevation/</link>
		<comments>http://matthewlong.wordpress.com/2011/03/06/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-2-uac-elevation/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 23:17:09 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=155</guid>
		<description><![CDATA[In the first challenge in this series, I covered script self deletion.  In this post, i&#8217;m going to talk about dealing with UAC elevation in VB and Powershell scripts, way&#8217;s of detecting if we are running as an administrator, and how to trigger a request for elevation.  There are a lot of other ways of doing this, but these [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=155&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the <a title="Scripting Series – Interesting things you can do with VBScript and Powershell – Post 1, Self Deletion" href="http://matthewlong.wordpress.com/2011/02/25/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-1-self-deletion/">first challenge</a> in this <a title="Scripting Series – Interesting things you can do with VBScript and Powershell" href="http://matthewlong.wordpress.com/2011/02/25/script-series-title/">series</a>, I covered script self deletion.  In this post, i&#8217;m going to talk about dealing with UAC elevation in VB and Powershell scripts, way&#8217;s of detecting if we are running as an administrator, and how to trigger a request for elevation.  There are a lot of other ways of doing this, but these are two methods that I find work pretty well.</p>
<p>Firstly, a note on UAC Elevation and how it works.  Elevation is performed on a per-process basis, at initialisation,  so once a process has been started without administrative rights, the only way to gain those rights is to restart the process or launch a child process and request that it be granted admin rights.</p>
<p>The other important thing to remember, is that when a non-elevated process checks group memberships from a user context that does have admin rights, that user is not returned in the results set.  effectively, to non-elevated processes, no matter what user the process is run with, that user is not in any admin groups.</p>
<p>First up, VBScript.</p>
<p><pre class="brush: vb;">
Option Explicit
Dim App
If WScript.Arguments.length =0 then
  Set App = CreateObject(&quot;Shell.Application&quot;)
  App.ShellExecute &quot;wscript.exe&quot;, Chr(34) &amp; WScript.ScriptFullName &amp; Chr(34) &amp; &quot; uac&quot;, &quot;&quot;, &quot;runas&quot;,1

Else

  'Perform Script Functions...

End If

WScript.Quit()

</pre></p>
<p>This is quite an elegant solution, if not the most efficient.  Essentially what the script does is first check to see if the script was started with an argument indicating we&#8217;ve run the process as an administrator explicitly.  If that argument is not found, we create a child process with the <strong>RunAs</strong> verb, and wait for that process to finish before we continue.  Starting the process with the <strong>RunAs</strong> verb will prompt for confirmation of administrative rights if we are not already in such a context.  The second process here is the WScript engine and our current VBScript&#8217;s path.  If our argument is found (in this case, the first argument <strong>uac</strong>) then rather than launching our child process, we instead carry on with our scripts main workload.</p>
<p>Obviously if your script accepts arguments, make sure you pass the other arguments onto your new process accordingly!  Note that in the above script, if you run the script with UAC off, or if you launch it the first time with admin rights, you won&#8217;t see a prompt and the script will just continue (but still create the second process).</p>
<p>Next up, Powershell.  As the Powershell process isn&#8217;t quite as  lightweight, we&#8217;ll do a check to see if this process is operating with the correct rights before trying to elevate.</p>
<p><pre class="brush: powershell;">

     Function Test-CurrentAdminRights
     {
      #Return $True if process has admin rights, otherwise $False
      $user = [System.Security.Principal.WindowsIdentity]::GetCurrent()
      $Role = [System.Security.Principal.WindowsBuiltinRole]::Administrator
      return (New-Object Security.Principal.WindowsPrincipal $User).IsInRole($Role)
     }

</pre></p>
<p>The function Test-CurrentAdminRights checks to see if the user that the script (the powershell.exe process) is running under is in the Administrator role.  As I mentioned earlier as the user isn&#8217;t marked as being in the administrative groups unless the process is operating as an admin, this will only ever return <strong>True</strong> if the process is running under an administrative context.</p>
<p>Personally, if the function returns false i&#8217;d prefer to throw an exception or message back to the user to ask them to launch the script from an administrative console.  The reason for this is that when we launch a new powershell process it might not have access to the same snappins, variables, current working directory (administrative PS consoles start in C:\Windows\System32), etc.  However, the below function will elevate the current script if you need it to :</p>
<p><pre class="brush: powershell;">
Function Invoke-AsAdmin()
{
    Param
         (
    [System.String]$ArgumentString = &quot;&quot;
         )
    $NewProcessInfo = new-object &quot;Diagnostics.ProcessStartInfo&quot;
    $NewProcessInfo.FileName = [System.Diagnostics.Process]::GetCurrentProcess().path    
    $NewProcessInfo.Arguments = &quot;-file &quot; + $MyInvocation.MyCommand.Definition + &quot; $ArgumentString&quot;
    $NewProcessInfo.Verb = &quot;runas&quot;
    $NewProcess = [Diagnostics.Process]::Start($NewProcessInfo)
    $NewProcess.WaitForExit()
}

</pre></p>
<p>Just pass in any arguments you need to this function, and it will create the necessary process.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=155&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/03/06/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-2-uac-elevation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
		<item>
		<title>Cleaning up Windows 7 / Server 2008 R2 Service pack 1 Files</title>
		<link>http://matthewlong.wordpress.com/2011/03/04/cleaning-up-windows-7-server-2008-r2-service-pack-1-files/</link>
		<comments>http://matthewlong.wordpress.com/2011/03/04/cleaning-up-windows-7-server-2008-r2-service-pack-1-files/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 11:29:57 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[DISM]]></category>
		<category><![CDATA[WIM]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Server 2008 R2]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=148</guid>
		<description><![CDATA[I&#8217;ve recently been updating various computers, wim images and virtual machines with NT 6.1 Sp1 (Windows 7 and Server 2008 R2).  As many people may have noticed before, this once again means you can expect a large jump in the size of your Side-By-Side repository (the C:\Windows\Winsxs).  Unlike with Vista and Server 2008 SP1/SP2 there is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=148&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:left;">I&#8217;ve recently been updating various computers, wim images and virtual machines with NT 6.1 Sp1 (Windows 7 and Server 2008 R2).  As many people may have noticed before, this once again means you can expect a large jump in the size of your Side-By-Side repository (the C:\Windows\Winsxs).  Unlike with Vista and Server 2008 SP1/SP2 there is no cleanup tool provided with the service pack.  This is because DiskCleanup / DISM are already provided for you to do this.</p>
<p style="text-align:left;">So what does this involve?  Removing the service pack backup files will essentially remove all of the superseded files and libraries that the service pack updated, at the cost of now being unable to remove the service pack (as you cannot roll back to the superseded versions).  The amount of space you will recover can vary but is usually between 1-2gb.  That isn&#8217;t a lot for end-user machines, but that can be huge when you are looking at machine images and virtual environments.  Obviously you should<strong> thoroughly test your machines / images before committing to such an endeavour. </strong></p>
<p style="text-align:left;">There are essentially two ways to complete this process.  If you have access to the Disk Cleanup tool (Windows 7 or Windows Server 2008 R2 with the desktop experience pack installed) you can run that, click on the &#8220;Cleanup System Files&#8221; button (requires user elevation) and when the tool re-opens select &#8220;Service Pack Backup Files&#8221;.</p>
<p>If you don&#8217;t have Disk Cleanup installed, or are working with an offline WIM image, you are going to need to use DISM.</p>
<ol>
<li>Start an elevated command or Powershell prompt (Run as Administrator)</li>
<li>If you are servicing this machine, enter <strong>dism /online /cleanup-image /spsuperseded /hidesp</strong> to cleanup the online computer.  If you want to cleanup an offline wim image, instead enter <strong>dism /image:</strong><em>wimfile.wim</em> <strong>/Cleanup-Image / spsuperseded /hidesp</strong>.  The <strong>/hidesp</strong> option will remove SP1 from the &#8220;Installed Updates&#8221; section of Programs and Features, to ensure that users do not try to uninstall the service pack.<strong>  </strong></li>
<li>DISM will now remove backup files and superseded components from your machine.  When finished, you should have the below output :</li>
</ol>
<div class="mceTemp mceIEcenter" style="text-align:left;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><a href="http://matthewlong.files.wordpress.com/2011/03/04-03-2011.png"><img class="size-full wp-image-149 " title="dism /Cleanup-Image /spsuperseded /hidesp" src="http://matthewlong.files.wordpress.com/2011/03/04-03-2011.png" alt="dism /Cleanup-Image /spsuperseded /hidesp results" width="486" height="216" /></a></dt>
<dd class="wp-caption-dd">dism /Cleanup-Image /spsuperseded /hidesp results</dd>
</dl>
</div>
<p>And that&#8217;s it, your done!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=148&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/03/04/cleaning-up-windows-7-server-2008-r2-service-pack-1-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>

		<media:content url="http://matthewlong.files.wordpress.com/2011/03/04-03-2011.png" medium="image">
			<media:title type="html">dism /Cleanup-Image /spsuperseded /hidesp</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting Series &#8211; Interesting things you can do with VBScript and Powershell &#8211; Post 1, Self Deletion</title>
		<link>http://matthewlong.wordpress.com/2011/02/25/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-1-self-deletion/</link>
		<comments>http://matthewlong.wordpress.com/2011/02/25/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-1-self-deletion/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 10:55:07 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=129</guid>
		<description><![CDATA[For the first challange i&#8217;m going to tackle in this series, we have the problem of self deletion. After quite a bit of experimentation, i found a powershell script cannot delete itself without help from some outside source.  Having the script setup a scheduled task on a timer to delete itself is one option, and Scheduled tasks [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=129&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the first challange i&#8217;m going to tackle in this <a title="Scripting Series – Interesting things you can do with VBScript and Powershell" href="http://matthewlong.wordpress.com/2011/02/25/script-series-title/">series</a>, we have the problem of self deletion.</p>
<p>After quite a bit of experimentation, i found a powershell script cannot delete itself without help from some outside source.  Having the script setup a scheduled task on a timer to delete itself is one option, and Scheduled tasks in powershell is certainly well documented on the internet. </p>
<p>However, as i already wanted a simple way of <em>students</em> cleaning up their own machines (and telling someone who has never used powershell to run as an admin, set execution policy etc etc isn&#8217;t fun) i instead decided to go with a VBScript.  As the Windows Scripting Host copies the entire script into memory and <em>then</em> executes it, this means that VBScripts can not only trigger my cleanup powershell script with the correct arguments, it can then also delete the .ps1 file and itself!  All the student has to do is double click on a shortcut on their desktop.</p>
<p>Here is a sample file that does the job.</p>
<p><pre class="brush: vb;">
Option Explicit
Dim FSO,VbScript,PowershellScript, Shell, Cmd, CurrentDirectory, Answer,
Set Shell  = CreateObject(&quot;WScript.Shell&quot;)
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
PowerShellScript = &quot;C:\Training Lab\CleanupScript.ps1&quot;
Answer = MsgBox(&quot;Are you sure you want to Remove all lab files?&quot;,VBYesNo,&quot;Cleanup Confirm&quot;)
If Answer = 6 Then
 'Copy script to current folder
 CurrentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(Len(WScript.ScriptName)))
 FSO.GetFile(PowerShellScript).Copy CurrentDirectory &amp; &quot;CleanupScript.ps1&quot;, True
 
 'Run Powershell Script
 Cmd = &quot;powershell -executionpolicy RemoteSigned -Command &quot;&quot;&amp; {cd &quot;&amp; CurrentDirectory &amp;&quot;; .\CleanupScript.ps1}&quot;&quot;&quot;
 Shell.Run appCmd, 4, True
 'Cleanup Files
 VbScript = Wscript.ScriptFullName
 FSO.DeleteFile CurrentDirectory &amp; &quot;CleanupScript.ps1&quot;, True

 FSO.DeleteFile VbScript, True
 WScript.Echo &quot;Cleanup Finished&quot;
Else
    Msgbox &quot;Cleanup Cancelled.&quot;
End If
WScript.Quit
</pre></p>
<p>This fairly simple script sits on the users desktop and when run, will prompt the user if they would like to cleanup the lab (Just going ahead and doing it doesn&#8217;t seem like a wise idea for something so easily launched!)<br />
Once confirmed, we copy the powershell script out of it&#8217;s resources folder to the current directory. This may not be neccessary, the reason i had to do it was that i placed the powershell script in a folder it was going to try and delete, so running it from that location wasn&#8217;t going to work.</p>
<p>We then build an argument string to run powershell. I&#8217;ve used -command rather than -file so that i can change the working directory of powershell. This is becuase my script is going to use the working directory, and when running using an elevated shell i don&#8217;t want the path to be c:\windows\system32!  I&#8217;ve also specified &#8220;-executionpolicy RemoteSigned&#8221; so that I don&#8217;t have to worry about what the system&#8217;s execution policy is currently set to.</p>
<p>Make sure when using the <em>Shell.Run</em> method you specify the bW<em>aitOnReturn</em> argument as <strong>True</strong>. Otherwise, your VBScript is going to try and delete things whilst they are still in use.  I&#8217;ve specified that the powershell window be shown (Mode 4) as the script displays progress reports to the user, but you could hide it using mode 0 if you wished.</p>
<p>Finally, we get the the path to our currently executing vbscript and delete both the powershell script and the VBScript itself.  All done!</p>
<p>Obviously this method has a couple of drawbacks.  Now i have to maintain two script files, and what if i change the name of the powershell script (or the path?).  Additionally, what if my script needs Admin priviledges and UAC mode is enabled?</p>
<p>I&#8217;ll address all of those points in later articles in this series.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=129&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/02/25/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-1-self-deletion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting Series &#8211; Interesting things you can do with VBScript and Powershell</title>
		<link>http://matthewlong.wordpress.com/2011/02/25/script-series-title/</link>
		<comments>http://matthewlong.wordpress.com/2011/02/25/script-series-title/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 10:54:28 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://matthewlong.wordpress.com/?p=125</guid>
		<description><![CDATA[I was recently tasked with creating a script (language was my choice) that can set up a bunch of machines for students undertaking some training using virtual machines.  The student servers are not managed by System Center Virtual Machine Manager and may not even be network connected, so the script was going to have to do all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=125&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was recently tasked with creating a script (language was my choice) that can set up a bunch of machines for students undertaking some training using virtual machines.  The student servers are not managed by System Center Virtual Machine Manager and may not even be network connected, so the script was going to have to do all the hard work of copying machines and resource files from the USB source, staging them in sensible places, importing the VMs into HyperV and performing some other configuration tasks.  As the training was also taking place in a public training centre, It also had to help tear the whole thing down again afterwards, including (in order to protect IP) itself!</p>
<p>Naturally Powershell was a good choice for this task as it can accomplish most of the above without breaking a sweat.  Rather than re-invent the wheel, I used James O&#8217; Neill&#8217;s fantastic <a title="HyperV Module" href="http://pshyperv.codeplex.com/" target="_blank">HyperV Module</a>.  All I had to deal with now were some other interesting challenges, namely</p>
<ul>
<li><a title="Scripting Series – Interesting things you can do with VBScript and Powershell – Post 1, Self Deletion" href="http://matthewlong.wordpress.com/2011/02/25/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-1-self-deletion/">Script Self Deletion</a></li>
<li><a title="Scripting Series – Interesting things you can do with VBScript and Powershell – Post 2, UAC Elevation" href="http://matthewlong.wordpress.com/2011/03/06/scripting-series-interesting-things-you-can-do-with-vbscript-and-powershell-post-2-uac-elevation/">UAC Elevation</a></li>
<li><a title="Scripting Series – Interesting things you can do with VBScript and Powershell – Post 3, embedded scripts" href="http://matthewlong.wordpress.com/2011/03/15/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-%e2%80%93-post-3-embedded-scripts/">Having 1 Script create multiple other scripts</a></li>
<li><a title="Scripting Series – Interesting things you can do with VBScript and Powershell Part 4 – Setting up HyperV host networking" href="http://matthewlong.wordpress.com/2011/10/11/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-4-setting-up-hyperv-host-networking/">Setting up virtual NICs with correct IP information</a></li>
<li><a title="Scripting Series – Interesting things you can do with VBScript and Powershell – Part 5, Issues with Copy-item and Remove-Item" href="http://matthewlong.wordpress.com/2011/10/13/scripting-series-%e2%80%93-interesting-things-you-can-do-with-vbscript-and-powershell-part-5-issues-with-copy-item-and-remove-item/">Bugs in remove-item preventing files from being deleted correctly and odd behaviour from Copy-Item when moving directories</a></li>
</ul>
<p>Across a series of blog posts, I&#8217;ll show how i overcame these problems and created a pretty feature rich script for setting up lab environments.  Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matthewlong.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matthewlong.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matthewlong.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matthewlong.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matthewlong.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matthewlong.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matthewlong.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matthewlong.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matthewlong.wordpress.com&amp;blog=5951959&amp;post=125&amp;subd=matthewlong&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matthewlong.wordpress.com/2011/02/25/script-series-title/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5696b5f2e04d78b1147fca7f79d2d4c3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matthew</media:title>
		</media:content>
	</item>
	</channel>
</rss>
