<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Po$H Pete &#124; Those who can... $cript</title>
	<atom:link href="http://www.poshpete.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.poshpete.com</link>
	<description>A Technologists Blog on Powershell &#38; Automation in General</description>
	<lastBuildDate>Mon, 30 Jan 2012 09:04:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Automated Datacentre Deployment &#8211; It&#8217;s Time to Let Go of Your Physical Devices</title>
		<link>http://www.poshpete.com/automation/automated-datacentre-deployment-its-time-to-let-go-of-your-physical-devices</link>
		<comments>http://www.poshpete.com/automation/automated-datacentre-deployment-its-time-to-let-go-of-your-physical-devices#comments</comments>
		<pubDate>Fri, 27 Jan 2012 09:24:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[physical devices]]></category>
		<category><![CDATA[virtual networks]]></category>
		<category><![CDATA[virtual storage]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=275</guid>
		<description><![CDATA[I work in the process automation arena, and have mainly spent the last 6 months automating server build processes. You might think "Why have you been doing that? There are plenty of tools out there for it", well, you might be right… In fact you are right. The problem that I came up against is [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/automation/automated-datacentre-deployment-its-time-to-let-go-of-your-physical-devices"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fautomation%2Fautomated-datacentre-deployment-its-time-to-let-go-of-your-physical-devices"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fautomation%2Fautomated-datacentre-deployment-its-time-to-let-go-of-your-physical-devices&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=automation,physical+devices,virtual+networks,virtual+storage" height="61" width="50" /><br />
			</a>
		</div>
<p>I work in the process automation arena, and have mainly spent the last 6 months automating server build processes. You might think "Why have you been doing that? There are plenty of tools out there for it", well, you might be right…</p>
<p>In fact you are right. The problem that I came up against is that server build automation tools assume that there is a physical server with drives and network already setup that it can build or there is a virtual environment/"cloud" that it can start orchestrating. Can you see where the problem is yet? </p>
<p>Best of breed datacentre environments use dedicated physical devices delivering what they're designed for. Devices such as network switches and routers, firewalls and IPS/IDS devices, SAN and NAS technology, fabric networks, the list goes on.</p>
<p>All of these devices are made by the industry leaders, such as Cisco, HP, Broccade, Netapp etc, all who have their own configuration interfaces and run their own software/firmware, many don't even have an API…</p>
<p>So, when it comes to deploying an enterprise environment which will consist of a physical and virtual hybrid, you're not going to just be putting operating systems and applications on servers, you're going to be:</p>
<p> - Configuring access ports on network switches<br />
 - Configuring core network routing<br />
 - Configuring SAN or NAS storage and presenting it<br />
 - Configuring fabric networks<br />
 - Configuring physical server hardware via ILO or DRAC</p>
<p>All of the above are generally done by subject matter experts via SSH or a web interface or (if you’re lucky) via a vendor specific orchestration tool which will keep track of all the different command sets required by different firmware/software versions of their relevant devices.</p>
<p>The issue now comes in the fact that everyone is thinking "Cloud" with services such as "Auto Scaling" and "On-Demand", so they want virtual datacentre environments  delivering performance and security of the old school environments but spun up quickly, very quickly, we're talking minutes here, not days or weeks.</p>
<p>This provides a big challenge in orchestrating the configuration of all of these physical devices. This is not to say it can't be done, it CAN be done, I've done it, but should we be doing it?</p>
<p>If you look at products like VCloud Director, CA (Previously 3Tera) Applogic and AWS you'll start to see what I'm talking about. These physical datacentre elements are now virtualised. For instance, you can drop a virtual F5 firewall, load balancer or some S3 storage into your AWS environment, and you're done. Just "Drag and Drop" not "Rack and Stack". </p>
<p>All of these devices are now software, but delivered by industry leading vendors. This is not to say they're better than their physical predecessors, but they're a lot easier to deploy in a virtual datacentre environment, and more importantly, you can automate their configuration.</p>
<p>So, it really feels like we're on the cusp of a datacentre revolution, and it's one that a lot of enterprises and MSP's aren't ready for. If you're going to compete in this growing, agile, scalable and transient world of "The Cloud", it's time to lose the shackles of physical devices and embrace an even more virtual world.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/automation/automated-datacentre-deployment-its-time-to-let-go-of-your-physical-devices/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding Binary Data in a Text File &#8211; or Just Saving Binary Data as Text</title>
		<link>http://www.poshpete.com/powershell/embedding-binary-data-in-a-text-file-or-just-saving-binary-data-as-text</link>
		<comments>http://www.poshpete.com/powershell/embedding-binary-data-in-a-text-file-or-just-saving-binary-data-as-text#comments</comments>
		<pubDate>Mon, 19 Dec 2011 11:34:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[embed binary]]></category>
		<category><![CDATA[embed images]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=248</guid>
		<description><![CDATA[Morning All! A colleague of mine was recently doing some Powershell GUI work and mentioned to me that it would be cool if he could use an image in the form. Which got me to thinking about how you would actually store binary data into a text file... encoding is the answer. I've written the [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/embedding-binary-data-in-a-text-file-or-just-saving-binary-data-as-text"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fembedding-binary-data-in-a-text-file-or-just-saving-binary-data-as-text"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fembedding-binary-data-in-a-text-file-or-just-saving-binary-data-as-text&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=base64,embed+binary,embed+images,Powershell" height="61" width="50" /><br />
			</a>
		</div>
<p>Morning All! A colleague of mine was recently doing some Powershell GUI work and mentioned to me that it would be cool if he could use an image in the form. Which got me to thinking about how you would actually store binary data into a text file... encoding is the answer. </p>
<p>I've written the following two ConvertTo and ConvertFrom functions which you can use to to encode either binary files or byte arrays to a Base64 strings. You can then use them in here strings in your scripts and write them out to binary files again.... Obviously, this does pose a potential moral issue of someone using these to store malicious binary files in the scripts, but I didn't intend the code for that! Honest!</p>
<p>Here's the ConvertTo function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #0000FF;">Function</span> ConvertTo<span style="color: pink;">-</span>EncodedText<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$FilePath</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">Byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ByteArray</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$SaveTo</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Converts Files or Byte Arrays into a Base 64 Encoded String
.Description
Allow you to pass in a file path, or a byte array and it will be encoded into a base 64 string. This can then either be outputted directly or written to a text file.
.Parameter FilePath
Optional: The path to the file you would like to encode
.Parameter ByteArray
Optional: A variable containing a byte array that you would like to encode.
.Parameter SaveTo
Optional: A path of where you would like to save the encoded text file to.
.Example
ConvertTo-EncodedText -FilePath c:\MyBinaryFile.Jpg
&nbsp;
This will return a base 64 encoded string of the file c:\MyBinaryFile.Jpg
.Example
ConvertTo-EncodedText -FilePath c:\MyBinaryFile.Jpg -SaveTo c:\MyEncodedFile.Txt
&nbsp;
This will create a base64 encoded string of c:\MyBinaryFile.Jpg and save it to c:\MyEncodedFile.Txt
.Example
ConvertTo-EncodedText -ByteArray $MyByteArray
&nbsp;
This will create a base 64 encoded string of the ByteArray held in $MyByteArray
.Notes
Name: ConvertTo-EncodedText
Author: Peter Rossi
Last Edited: 19th December 2011
#&gt;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ByteArray</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Data</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ByteArray</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span><span style="color: #008080;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Data</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$FilePath</span> <span style="color: #008080; font-style: italic;">-Encoding</span> Byte
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$SaveTo</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>system.convert<span style="color: #000000;">&#93;</span>::ToBase64String<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Data</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Set-Content</span> <span style="color: #800080;">$SaveTo</span>
		<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$Null</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">Return</span> <span style="color: #000000;">&#91;</span>system.convert<span style="color: #000000;">&#93;</span>::ToBase64String<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Data</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And this is the ConvertFrom function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #0000FF;">Function</span> ConvertFrom<span style="color: pink;">-</span>EncodedText<span style="color: #000000;">&#40;</span><span style="color: #800080;">$InputData</span><span style="color: pink;">,</span><span style="color: #800080;">$FilePath</span><span style="color: pink;">,</span><span style="color: #800080;">$SaveTo</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Converts Files or Base64 Encoded strings into Byte Arrays or binary files
.Description
Allow you to pass in a file path, or a string and it will be encoded into a byte array. This can then either be outputted directly or written to a binary file.
.Parameter InputData
Optional: A variable containing a base64 encoded string
.Parameter FilePath
Optional: The path to the file you would like to decode
.Parameter SaveTo
Optional: A path of where you would like to save the decoded binary file to.
.Example
ConvertFrom-EncodedText -FilePath c:\MyEncodedFile.Txt
&nbsp;
This will return a byte array of the file c:\MyEncodedFile.Txt
.Example
ConvertFrom-EncodedText -FilePath c:\MyEncodedFile.txt -SaveTo c:\MyBinaryFile.Jpg
&nbsp;
This will create a byte array of c:\MyEncodedFile.Jpg and save it to c:\MyBinaryFile.Txt
.Example
ConvertFrom-EncodedText -InputData $MyBase64String
&nbsp;
This will create a byte arry of the base 64 encoded string held in $MyBase64String
.Notes
Name: ConvertFrom-EncodedText
Author: Peter Rossi
Last Edited: 19th December 2011
#&gt;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$InputData</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Data</span> <span style="color: pink;">=</span> <span style="color: #800080;">$InputData</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Data</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$FilePath</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$SaveTo</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>system.convert<span style="color: #000000;">&#93;</span>::FromBase64String<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Data</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Set-Content</span> <span style="color: #800080;">$SaveTo</span> <span style="color: #008080; font-style: italic;">-Encoding</span> Byte
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">Return</span> <span style="color: #000000;">&#91;</span>System.Convert<span style="color: #000000;">&#93;</span>::FromBase64String<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Data</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/embedding-binary-data-in-a-text-file-or-just-saving-binary-data-as-text/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extract Functions, Parameters and Help Info from a Module</title>
		<link>http://www.poshpete.com/powershell/extract-functions-paramters-and-help-info-from-a-module</link>
		<comments>http://www.poshpete.com/powershell/extract-functions-paramters-and-help-info-from-a-module#comments</comments>
		<pubDate>Thu, 15 Dec 2011 08:48:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[extract function]]></category>
		<category><![CDATA[extract help]]></category>
		<category><![CDATA[extract paramter]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=233</guid>
		<description><![CDATA[Morning all! It's been a while since I've written a blog post, mainly due to swapping jobs around and moving house, but now I'm back and keen to get writing again, so here we go. I've been working on various Powershell related projects which involve a central database storage solution for modules so we can [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/extract-functions-paramters-and-help-info-from-a-module"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fextract-functions-paramters-and-help-info-from-a-module"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fextract-functions-paramters-and-help-info-from-a-module&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=extract+function,extract+help,extract+paramter,Powershell" height="61" width="50" /><br />
			</a>
		</div>
<p>Morning all! It's been a while since I've written a blog post, mainly due to swapping jobs around and moving house, but now I'm back and keen to get writing again, so here we go.</p>
<p>I've been working on various Powershell related projects which involve a central database storage solution for modules so we can share them easily internally in the business and use them as part of orchestration tools we've written. One of the things we needed to do was create an XML manifest of all functions in a module, their paramters and types and then (if it existed) the help for each paramter so we could pass it into the toolbox.</p>
<p>The following functions extract the data into nice Powershell objects so you can use them however you like.</p>
<p>The first function is Get-ModuleFunctionsandParams and does what it says on the tin.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>ModuleFunctionsAndParams<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ModuleName</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	Import<span style="color: pink;">-</span>Module <span style="color: #800080;">$ModuleName</span>
	<span style="color: #800080;">$Functions</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Command</span> <span style="color: pink;">-</span>Module <span style="color: #800080;">$ModuleName</span>
	<span style="color: #800080;">$FuncTable</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Func</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Functions</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	                <span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span>Params
			<span style="color: #800080;">$ARow</span>.Name <span style="color: pink;">=</span> <span style="color: #800080;">$Func</span>.Name
			<span style="color: #800080;">$Params</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$PSet</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Func</span>.ParameterSets<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Param</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$PSet</span>.Parameters<span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$BRow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span><span style="color: #008080; font-weight: bold;">Type</span>
					<span style="color: #800080;">$BRow</span>.Name <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Name
					<span style="color: #800080;">$BRow</span>.<span style="color: #008080; font-weight: bold;">Type</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.ParameterType
					<span style="color: #800080;">$Params</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$BRow</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
	        <span style="color: #800080;">$ARow</span>.Params <span style="color: pink;">=</span> <span style="color: #800080;">$Params</span>
		<span style="color: #800080;">$FuncTable</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$ARow</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$FuncTable</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>This is the Get-ParamterHelp function, you pass in the function name and the variable name you're interested in, and away you go....</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>ParameterHelp<span style="color: #000000;">&#40;</span><span style="color: #800080;">$FunctionName</span><span style="color: pink;">,</span><span style="color: #800080;">$VariableName</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$Help</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Help</span> <span style="color: #800080;">$FunctionName</span>
	<span style="color: #800080;">$Table</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Param</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Help</span>.Parameters.Parameter<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$VariableName</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span>Description<span style="color: pink;">,</span>Position<span style="color: pink;">,</span>Required
			<span style="color: #800080;">$ARow</span>.Name <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Name
			<span style="color: #800080;">$ARow</span>.Description <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Description<span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.text
			<span style="color: #800080;">$ARow</span>.Position <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Position
			<span style="color: #800080;">$ARow</span>.Required <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Required
			<span style="color: #800080;">$Table</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$ARow</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">Else</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Param</span>.Name.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.ToLower<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$VariableName</span>.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.ToLower<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span>Description<span style="color: pink;">,</span>Position<span style="color: pink;">,</span>Required
				<span style="color: #800080;">$ARow</span>.Name <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Name
				<span style="color: #800080;">$ARow</span>.Description <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Description<span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.text
				<span style="color: #800080;">$ARow</span>.Position <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Position
				<span style="color: #800080;">$ARow</span>.Required <span style="color: pink;">=</span> <span style="color: #800080;">$Param</span>.Required
				<span style="color: #800080;">$Table</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$ARow</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$Table</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/extract-functions-paramters-and-help-info-from-a-module/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Volume Shadow Copy Information from Powershell</title>
		<link>http://www.poshpete.com/powershell/get-volume-shadow-copy-information-from-powershell</link>
		<comments>http://www.poshpete.com/powershell/get-volume-shadow-copy-information-from-powershell#comments</comments>
		<pubDate>Thu, 26 May 2011 07:28:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[shadow copy]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=228</guid>
		<description><![CDATA[A colleague came and asked me yesterday if it was possible to get Volume Shadow Copy Information from a list of servers..... Powershell to the rescue! The biggest problem that I found is that the data in the WMI class refers to the drive by it's device ID, so I've built in a lookup to [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/get-volume-shadow-copy-information-from-powershell"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fget-volume-shadow-copy-information-from-powershell"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fget-volume-shadow-copy-information-from-powershell&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=Powershell,shadow+copy" height="61" width="50" /><br />
			</a>
		</div>
<p>A colleague came and asked me yesterday if it was possible to get Volume Shadow Copy Information from a list of servers..... Powershell to the rescue!</p>
<p>The biggest problem that I found is that the data in the WMI class refers to the drive by it's device ID, so I've built in a lookup to translate that to a drive letter.</p>
<p>Here's the function I came up with, hope it can help you too.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>ShadowCopyInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Computer</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$UserName</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Password</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #0000FF;">switch</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$MB</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #0000FF;">switch</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PromptForCredentials</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #0000FF;">switch</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$NoCredentials</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Get volume shadow copy information
.Description
Obtains volume shadow copy information for local and remote servers
.Parameter Computer
The name of the computer you wish to run the command against, default is LocalHost
.Parameter UserName
The UserName for any credentials you wish to pass
.Parameter Password
The Password for any credentials you wish to pass
.Parameter MB
Return stats in MB rather than GB
.Parameter PromptForCredentials
This will prompt you to enter credentials for the server, rather than passing in the data in plain text.
.Parameter NoCredentials
Forces the function to not use any credentials.
&nbsp;
.Example
Get-ShadowCopyInfo
&nbsp;
This will return information about the shadow copy data on localhost
.Example
Get-ShadowCopyInfo -Computer ServerA -UserName &quot;MyDomain\MyUser&quot; -Password &quot;MyPassword&quot;
&nbsp;
This will return information about the shadow copy data on ServerA using the supplied credentials
.Example
Get-ShadowCopyInfo -Computer ServerA -PromptForCredentials
&nbsp;
This will return information about the shadow copy data on ServerA, but will prompt you to enter credentials.
.Example
Get-ShadowCopyInfo -Computer ServerA -NoCredentials
&nbsp;
This will return information about the shadow copy data on ServerA using no additional credentials.
.Example
Get-ShadowCopyInfo -MB
&nbsp;
This will return data about the shadow copy volume on your computer, but return the stats in MB rather than GB.
&nbsp;
.Notes
Name: Get-ShadowCopyInfo
Author: Peter Rossi
Last Edited: 26th May 2011
#&gt;</span>
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$UserName</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$Password</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$PromptForCredentials</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$NoCredentials</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$Computer</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Computer</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;LocalHost&quot;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$NoCredentials</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$PromptForCredentials</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$SecPass</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">convertto-securestring</span> <span style="color: #008080; font-style: italic;">-asplaintext</span> <span style="color: #008080; font-style: italic;">-string</span> <span style="color: #800080;">$Password</span> <span style="color: #008080; font-style: italic;">-force</span>
			<span style="color: #800080;">$Creds</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> System.Management.Automation.PSCredential <span style="color: #008080; font-style: italic;">-argumentlist</span> <span style="color: #800080;">$UserName</span><span style="color: pink;">,</span><span style="color: #800080;">$SecPass</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">Else</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$Creds</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Credential</span> 
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$NoCredentials</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$ShadowInfo</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">gwmi</span> <span style="color: #008080; font-style: italic;">-Class</span> win32_shadowstorage <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Computer</span> <span style="color: #008080; font-style: italic;">-Credential</span> <span style="color: #800080;">$Creds</span>
		<span style="color: #800080;">$VolumeInfo</span> <span style="color: pink;">=</span>  <span style="color: #008080; font-weight: bold;">gwmi</span> <span style="color: #008080; font-style: italic;">-Class</span> win32_volume <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Computer</span> <span style="color: #008080; font-style: italic;">-Credential</span> <span style="color: #800080;">$Creds</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$ShadowInfo</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">gwmi</span> <span style="color: #008080; font-style: italic;">-Class</span> win32_shadowstorage <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Computer</span>
		<span style="color: #800080;">$VolumeInfo</span> <span style="color: pink;">=</span>  <span style="color: #008080; font-weight: bold;">gwmi</span> <span style="color: #008080; font-style: italic;">-Class</span> win32_volume <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Computer</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #800080;">$Final</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$ShadowInfo</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">-not</span> <span style="color: #800080;">$MB</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Computer<span style="color: pink;">,</span>Drive<span style="color: pink;">,</span>SizeGB<span style="color: pink;">,</span>ShadowMaxSizeGB<span style="color: pink;">,</span>ShadowUsedSizeGB<span style="color: pink;">,</span>ShadowPercent<span style="color: pink;">,</span>TimeChecked
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">Else</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Computer<span style="color: pink;">,</span>Drive<span style="color: pink;">,</span>SizeMB<span style="color: pink;">,</span>ShadowMaxSizeMB<span style="color: pink;">,</span>ShadowUsedSizeMB<span style="color: pink;">,</span>ShadowPercent<span style="color: pink;">,</span>TimeChecked
		<span style="color: #000000;">&#125;</span>
		<span style="color: #800080;">$ARow</span>.Computer <span style="color: pink;">=</span> <span style="color: #800080;">$Computer</span>
		<span style="color: #800080;">$ARow</span>.TimeChecked <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span>
&nbsp;
		<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Vol</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$VolumeInfo</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span>.Volume <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;*$($Vol.DeviceId.trimstart(&quot;</span>\\<span style="color: pink;">?</span>\Volume<span style="color: #800000;">&quot;).trimend(&quot;</span>\<span style="color: #800000;">&quot;))*&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$ARow</span>.Drive <span style="color: pink;">=</span> <span style="color: #800080;">$Vol</span>.Name
				<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$MB</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$ARow</span>.SizeMB <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:N2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Vol</span>.Capacity<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$ARow</span>.ShadowMaxSizeMB <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:N2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span>.MaxSpace<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$ARow</span>.ShadowUsedSizeMB <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:N2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span>.UsedSpace<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0000FF;">Else</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$ARow</span>.SizeGB <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:N2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Vol</span>.Capacity<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$ARow</span>.ShadowMaxSizeGB <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:N2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span>.MaxSpace<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: #000000;">&#41;</span>
					<span style="color: #800080;">$ARow</span>.ShadowUsedSizeGB <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:N2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span>.UsedSpace<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #800080;">$Percent</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$Shadow</span>.MaxSpace<span style="color: pink;">/</span><span style="color: #800080;">$Vol</span>.Capacity<span style="color: #000000;">&#41;</span> <span style="color: pink;">*</span> <span style="color: #804000;">100</span>
				<span style="color: #800080;">$ARow</span>.ShadowPercent <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Percent</span>
&nbsp;
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #800080;">$Final</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$ARow</span>
&nbsp;
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$Final</span>
&nbsp;
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/get-volume-shadow-copy-information-from-powershell/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IT Process Automation (ITPA) &#8211; How I See It</title>
		<link>http://www.poshpete.com/powershell/it-process-automation-itpa-how-i-see-it</link>
		<comments>http://www.poshpete.com/powershell/it-process-automation-itpa-how-i-see-it#comments</comments>
		<pubDate>Tue, 24 May 2011 18:07:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[aegis]]></category>
		<category><![CDATA[cep]]></category>
		<category><![CDATA[complex event processing]]></category>
		<category><![CDATA[itpa]]></category>
		<category><![CDATA[process automation]]></category>
		<category><![CDATA[stream insight]]></category>
		<category><![CDATA[streambase]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=217</guid>
		<description><![CDATA[I thought for this blog, I'd write something slightly different rather than just the usual Powershell piece. I have been working in the IT Process Automation (ITPA) arena for around 2 years now. It's a fascinating industry that's starting to emerge, and as more and more large IT companies realise it's potential, the core concept [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/it-process-automation-itpa-how-i-see-it"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fit-process-automation-itpa-how-i-see-it"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fit-process-automation-itpa-how-i-see-it&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=aegis,cep,complex+event+processing,itpa,Powershell,process+automation,stream+insight,streambase" height="61" width="50" /><br />
			</a>
		</div>
<p>I thought for this blog, I'd write something slightly different rather than just the usual Powershell piece.</p>
<p>I have been working in the IT Process Automation (ITPA) arena for around 2 years now. It's a fascinating industry that's starting to emerge, and as more and more large IT companies realise it's potential, the core concept is really starting to take hold. </p>
<p>The main idea behind it is automating processes which are generally highly repetitive, quite often long winded and are prone to user errors. Although, this does pose a large block in front of any manager when your staff ask: "But doesn't this mean we'll be out of a job?". It's the largest problem I've faced when trying to get various processes rolled out. Personally, I feel that by removing these time wasting tasks, the staff that you already have will have more time to work on interesting projects and further their skill sets and thus career. This is still a tough sell....</p>
<p>The main product that I have worked with from an workflow perspective is NetIQ Aegis, but I've also seen Symantecs Altiris workflow product and Microsoft's Opalis. These are great products, although, with one flaw. The way they are marketed is such that "Any business process owner can put together a workflow". Incorrect. I'd really like to see a business manager attempt to throw together a technical workflow without any prior IT experience. To deliver this ease, the approach tends to be to abstract the code from the user, and present them with thousands of buttons and options to click. The reality is that most users who will design workflows are going to be either DevOps or a developer. Both of which would much rather have keyboard access straight into editing variables etc. SQL SSIS seems to have gone slightly the other way with this, but I think I'd prefer that approach.</p>
<p>You may ask, <strong>"Well, if you want to just start typing out scripts, then why do you bother with workflow in the first place?"</strong>. Well, workflow has a great deal to offer. It allows for a very robust process to be put together which in most cases can be easily watched, tracked and reported upon. This alone is worth a lot to most businesses.</p>
<p>The biggest topic next to workflow, is <strong>"How do you initiate workflow?"</strong></p>
<p>The way most workflow products out there seem to work, relys on a manual button press from someone. Whether that's triggered through the built in UI, or via an API call or a database trigger from an 3rd party app, who knows. This is great if you want to load up your service desk with a thousand potential buttons to press in the event of something happening, but in most cases, that's not the best move....</p>
<p><strong>Complex Event Processing (CEP)</strong> - This is the area where it's all moving to, and it's one of the key reasons why I've been working with NetIQ Aegis for the past 2 years. Aegis cleverly combines the StreamBase CEP engine, which allows you to watch for patterns in all of your data streams <strong>"while it is in flight"</strong>, simultaneously. Therefore, you can configure a custom trigger to watch for something like:</p>
<p>In any 5 minute window<br />
If you see a ping timeout from a server in data centre 1<br />
AND you see a URL timeout for a domain in this group<br />
AND you see a disk capacity warning for one of these servers</p>
<p>Trigger something.....</p>
<p>You can then have a workflow which specifically caters for that scenario. No users needed, it just gets on with it.</p>
<p>Unfortunately, there are a few occasions where you might want your workflow engine not to react i.e. during a planned maintenance window or during a major incident. The trick to this is designing your architecture so you can restrict the flow of data into your CEP engine at the right times, therefore, creating some form of data flow controller in front of it.... pie in the sky stuff though.</p>
<p>Either way, CEP is fantastic. Annoyingly, it's really marketed in the financial sector due to the fact it can watch for stock trade patterns etc and allow traders to make choices quickly. However, as you can see, there are some fantastic uses for it in a data centre environment.</p>
<p><strong>So, what's the best of both worlds?</strong></p>
<p>Well, as I mentioned above, I've been using NetIQ Aegis, and it was the product we picked for a lot of reasons, but mainly because of the CEP engine integration. The downside is that the StreamBase engine is wrapped by the product and you therefore don't get a huge amount of access to how it actually works, which can be quite frustrating sometimes... although, I know it's a Java based product and it's not overly easy to integrate with .net, so I'm not too worried.</p>
<p>As you all know, I'm a massive Powershell advocate and believe that there are boundless time savings to be had from it in large IT enterprises. However, imagine Powershell bolted to a decent CEP? Powershell that ran automatically when it knew something needed to be done.....</p>
<p>You can sort of do this with Aegis, but I'd like a much closer to the metal approach, and believe that this could easily be delivered by Microsofts new StreamInsight product. </p>
<p>StreamInsight is Microsofts new CEP engine, and it ships as part of SQL 2008 R2, although it's not actually a server product. If you get a license for it, you will receive 10 or 12 dll's which you can import into a .net c# project and build your own engine. You can connect to as many different data streams as you like, process them how you wish and then fire them off to any system you deem fit to deal with them all in real time. If you had a service which fired off Powershell at the end, then you'd be done.....</p>
<p>I'd love to see a product like this to come on the market, but I think we're a bit of a way off, so I'm currently working on my own.</p>
<p>If you're interested in looking at Stream Insight or CEP in general, Alan Mitchell did a great session on StreamInsight at SQLBits in 2010 and 2011, you can see his deep dive video <a href="http://sqlbits.com/Sessions/Event7/StreamInsight_Deep_Dive">here</a>.</p>
<p>Hope you found this post interesting, and give me a shout if you're interested in process automation or CEP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/it-process-automation-itpa-how-i-see-it/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get and Set &#8211; Active Directory User Thumbnail Photos</title>
		<link>http://www.poshpete.com/uncategorized/get-and-set-active-directory-user-thumbnail-photos</link>
		<comments>http://www.poshpete.com/uncategorized/get-and-set-active-directory-user-thumbnail-photos#comments</comments>
		<pubDate>Fri, 13 May 2011 11:27:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[thumbnailphoto]]></category>
		<category><![CDATA[user photo]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=210</guid>
		<description><![CDATA[I was just asked how you can update the user thumbnail images in active directory (the ones that appear in outlook when you select a user etc). So I did some digging. Basically, thumbnailPhoto is a property of an AD user which stores an array of bytes. So I've put together the following functions to [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/uncategorized/get-and-set-active-directory-user-thumbnail-photos"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Funcategorized%2Fget-and-set-active-directory-user-thumbnail-photos"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Funcategorized%2Fget-and-set-active-directory-user-thumbnail-photos&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=active+directory,Powershell,thumbnailphoto,user+photo" height="61" width="50" /><br />
			</a>
		</div>
<p>I was just asked how you can update the user thumbnail images in active directory (the ones that appear in outlook when you select a user etc). So I did some digging.</p>
<p>Basically, thumbnailPhoto is a property of an AD user which stores an array of bytes. So I've put together the following functions to allow you to easily get or set the images for a user:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>ADThumbnailPhoto<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Get Active Directory user thumbnail image
.Description
Extracts the current user thumbnail image from active directory
.Parameter UserName
The username of the person you're looking for
.Parameter Path
The path for the file you would like to output to, i.e. c:\test.jpg
.Example
Get-ADThumbnailPhoto -UserName PeterRossi -Path c:\PeterRossi.JPG
&nbsp;
This will extract the thumbnail image for user PeterRossi and export it to c:\PeterRossi.jpg
.Notes
Name: Get-ADThumbnailPhoto
Author: Peter Rossi
Last Edited: 13th May 2011
#&gt;</span>
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span>
        <span style="color: #000000;">&#91;</span>Parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$True</span><span style="color: pink;">,</span> Position<span style="color: pink;">=</span><span style="color: #804000;">0</span><span style="color: pink;">,</span> ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$UserName</span><span style="color: pink;">,</span>
		<span style="color: #000000;">&#91;</span>Parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$True</span><span style="color: pink;">,</span> ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Path</span>
	<span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$ADSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> DirectoryServices.DirectorySearcher<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(&amp;(SAMAccountName=$UserName))&quot;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$Users</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ADSearcher</span>.FindOne<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Users</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>adsi<span style="color: #000000;">&#93;</span><span style="color: #800080;">$TheUser</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$($Users.Path)&quot;</span>
		<span style="color: #800080;">$Thumbnail</span> <span style="color: pink;">=</span> <span style="color: #800080;">$TheUser</span>.ThumbnailPhoto.Value
		<span style="color: #000000;">&#91;</span>System.IO.File<span style="color: #000000;">&#93;</span>::WriteAllBytes<span style="color: #000000;">&#40;</span><span style="color: #800080;">$Path</span><span style="color: pink;">,</span><span style="color: #800080;">$Thumbnail</span><span style="color: #000000;">&#41;</span>	
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;User $UserName could not be found in AD, is it the right username?&quot;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Set<span style="color: pink;">-</span>ADThumbnailPhoto<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Set Active Directory user thumbnail image
.Description
Sets the current user thumbnail image from active directory
.Parameter UserName
The username of the person you're looking for
.Parameter JPGPath
The path for the file you would like to use as the new thumbnail
.Example
Set-ADThumbnailPhoto -UserName PeterRossi -JPGPath c:\PeterRossi.JPG
&nbsp;
This will set the thumbnail image for user PeterRossi using c:\PeterRossi.jpg
.Notes
Name: Set-ADThumbnailPhoto
Author: Peter Rossi
Last Edited: 13th May 2011
#&gt;</span>
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span>
        <span style="color: #000000;">&#91;</span>Parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$True</span><span style="color: pink;">,</span> Position<span style="color: pink;">=</span><span style="color: #804000;">0</span><span style="color: pink;">,</span> ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$UserName</span><span style="color: pink;">,</span>
		<span style="color: #000000;">&#91;</span>Parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$True</span><span style="color: pink;">,</span> ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#91;</span>String<span style="color: #000000;">&#93;</span><span style="color: #800080;">$JPGPath</span>
	<span style="color: #000000;">&#41;</span>
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #800080;">$JPGPath</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>byte<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Thumbnail</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$JPGPath</span> <span style="color: #008080; font-style: italic;">-encoding</span> byte
&nbsp;
		<span style="color: #800080;">$ADSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> DirectoryServices.DirectorySearcher<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(&amp;(SAMAccountName=$UserName))&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #800080;">$UserSearch</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ADSearcher</span>.FindOne<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$UserSearch</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$User</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>ADSI<span style="color: #000000;">&#93;</span><span style="color: #800000;">&quot;$($UserSearch.Path)&quot;</span>
 			<span style="color: #800080;">$User</span>.put<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;thumbnailPhoto&quot;</span><span style="color: pink;">,</span>  <span style="color: #800080;">$Thumbnail</span> <span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$User</span>.setinfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">Else</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;User $UserName could not be found in AD, is it the right username?&quot;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;Can't find $JPGPath, does it exist?&quot;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/uncategorized/get-and-set-active-directory-user-thumbnail-photos/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating a Throttle for Background Tasks Without Rewriting Your Code &#8211; V2</title>
		<link>http://www.poshpete.com/powershell/creating-a-throttle-for-background-tasks-without-rewriting-your-code-v2</link>
		<comments>http://www.poshpete.com/powershell/creating-a-throttle-for-background-tasks-without-rewriting-your-code-v2#comments</comments>
		<pubDate>Fri, 06 May 2011 07:16:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[invoke-command]]></category>
		<category><![CDATA[start-job]]></category>
		<category><![CDATA[throttle]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=167</guid>
		<description><![CDATA[A while ago I posted some code which allows you to add a function called Threshold to your script to throttle the number of background tasks a loop can run at any one time. The idea behind this was that if you are looping through a dataset and spawning a thread for each item, you [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/creating-a-throttle-for-background-tasks-without-rewriting-your-code-v2"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fcreating-a-throttle-for-background-tasks-without-rewriting-your-code-v2"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fcreating-a-throttle-for-background-tasks-without-rewriting-your-code-v2&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=background,invoke-command,start-job,throttle" height="61" width="50" /><br />
			</a>
		</div>
<p>A while ago I posted some code which allows you to add a function called Threshold to your script to throttle the number of background tasks a loop can run at any one time.</p>
<p>The idea behind this was that if you are looping through a dataset and spawning a thread for each item, you may well run out of memory or hit some sort of other limit which might break your script, or return incorrect data.</p>
<p>This function allows you have the best of both worlds: The consistency of serial running, with the benefits of background tasks.</p>
<p><strong>NOTE </strong>- If you're using Invoke-Command you can always use the -ThrottleLimit switch, although, this only works if you are passing in a parameter which contains a list of computers to run against.</p>
<p>In your loop, before you call a "Start-Job" or an "Invoke-Command" all you need to add is:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Limit<span style="color: pink;">-</span>Jobs <span style="color: pink;">-</span>MaxConcurrent <span style="color: #804000;">10</span> <span style="color: pink;">-</span>PauseTime <span style="color: #804000;">10</span></pre></div></div>

<p>This will call out to the Limit-Jobs function, which will:</p>
<p>- Check the number of currently running background jobs<br />
- If the amount of currently running jobs is greater than or equal to the parameter passed in for MaxConcurrent it will wait for the number of seconds passed in under PauseTime. It will then check again.<br />
- If the amount of currently running jobs is less than the parmeter passed into MaxConcurrent it will allow your script to continue.</p>
<p>Therefore, the above command will allow 10 concurrent jobs to run at a time and add a pause of 10 seconds in before checking again.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #0000FF;">Function</span> Limit<span style="color: pink;">-</span>Jobs <span style="color: #000000;">&#123;</span>    		
&nbsp;
	<span style="color: #0000FF;">Param</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$MaxConcurrent</span><span style="color: pink;">,</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$PauseTime</span><span style="color: #000000;">&#41;</span>     	
	<span style="color: #800080;">$jobs</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>job <span style="color: pink;">-</span>state running <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span><span style="color: #000000;">&#41;</span>.count      
	<span style="color: #800080;">$RunningJobs</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>       		
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$jobs</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>	<span style="color: #000000;">&#123;</span><span style="color: #800080;">$RunningJobs</span> <span style="color: pink;">=</span> <span style="color: #800080;">$jobs</span><span style="color: #000000;">&#125;</span>     	
	<span style="color: #0000FF;">while</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$RunningJobs</span> <span style="color: #FF0000;">-ge</span> <span style="color: #800080;">$MaxConcurrent</span><span style="color: #000000;">&#41;</span>	
	<span style="color: #000000;">&#123;</span>		
		<span style="color: #800080;">$jobs</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>job <span style="color: pink;">-</span>state running <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span><span style="color: #000000;">&#41;</span>.count      
		<span style="color: #800080;">$RunningJobs</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>       			
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$jobs</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$RunningJobs</span> <span style="color: pink;">=</span> <span style="color: #800080;">$jobs</span> 
		<span style="color: #000000;">&#125;</span>   
&nbsp;
		<span style="color: #008080; font-weight: bold;">Write-Warning</span> <span style="color: #800000;">&quot;Current Running Jobs: $RunningJobs&quot;</span> 
		<span style="color: #008080; font-weight: bold;">start-sleep</span> <span style="color: #008080; font-style: italic;">-seconds</span>  <span style="color: #800080;">$PauseTime</span> 		
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/creating-a-throttle-for-background-tasks-without-rewriting-your-code-v2/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Controlling Media Playback from Powershell</title>
		<link>http://www.poshpete.com/powershell/controlling-media-playback-from-powershell</link>
		<comments>http://www.poshpete.com/powershell/controlling-media-playback-from-powershell#comments</comments>
		<pubDate>Wed, 04 May 2011 10:36:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[next track]]></category>
		<category><![CDATA[pause track]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=161</guid>
		<description><![CDATA[Ever wanted to control your media playback from Powershell? Now you can send Play, Pause, Next, Previous and Stop commands directly to any media player you have open without leaving the powershell shell Feel free to chop and change the function names around. I wasn't feeling overly creative when I came up with them. $SendKeyClass [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/controlling-media-playback-from-powershell"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fcontrolling-media-playback-from-powershell"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fcontrolling-media-playback-from-powershell&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=control,media,next+track,pause+track,Powershell" height="61" width="50" /><br />
			</a>
		</div>
<p>Ever wanted to control your media playback from Powershell?</p>
<p>Now you can send Play, Pause, Next, Previous and Stop commands directly to any media player you have open without leaving the powershell shell <img src='http://www.poshpete.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Feel free to chop and change the function names around. I wasn't feeling overly creative when I came up with them.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$SendKeyClass</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #800000;">&quot;
&nbsp;
       [DllImport(&quot;</span>user32.dll<span style="color: #800000;">&quot;)]
        private static extern int keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
&nbsp;
        public static void SendKey(Keys key)
        {
            keybd_event((byte)key, 0, 0, 0);
        }
&nbsp;
&nbsp;
&quot;</span><span style="color: pink;">@</span>
&nbsp;
<span style="color: #0000FF;">function</span> Set<span style="color: pink;">-</span>PlayPausetrack
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$app</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$app</span> <span style="color: pink;">=</span> Add<span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">Type</span> <span style="color: pink;">-</span>MemberDefinition <span style="color: #800080;">$SendKeyClass</span> <span style="color: #008080; font-style: italic;">-Name</span> Win32Window <span style="color: #008080; font-style: italic;">-Namespace</span> PoshPete.WinAPI <span style="color: pink;">-</span>ReferencedAssemblies System.Windows.Forms <span style="color: pink;">-</span>Using System.Windows.Forms <span style="color: #008080; font-style: italic;">-PassThru</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #800080;">$app</span>::SendKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.Windows.Forms.Keys<span style="color: #000000;">&#93;</span>::MediaPlayPause<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">function</span> Set<span style="color: pink;">-</span>StopTrack
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$app</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$app</span> <span style="color: pink;">=</span> Add<span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">Type</span> <span style="color: pink;">-</span>MemberDefinition <span style="color: #800080;">$SendKeyClass</span> <span style="color: #008080; font-style: italic;">-Name</span> Win32Window <span style="color: #008080; font-style: italic;">-Namespace</span> PoshPete.WinAPI <span style="color: pink;">-</span>ReferencedAssemblies System.Windows.Forms <span style="color: pink;">-</span>Using System.Windows.Forms <span style="color: #008080; font-style: italic;">-PassThru</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #800080;">$app</span>::SendKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.Windows.Forms.Keys<span style="color: #000000;">&#93;</span>::MediaStop<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">function</span> Set<span style="color: pink;">-</span>NextTrack
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$app</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$app</span> <span style="color: pink;">=</span> Add<span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">Type</span> <span style="color: pink;">-</span>MemberDefinition <span style="color: #800080;">$SendKeyClass</span> <span style="color: #008080; font-style: italic;">-Name</span> Win32Window <span style="color: #008080; font-style: italic;">-Namespace</span> PoshPete.WinAPI <span style="color: pink;">-</span>ReferencedAssemblies System.Windows.Forms <span style="color: pink;">-</span>Using System.Windows.Forms <span style="color: #008080; font-style: italic;">-PassThru</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #800080;">$app</span>::SendKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.Windows.Forms.Keys<span style="color: #000000;">&#93;</span>::MediaNextTrack<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">function</span> Set<span style="color: pink;">-</span>PreviousTrack
<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$app</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$app</span> <span style="color: pink;">=</span> Add<span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">Type</span> <span style="color: pink;">-</span>MemberDefinition <span style="color: #800080;">$SendKeyClass</span> <span style="color: #008080; font-style: italic;">-Name</span> Win32Window <span style="color: #008080; font-style: italic;">-Namespace</span> PoshPete.WinAPI <span style="color: pink;">-</span>ReferencedAssemblies System.Windows.Forms <span style="color: pink;">-</span>Using System.Windows.Forms <span style="color: #008080; font-style: italic;">-PassThru</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #800080;">$app</span>::SendKey<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.Windows.Forms.Keys<span style="color: #000000;">&#93;</span>::MediaPreviousTrack<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/controlling-media-playback-from-powershell/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Object Property Expansion in Strings</title>
		<link>http://www.poshpete.com/powershell/object-property-expansion-in-strings</link>
		<comments>http://www.poshpete.com/powershell/object-property-expansion-in-strings#comments</comments>
		<pubDate>Thu, 07 Apr 2011 20:22:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[string expansion]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=152</guid>
		<description><![CDATA[Just a quick on really. Ever had a problem where you had a property of an object that was a string that you wanted to use in another string? For example, if you had a variable that looked like this: $Name = &#34;Posh Pete&#34; You could expand that really easily in another string: write-host &#34;Hi, [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/powershell/object-property-expansion-in-strings"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fobject-property-expansion-in-strings"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Fpowershell%2Fobject-property-expansion-in-strings&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly&amp;hashtags=Powershell,string+expansion" height="61" width="50" /><br />
			</a>
		</div>
<p>Just a quick on really. Ever had a problem where you had a property of an object that was a string that you wanted to use in another string?</p>
<p>For example, if you had a variable that looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$Name</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Posh Pete&quot;</span></pre></div></div>

<p>You could expand that really easily in another string:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;Hi, my name is $Name&quot;</span></pre></div></div>

<p>Which returns "Hi, my name is Posh Pete" which is great.</p>
<p>However, say you had an object that had 2 properties, "FirstName" and "LastName"</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#Quick and dirty object creation</span>
<span style="color: #800080;">$NameObject</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> FirstName<span style="color: pink;">,</span>LastName
<span style="color: #800080;">$NameObject</span>.FirstName <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Posh&quot;</span>
<span style="color: #800080;">$NameObject</span>.LastName <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Pete&quot;</span></pre></div></div>

<p>Now, say you wanted to do what we did before:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;Hi, my name is $NameObject.FirstName $NameObject.LastName&quot;</span></pre></div></div>

<p>You get a rather nasty looking response:</p>
<p>Hi, my name is @{FirstName=Posh; LastName=Pete}.FirstName @{FirstName=Posh; LastName=Pete}.LastName</p>
<p>Eeeeek!</p>
<p>So, to get around this, all you need to do is wrap your expressions in a $(), so it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">write-host</span> <span style="color: #800000;">&quot;Hi, my name is $($NameObject.FirstName) $($NameObject.LastName)&quot;</span></pre></div></div>

<p>Job done <img src='http://www.poshpete.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/powershell/object-property-expansion-in-strings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don Jones Powershell Challenge &#8211; My Answers</title>
		<link>http://www.poshpete.com/uncategorized/don-jones-powershell-challenge-my-answers</link>
		<comments>http://www.poshpete.com/uncategorized/don-jones-powershell-challenge-my-answers#comments</comments>
		<pubDate>Wed, 09 Mar 2011 17:38:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.poshpete.com/?p=145</guid>
		<description><![CDATA[This is my response to Don Jones Powershell Challenge posted on 9th March 2011. The challenge can be found here &#160; #Problem 1 &#160; Function Change-DataServerPassword&#40;&#41; &#123; &#60;# .Synopsis Change the password for the service account on servers in a given OU .Description Changes the password used for a service on all computers in a [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="tall" count="1" href="http://www.poshpete.com/uncategorized/don-jones-powershell-challenge-my-answers"></g:plusone></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.poshpete.com%2Funcategorized%2Fdon-jones-powershell-challenge-my-answers"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.poshpete.com%2Funcategorized%2Fdon-jones-powershell-challenge-my-answers&amp;source=RossiPete&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>This is my response to Don Jones Powershell Challenge posted on 9th March 2011.</p>
<p>The challenge can be found <a href="http://www.windowsitpro.com/blogs/PowerShellwithaPurpose/tabid/2248/entryid/76222/A-PowerShell-Challenge-win-a-free-book.aspx">here</a></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">&nbsp;
<span style="color: #008000;">#Problem 1</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Change<span style="color: pink;">-</span>DataServerPassword<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;">&lt;#
.Synopsis
Change the password for the service account on servers in a given OU
.Description
Changes the password used for a service on all computers in a given OU. By default this is the Database Servers OU, and the DataServer service.
.Parameter OUName
The name of the OU where the servers exist
.Parameter ServiceName
The name of the service you want to target
.Parameter UserName
The username for the account you want to use for the service (optional)
.Parameter Password
The password you want to set the service account to.
.Example
Change-DataServerPassword -Password MyNewPassword
&nbsp;
This will set the DataServer account password on all servers in the Database Servers OU.
.Example
Change-DataServerPassword -OUName AnotherOU -Password MyNewPassword
&nbsp;
This will set the DataServer account password on all servers in the AnotherOU OU.
.Example
Change-DataServerPassword -OUName AnotherOU -ServiceName AnotherService -Password MyNewPassword
&nbsp;
This will set the AnotherService account password on all servers in the AnotherOU OU.
.Example
Change-DataServerPassword -OUName AnotherOU -ServiceName AnotherService -UserName AnotherUserName -Password MyNewPassword
&nbsp;
This will set the AnotherService account password for the AnotherUserName account on all servers in the AnotherOU OU.
.Notes
Name: Change-DataServerPassword
Author: Peter Rossi
Last Edited: 9th March 2011
#&gt;</span>
	<span style="color: #0000FF;">Param</span>
          <span style="color: #000000;">&#40;</span>
            <span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$OUName</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;Database Servers&quot;</span><span style="color: pink;">,</span>
			<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ServiceName</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;DataServer&quot;</span><span style="color: pink;">,</span>
			<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$false</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$UserName</span><span style="color: pink;">,</span>
			<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>String<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$Password</span>
          <span style="color: #000000;">&#41;</span> 
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #800080;">$ADSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> DirectoryServices.DirectorySearcher<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(&amp;(objectClass=organizationalUnit)(ou=$OUName))&quot;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$OUs</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ADSearcher</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #008000;">#Assuming there is only one of these OU's</span>
	<span style="color: #800080;">$ThisOU</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>ADSI<span style="color: #000000;">&#93;</span><span style="color: #800080;">$OUs</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.Path
	<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Child</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$ThisOU</span>.psbase.children<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Child</span>.ObjectCategory <span style="color: #FF0000;">-like</span> <span style="color: #800000;">'*computer*'</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$svc</span><span style="color: pink;">=</span><span style="color: #008080; font-weight: bold;">gwmi</span> win32_service <span style="color: pink;">-</span><span style="color: #0000FF;">filter</span> <span style="color: #800000;">&quot;name='$ServiceName'&quot;</span> <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Child</span>.Name
			<span style="color: #800080;">$inParams</span> <span style="color: pink;">=</span> <span style="color: #800080;">$svc</span>.psbase.getMethodParameters<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Change&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$inParams</span><span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;StartName&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">=</span> <span style="color: #800080;">$UserName</span>
			<span style="color: #800080;">$inParams</span><span style="color: #000000;">&#91;</span><span style="color: #800000;">&quot;StartPassword&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Password</span>
			<span style="color: #800080;">$svc</span>.invokeMethod<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Change&quot;</span><span style="color: pink;">,</span><span style="color: #800080;">$inParams</span><span style="color: pink;">,</span><span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #800080;">$Message</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Changing Passowrd for $ServiceName on &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$Child</span>.Name
			<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$Message</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;">#Problem 2</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>DiskInventory<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Returns a report of all logical drives in a given list of servers where their disk space is below the threshold set by DiskSpaceRemaining
.Description
Queries a list of remote servers to return a disk space report for their logical drives.
.Parameter ServerListFile
The path to the text file with server names
.Parameter DiskSpaceRemainingGB
The amount of disk space remaining that you are concerned about.
.Example
Get-DiskInventory -ServerListFile c:\servers.txt
&nbsp;
This will return a report of all logical drives for the servers listed in c:\servers.txt
.Example
Get-DiskInventory -ServerListFile c:\servers.txt -DiskSpaceRemainingGB 10
&nbsp;
This will return a report of all logical drives for the servers listed in c:\servers.txt where there is less than 10GB remaining.
&nbsp;
.Notes
Name: Get-DiskInventory
Author: Peter Rossi
Last Edited: 9th March 2011
#&gt;</span>
<span style="color: #0000FF;">Param</span>
<span style="color: #000000;">&#40;</span>
	<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ServerListFile</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>Int<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$DiskSpaceRemainingGB</span><span style="color: pink;">=</span><span style="color: #804000;">20</span>
<span style="color: #000000;">&#41;</span> 
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #800080;">$ServerListFile</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;The Server List File Doesn't Exist&quot;</span>
	<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$null</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">Else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$DiskSpaceInKB</span> <span style="color: pink;">=</span> <span style="color: #800080;">$DiskSpaceRemainingGB</span> <span style="color: pink;">*</span> <span style="color: #804000;">1024</span> <span style="color: pink;">*</span> <span style="color: #804000;">1024</span>
	<span style="color: #800080;">$Servers</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Content</span> <span style="color: #800080;">$ServerListFile</span>
	<span style="color: #800080;">$FinalData</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Server</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Servers</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$Disks</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">gwmi</span> win32_logicaldisk <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: #800000;">&quot;DriveType=3 and FreeSpace &lt;= $DiskSpaceInKB&quot;</span>
		<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Disk</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Disks</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Server<span style="color: pink;">,</span>DriveLetter<span style="color: pink;">,</span>FreeSpaceGB<span style="color: pink;">,</span>TotalSizeGB<span style="color: pink;">,</span>PercentFreeSpace
			<span style="color: #800080;">$ARow</span>.Server <span style="color: pink;">=</span> <span style="color: #800080;">$Server</span>
			<span style="color: #800080;">$ARow</span>.DriveLetter <span style="color: pink;">=</span> <span style="color: #800080;">$Disk</span>.DeviceID
			<span style="color: #800080;">$ARow</span>.FreeSpaceGB <span style="color: pink;">=</span> <span style="color: #800080;">$Disk</span>.FreeSpace<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span>
			<span style="color: #800080;">$ARow</span>.TotalSizeGB <span style="color: pink;">=</span> <span style="color: #800080;">$Disk</span>.Size<span style="color: pink;">/</span><span style="color: #804000;">1024</span><span style="color: pink;">/</span><span style="color: #804000;">1024</span>
			<span style="color: #800080;">$ARow</span>.PercentFreeSpace <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Disk</span>.FreeSpace<span style="color: pink;">/</span><span style="color: #800080;">$Disk</span>.Size<span style="color: #000000;">&#41;</span><span style="color: pink;">*</span><span style="color: #804000;">100</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$FinalData</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$ARow</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$FinalData</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;">#Problem 3</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Get<span style="color: pink;">-</span>ADComputerInfo
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Returns a report of all computers in AD
.Description
Queries AD for all computers and returns their Windows Version, Service Pack Version and BIOS serial number
.Parameter WindowsVersion
The windows version you want to filter by (optional)
.Parameter ServicePackVersion
The Service Pack Version you want to filter by (optional)
.Example
Get-ADComputerInfo
&nbsp;
This will return a report of all servers in AD
&nbsp;
.Notes
Name: Get-ADComputerInfo
Author: Peter Rossi
Last Edited: 9th March 2011
#&gt;</span>
	<span style="color: #0000FF;">Param</span>
	<span style="color: #000000;">&#40;</span>
		<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$WindowsVersion</span><span style="color: pink;">,</span>
		<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>String<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ServicePackVersion</span>
	<span style="color: #000000;">&#41;</span> 
&nbsp;
	<span style="color: #800080;">$ADSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> DirectoryServices.DirectorySearcher<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(&amp;(objectClass=computer))&quot;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$Servers</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ADSearcher</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$FinalTable</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ServerObj</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$Servers</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #800080;">$Server</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>ADSI<span style="color: #000000;">&#93;</span><span style="color: #800080;">$ServerObj</span>.Path
		<span style="color: #800080;">$ARow</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Server<span style="color: pink;">,</span>WindowsVersionNumber<span style="color: pink;">,</span>BIOSSerial<span style="color: pink;">,</span>ServicePackVersion
		<span style="color: #800080;">$BiosInfo</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">gwmi</span> win32_bios <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$Server</span>.Name
		<span style="color: #800080;">$ARow</span>.WindowsVersionNumber <span style="color: pink;">=</span> <span style="color: #800080;">$Server</span>.operatingSystemVersion
		<span style="color: #800080;">$ARow</span>.BIOSSerial <span style="color: pink;">=</span> <span style="color: #800080;">$BiosInfo</span>.SerialNumber
		<span style="color: #800080;">$ARow</span>.ServicePackVersion <span style="color: pink;">=</span> <span style="color: #800080;">$Server</span>.operatingSystemServicePack
&nbsp;
		<span style="color: #800080;">$OkToAdd</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
&nbsp;
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$WindowsVersion</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ARow</span>.WindowsVersionNumber <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$WindowsVersion</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$OkToAdd</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0000FF;">Else</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$OkToAdd</span> <span style="color: pink;">=</span> <span style="color: #800080;">$False</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0000FF;">If</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ServicePackVersion</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ARow</span>.ServicePackVersion <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$ServicePackVersion</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$OkToAdd</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0000FF;">Else</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$OkToAdd</span> <span style="color: pink;">=</span> <span style="color: #800080;">$False</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$OkToAdd</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$FinalTable</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$ARow</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #0000FF;">Return</span> <span style="color: #800080;">$FinalTable</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;">#Problem 4</span>
&nbsp;
<span style="color: #0000FF;">Function</span> Add<span style="color: pink;">-</span>Users<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #008000;">&lt;#
.Synopsis
Creates AD users for all users in a given CSV and adds the to the Employees group
.Description
Takes a CSV file of new users, creates them in AD and adds them to the Employees group.
.Parameter ImportCSV
The path to the CSV file with the users
.Example
Add-Users -ImportCSV c:\Users.csv
&nbsp;
This will import all users in c:\users.csv into AD
&nbsp;
.Notes
Name: Add-Users
Author: Peter Rossi
Last Edited: 9th March 2011
#&gt;</span>
<span style="color: #0000FF;">Param</span>
	<span style="color: #000000;">&#40;</span>
		<span style="color: #000000;">&#91;</span>parameter<span style="color: #000000;">&#40;</span>Mandatory<span style="color: pink;">=</span><span style="color: #800080;">$True</span><span style="color: pink;">,</span>ValueFromPipeline<span style="color: pink;">=</span><span style="color: #800080;">$False</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ImportCSV</span>
	<span style="color: #000000;">&#41;</span> 
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #800080;">$ImportCSV</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$false</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;The file $ImportCSV doesn't exist&quot;</span>
		<span style="color: #0000FF;">return</span> <span style="color: #800080;">$null</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">Else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$ImportData</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Import-Csv</span> <span style="color: #008080; font-style: italic;">-Path</span> <span style="color: #800080;">$ImportCSV</span>
&nbsp;
		<span style="color: #800080;">$ADSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> DirectoryServices.DirectorySearcher<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(&amp;(objectClass=group)(name=Employees))&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #800080;">$Groups</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ADSearcher</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
		<span style="color: #800080;">$Group</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>ADSI<span style="color: #000000;">&#93;</span><span style="color: #800080;">$Groups</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.Path
		<span style="color: #800080;">$GroupMembers</span> <span style="color: pink;">=</span> <span style="color: #800080;">$Group</span>.Members
&nbsp;
		<span style="color: #800080;">$OUSearcher</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">new-object</span> DirectoryServices.DirectorySearcher<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;(&amp;(objectClass=organizationalUnit)(ou=Users))&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #800080;">$UsersOUs</span> <span style="color: pink;">=</span> <span style="color: #800080;">$OUSearcher</span>.FindAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #800080;">$UserOuObj</span> <span style="color: pink;">=</span> <span style="color: #800080;">$UsersOUs</span><span style="color: #000000;">&#91;</span><span style="color: #804000;">0</span><span style="color: #000000;">&#93;</span>.Path
&nbsp;
		<span style="color: #0000FF;">ForEach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$User</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$ImportData</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$Message</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Adding User &quot;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$User</span>.UserName
			<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$Message</span>
			<span style="color: #800080;">$usersOU</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>adsi<span style="color: #000000;">&#93;</span><span style="color: #800080;">$UserOuObj</span>
			<span style="color: #800080;">$UserName</span> <span style="color: pink;">=</span> <span style="color: #800080;">$User</span>.UserName
			<span style="color: #800080;">$Department</span> <span style="color: pink;">=</span> <span style="color: #800080;">$User</span>.Department
			<span style="color: #800080;">$Title</span> <span style="color: pink;">=</span> <span style="color: #800080;">$User</span>.Title
			<span style="color: #800080;">$City</span> <span style="color: pink;">=</span> <span style="color: #800080;">$User</span>.City
&nbsp;
			<span style="color: #800080;">$newUser</span> <span style="color: pink;">=</span> <span style="color: #800080;">$usersOU</span>.Create<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;user&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;cn=$UserName&quot;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$newUser</span>.put<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;title&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$Title</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$newUser</span>.put<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;department&quot;</span><span style="color: pink;">,</span> <span style="color: #800080;">$Department</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$newUser</span>.put<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;physicalDeliveryOfficeName&quot;</span><span style="color: pink;">,</span><span style="color: #800080;">$City</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$newUser</span>.SetInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #800080;">$Group</span>.Members <span style="color: pink;">=</span> <span style="color: #800080;">$GroupMembers</span> <span style="color: pink;">+</span> <span style="color: #800080;">$newUser</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.poshpete.com/uncategorized/don-jones-powershell-challenge-my-answers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

