<?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>Vallery.net &#187; PowerShell</title>
	<atom:link href="http://vallery.net/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://vallery.net</link>
	<description>personal homepage of Jason Vallery</description>
	<lastBuildDate>Sun, 05 Feb 2012 20:13:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Organizing lots of pictures</title>
		<link>http://vallery.net/2012/02/03/organizing-lots-of-pictures/</link>
		<comments>http://vallery.net/2012/02/03/organizing-lots-of-pictures/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 06:36:02 +0000</pubDate>
		<dc:creator>jvallery</dc:creator>
				<category><![CDATA[Getting Things Done]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[duplicate file detection]]></category>
		<category><![CDATA[organization]]></category>

		<guid isPermaLink="false">http://vallery.net/?p=284</guid>
		<description><![CDATA[If you’re anything like me you’ve been taking digital pictures for a long time now.&#160;&#160; You’ve used various strategies and tools for organizing them over the years.&#160;&#160; You’ve gone through several computers and moved the files around countless times.&#160;&#160; Where does that leave you?&#160; With an unorganized mess. With library software like Picasa you can [...]]]></description>
			<content:encoded><![CDATA[<p>If you’re anything like me you’ve been taking digital pictures for a long time now.&#160;&#160; You’ve used various strategies and tools for organizing them over the years.&#160;&#160; You’ve gone through several computers and moved the files around countless times.&#160;&#160; Where does that leave you?&#160; With an unorganized mess.</p>
<p>With library software like Picasa you can import all of those pictures and you can have some semblance of organization by way of the user interface but it doesn’t really solve the problem at the core.&#160;&#160; The files are a mess.</p>
<p>I wanted to find a way to give a consistent filename to all of my pictures, organize them into folders based on the month and year they were taken, and remove duplicates.&#160;&#160; At first it sounded like a tall order as I couldn’t find any off the shelf tools to do this.&#160; Thankfully with just a little bit of time in Powershell I was able to put together a script that accomplished this for me.</p>
<p>&#160;</p>
<p>The script does the following:</p>
<ul>
<ul>
<li>Identify all of the existing pictures </li>
<li>Query the EXIF data </li>
<li>Calculate an MD5 has of the file </li>
<li>Create a new copy based on the data in a “staging” folder </li>
<li>Parse the new file name to get the MD5 and look for duplicates </li>
<li>Delete the duplicate version </li>
<li>Move the files to the YYYY\MM folders </li>
</ul>
</ul>
<p>&#160;</p>
<p>The first task of querying the EXIF data of files was actually the hardest.&#160;&#160; I found a couple of blog articles that touched on this.&#160;&#160; The synopsis is that you have to use the .NET System.Drawing DLL.&#160;&#160; We can use Get-ChildItem to recurse a directory structure looking for files of a specific type.&#160;&#160; For each file that we find we instantiate a new Bitmap object which contains the EXIF properties.&#160;&#160; We can extract and update these.&#160;&#160; I thought it might be useful to store the original path as a “Comment” in the EXIF in case it contained some relevant information that I later want to turn into a tag.</p>
<p>Below is the complete script.</p>
<pre><span style="color: #008000">#</span><span style="color: #008000">Load the .net System.Drawing assembly for examining the EXIF data of the pictures.</span><span style="color: #008000">
</span><span style="color: #000000">[</span><span style="color: #008080">reflection.assembly</span><span style="color: #000000">]::</span><span style="color: #8b4513">loadfile</span><span style="color: #000000">( </span><span style="color: #800000">&quot;</span><span style="color: #800000">C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll</span><span style="color: #800000">&quot;</span><span style="color: #000000">)

</span><span style="color: #008000">#</span><span style="color: #008000">Function to calculate the MD5 hash of a file</span><span style="color: #008000">
</span><span style="color: #0000ff">function</span><span style="color: #000000"> Get-MD5([</span><span style="color: #008080">System.IO.FileInfo</span><span style="color: #000000">] </span><span style="color: #800080">$file</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> $(</span><span style="color: #0000ff">throw</span><span style="color: #000000"> </span><span style="color: #800000">'</span><span style="color: #800000">Usage: Get-MD5 [System.IO.FileInfo]</span><span style="color: #800000">'</span><span style="color: #000000">))
{
    </span><span style="color: #008000">#</span><span style="color: #008000"> This Get-MD5 function sourced from:</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #008000">#</span><span style="color: #008000"> http://blogs.msdn.com/powershell/archive/2006/04/25/583225.aspx</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$stream</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$null</span><span style="color: #000000">;
    </span><span style="color: #800080">$cryptoServiceProvider</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">System.Security.Cryptography.MD5CryptoServiceProvider</span><span style="color: #000000">];
    </span><span style="color: #800080">$hashAlgorithm</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">new-object</span><span style="color: #000000"> </span><span style="color: #800080">$cryptoServiceProvider</span><span style="color: #000000">
    </span><span style="color: #800080">$stream</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$file</span><span style="color: #000000">.OpenRead();
    </span><span style="color: #800080">$hashByteArray</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$hashAlgorithm</span><span style="color: #000000">.ComputeHash(</span><span style="color: #800080">$stream</span><span style="color: #000000">);
    </span><span style="color: #800080">$stream</span><span style="color: #000000">.Close();

    </span><span style="color: #008000">#</span><span style="color: #008000"># We have to be sure that we close the file stream if any exceptions are thrown.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #0000ff">trap</span><span style="color: #000000">
    {
        </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$stream</span><span style="color: #000000"> </span><span style="color: #ff0000">-ne</span><span style="color: #000000"> </span><span style="color: #800080">$null</span><span style="color: #000000">) { </span><span style="color: #800080">$stream</span><span style="color: #000000">.Close(); }
        </span><span style="color: #0000ff">break</span><span style="color: #000000">;
    }

    </span><span style="color: #800080">$md5</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;&quot;</span><span style="color: #000000">
    </span><span style="color: #0000ff">foreach</span><span style="color: #000000"> (</span><span style="color: #800080">$byte</span><span style="color: #000000"> </span><span style="color: #0000ff">in</span><span style="color: #000000"> </span><span style="color: #800080">$hashByteArray</span><span style="color: #000000">)
      {
        </span><span style="color: #800080">$md5</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$md5</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$byte</span><span style="color: #000000">.ToString(</span><span style="color: #800000">&quot;</span><span style="color: #800000">X2</span><span style="color: #800000">&quot;</span><span style="color: #000000">);
      }
</span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #800080">$md5</span><span style="color: #000000">;
}

</span><span style="color: #008000">#</span><span style="color: #008000">Figure out where we are at and if there is a subfolder called output.  If not we will create one.   This is where we will put all of our images.</span><span style="color: #008000">
</span><span style="color: #800080">$currdir</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000">  </span><span style="color: #5f9ea0; font-weight: bold">split-path</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-parent</span><span style="color: #000000"> </span><span style="color: #800080">$MyInvocation</span><span style="color: #000000">.MyCommand.Definition
</span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$currdir</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">\output\</span><span style="color: #800000">&quot;</span><span style="color: #000000">

</span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #ff0000">!</span><span style="color: #000000">(</span><span style="color: #5f9ea0; font-weight: bold">Test-Path</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-path</span><span style="color: #000000"> </span><span style="color: #800080">$outputdir</span><span style="color: #000000">))
{
    </span><span style="color: #5f9ea0; font-weight: bold">New-Item</span><span style="color: #000000"> </span><span style="color: #800080">$outputdir</span><span style="color: #000000"> -type </span><span style="color: #800000">directory</span><span style="color: #000000">
}

</span><span style="color: #008000">#</span><span style="color: #008000">What files should we look for?   Typically this would be *.jpg.</span><span style="color: #008000">
</span><span style="color: #800080">$ext</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">*.jpg</span><span style="color: #800000">&quot;</span><span style="color: #000000">

</span><span style="color: #008000">#</span><span style="color: #008000">Using Get-ChildItem we search for all files matching our extension recurisvley from the location of the script down.</span><span style="color: #008000">
</span><span style="color: #800080">$files</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">Get-ChildItem</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-r</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-Include</span><span style="color: #000000"> </span><span style="color: #800080">$ext</span><span style="color: #000000">

</span><span style="color: #008000">#</span><span style="color: #008000">We're going to keep track of how many files we process and put a unique number in the file for each one (eliminates all possibility of duplicate filename)</span><span style="color: #008000">
</span><span style="color: #800080">$i</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;
</span><span style="color: #0000ff">foreach</span><span style="color: #000000">(</span><span style="color: #800080">$f</span><span style="color: #000000"> </span><span style="color: #0000ff">in</span><span style="color: #000000"> </span><span style="color: #800080">$files</span><span style="color: #000000">) {
    </span><span style="color: #008000">#</span><span style="color: #008000">Increment our counter</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$i</span><span style="color: #ff0000">++</span><span style="color: #000000">;

    </span><span style="color: #008000">#</span><span style="color: #008000">Load up the .net system.drawing.bitmap object for the current file.  We will use this to access and update the exif data.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$img</span><span style="color: #000000">=</span><span style="color: #5f9ea0; font-weight: bold">New-Object</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-TypeName</span><span style="color: #000000"> </span><span style="color: #800000">system.drawing.bitmap</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-ArgumentList</span><span style="color: #000000"> </span><span style="color: #800080">$f</span><span style="color: #000000">.fullname;

    </span><span style="color: #008000">#</span><span style="color: #008000">We grab up the camera date, height, and width.  We use try catch in case the property isn't availabe and set a default value.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #008000">#</span><span style="color: #008000">For more details on properties available check:</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #008000">#</span><span style="color: #008000">http://blogs.technet.com/b/jamesone/archive/2007/07/13/exploring-photographic-exif-data-using-powershell-of-course.aspx</span><span style="color: #008000">
</span><span style="color: #000000">
    </span><span style="color: #0000ff">Try</span><span style="color: #000000">
     {
        </span><span style="color: #008000">#</span><span style="color: #008000">The value is a byte array which we need to convert (assuming ASCII character set)</span><span style="color: #008000">
</span><span style="color: #000000">        </span><span style="color: #800080">$date</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">System.Text.Encoding</span><span style="color: #000000">]::</span><span style="color: #8b4513">ASCII</span><span style="color: #000000">.</span><span style="color: #8b4513">GetString</span><span style="color: #000000">(</span><span style="color: #800080">$img</span><span style="color: #000000">.GetPropertyItem(</span><span style="color: #000000">36867</span><span style="color: #000000">).Value);
     }
    </span><span style="color: #0000ff">Catch</span><span style="color: #000000"> [</span><span style="color: #008080">system.exception</span><span style="color: #000000">]
     {
        </span><span style="color: #008000">#</span><span style="color: #008000">Default value in case we can't access the EXIF</span><span style="color: #008000">
</span><span style="color: #000000">        </span><span style="color: #800080">$date</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">0000:00:00 00:00:00</span><span style="color: #800000">&quot;</span><span style="color: #000000">;
      }

    </span><span style="color: #008000">#</span><span style="color: #008000">Grab the height and width of our object</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$height</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$img</span><span style="color: #000000">.Height;
    </span><span style="color: #800080">$width</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$img</span><span style="color: #000000">.Width; 

    </span><span style="color: #008000">#</span><span style="color: #008000">The date is returned as a null terminated string with spaces and colons in it.   We replace all of these with dashes to make it filename friendly.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$date</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> ((</span><span style="color: #800080">$date</span><span style="color: #000000">.Replace(</span><span style="color: #800000">&quot;</span><span style="color: #800000">`0</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800000">&quot;&quot;</span><span style="color: #000000">)).Replace(</span><span style="color: #800000">&quot;</span><span style="color: #800000"> </span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">-</span><span style="color: #800000">&quot;</span><span style="color: #000000">)).Replace(</span><span style="color: #800000">&quot;</span><span style="color: #800000">:</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">-</span><span style="color: #800000">&quot;</span><span style="color: #000000">);

    </span><span style="color: #008000">#</span><span style="color: #008000">Calcualte the MD5 of the original file so that we can look for duplicates later</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$md5</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> Get-MD5(</span><span style="color: #800080">$f</span><span style="color: #000000">);

    </span><span style="color: #008000">#</span><span style="color: #008000">The target filename will be the output directory with the variables concatnated in the below format.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #008000">#</span><span style="color: #008000">Format will be YYYY-MM-DD-HH-MM-SS-WIDTHxHEIGHT-MD5-ID.Extension</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$filename</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> [</span><span style="color: #008080">string</span><span style="color: #000000">]::</span><span style="color: #8b4513">Format</span><span style="color: #000000">(</span><span style="color: #800000">&quot;</span><span style="color: #800000">{0}-{1}x{2}-{3}-{4}{5}</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800080">$date</span><span style="color: #000000">, </span><span style="color: #800080">$width</span><span style="color: #000000">, </span><span style="color: #800080">$height</span><span style="color: #000000">, </span><span style="color: #800080">$md5</span><span style="color: #000000">, </span><span style="color: #800080">$i</span><span style="color: #000000">, </span><span style="color: #800080">$f</span><span style="color: #000000">.extension);

    </span><span style="color: #008000">#</span><span style="color: #008000">We want to save the current path as a comment so we create a new property of type 40092 (comment)</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$property</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$img</span><span style="color: #000000">.PropertyItems[0];
    </span><span style="color: #800080">$property</span><span style="color: #000000">.Id </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #000000">40092</span><span style="color: #000000">;
    </span><span style="color: #800080">$property</span><span style="color: #000000">.Type </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">;

    </span><span style="color: #008000">#</span><span style="color: #008000">It needs a string array so we pass in the current path ($f.fullname) and convert it to an array</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$property</span><span style="color: #000000">.Value </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">system.text.encoding</span><span style="color: #000000">]::</span><span style="color: #8b4513">Unicode</span><span style="color: #000000">.</span><span style="color: #8b4513">GetBytes</span><span style="color: #000000">(</span><span style="color: #800080">$f</span><span style="color: #000000">.fullname </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">:</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$md5</span><span style="color: #000000">);
    </span><span style="color: #800080">$property</span><span style="color: #000000">.Len </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$property</span><span style="color: #000000">.Value.Count;
    </span><span style="color: #800080">$img</span><span style="color: #000000">.SetPropertyItem(</span><span style="color: #800080">$property</span><span style="color: #000000">);

    </span><span style="color: #008000">#</span><span style="color: #008000">We will save our image from memory in the path of our new file.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$img</span><span style="color: #000000">.Save(</span><span style="color: #800080">$filename</span><span style="color: #000000">);
    </span><span style="color: #800080">$img</span><span style="color: #000000">.Dispose();

    </span><span style="color: #008000">#</span><span style="color: #008000">Could delete the old version, I'm leaving it as a backup so I've commented this out.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #008000">#</span><span style="color: #008000">Remove-Item $f.fullname;</span><span style="color: #008000">
</span><span style="color: #000000">
    </span><span style="color: #008000">#</span><span style="color: #008000">Let the user know what the current status is and which files are being moved.    </span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #5f9ea0; font-weight: bold">Write-Output</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Copying $f to $filename</span><span style="color: #800000">&quot;</span><span style="color: #000000">;
}

</span><span style="color: #008000">#</span><span style="color: #008000">This is a one liner to split on filename, find the duplicates by MD5, ignore the first result and then delete the rest</span><span style="color: #008000">
#</span><span style="color: #008000">The 7th item in the filename format is the MD5 hence the hard coded index</span><span style="color: #008000">
</span><span style="color: #800080">$o</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">Get-ChildItem</span><span style="color: #000000"> </span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">`</span><span style="color: #000000">
| </span><span style="color: #5f9ea0; font-weight: bold">Select-Object</span><span style="color: #000000"> @{Name</span><span style="color: #ff0000">=</span><span style="color: #800000">&quot;</span><span style="color: #800000">MD5</span><span style="color: #800000">&quot;</span><span style="color: #000000">;Expression</span><span style="color: #ff0000">=</span><span style="color: #000000">{(</span><span style="color: #800080">$_</span><span style="color: #000000">.Name).Split(</span><span style="color: #800000">&quot;</span><span style="color: #800000">-</span><span style="color: #800000">&quot;</span><span style="color: #000000">)[7]}}, @{Name</span><span style="color: #ff0000">=</span><span style="color: #800000">&quot;</span><span style="color: #800000">Filename</span><span style="color: #800000">&quot;</span><span style="color: #000000">;Expression</span><span style="color: #ff0000">=</span><span style="color: #000000">{</span><span style="color: #800080">$_</span><span style="color: #000000">.Fullname}} </span><span style="color: #5f9ea0; font-weight: bold">`</span><span style="color: #000000">
| </span><span style="color: #5f9ea0; font-weight: bold">Group-Object</span><span style="color: #000000"> </span><span style="color: #800000">md5</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">`</span><span style="color: #000000">
| ?{ </span><span style="color: #800080">$_</span><span style="color: #000000">.Count </span><span style="color: #ff0000">-gt</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"> } </span><span style="color: #5f9ea0; font-weight: bold">`</span><span style="color: #000000">
| </span><span style="color: #5f9ea0; font-weight: bold">%</span><span style="color: #000000"> {(</span><span style="color: #800080">$null</span><span style="color: #000000">, </span><span style="color: #800080">$rest</span><span style="color: #000000">) </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$_</span><span style="color: #000000">.Group; </span><span style="color: #800080">$rest</span><span style="color: #000000">;} </span><span style="color: #5f9ea0; font-weight: bold">`</span><span style="color: #000000">
| </span><span style="color: #5f9ea0; font-weight: bold">Select-Object</span><span style="color: #000000"> </span><span style="color: #800000">Filename</span><span style="color: #000000">  </span><span style="color: #5f9ea0; font-weight: bold">`</span><span style="color: #000000">
| </span><span style="color: #5f9ea0; font-weight: bold">%</span><span style="color: #000000"> { </span><span style="color: #5f9ea0; font-weight: bold">Write-Output</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Removing duplicate $_</span><span style="color: #800000">&quot;</span><span style="color: #000000">; </span><span style="color: #5f9ea0; font-weight: bold">Remove-Item</span><span style="color: #000000"> </span><span style="color: #800080">$_</span><span style="color: #000000">.Filename }

</span><span style="color: #5f9ea0; font-weight: bold">Write-Output</span><span style="color: #000000"> </span><span style="color: #800080">$o</span><span style="color: #000000">

</span><span style="color: #008000">#</span><span style="color: #008000">Now that we've zapped our duplicates we can move the files out to their target locations</span><span style="color: #008000">
#</span><span style="color: #008000">We loop through them again extracting the important bits from the filename</span><span style="color: #008000">
#</span><span style="color: #008000">Format will be YYYY-MM-DD-HH-MM-SS-WIDTHxHEIGHT-ID.Extension</span><span style="color: #008000">
</span><span style="color: #800080">$files</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">Get-ChildItem</span><span style="color: #000000"> </span><span style="color: #800080">$outputdir</span><span style="color: #000000">
</span><span style="color: #800080">$i</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;
</span><span style="color: #0000ff">foreach</span><span style="color: #000000">(</span><span style="color: #800080">$f</span><span style="color: #000000"> </span><span style="color: #0000ff">in</span><span style="color: #000000"> </span><span style="color: #800080">$files</span><span style="color: #000000">) {
    </span><span style="color: #800080">$i</span><span style="color: #ff0000">++</span><span style="color: #000000">;

    </span><span style="color: #008000">#</span><span style="color: #008000">split string on dash and create an array of attributes</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$name</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> (</span><span style="color: #800080">$f</span><span style="color: #000000">.name).split(</span><span style="color: #800000">&quot;</span><span style="color: #800000">-</span><span style="color: #800000">&quot;</span><span style="color: #000000">);
    </span><span style="color: #800080">$year</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[0];
    </span><span style="color: #800080">$month</span><span style="color: #000000">  </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[1];
    </span><span style="color: #800080">$day</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[2];
    </span><span style="color: #800080">$hour</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[3];
    </span><span style="color: #800080">$min</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[4];
    </span><span style="color: #800080">$sec</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[5];
    </span><span style="color: #800080">$size</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[6];
    </span><span style="color: #800080">$md5</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$name</span><span style="color: #000000">[7];

    </span><span style="color: #008000">#</span><span style="color: #008000">Where are we putting the new file?</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #800080">$targetname</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$outputdir</span><span style="color: #000000">  </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$year</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">\</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$month</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">\</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> [</span><span style="color: #008080">string</span><span style="color: #000000">]::</span><span style="color: #8b4513">Format</span><span style="color: #000000">(</span><span style="color: #800000">&quot;</span><span style="color: #800000">{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}{8}</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800080">$year</span><span style="color: #000000">, </span><span style="color: #800080">$month</span><span style="color: #000000">, </span><span style="color: #800080">$day</span><span style="color: #000000">, </span><span style="color: #800080">$hour</span><span style="color: #000000">, </span><span style="color: #800080">$min</span><span style="color: #000000">, </span><span style="color: #800080">$sec</span><span style="color: #000000">, </span><span style="color: #800080">$size</span><span style="color: #000000">, </span><span style="color: #800080">$i</span><span style="color: #000000">, </span><span style="color: #800080">$f</span><span style="color: #000000">.extension);

    </span><span style="color: #008000">#</span><span style="color: #008000">Make sure that our folders exist (one for each month under the year) and if not create them</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #ff0000">!</span><span style="color: #000000">(</span><span style="color: #5f9ea0; font-weight: bold">Test-Path</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-path</span><span style="color: #000000"> (</span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$year</span><span style="color: #000000">)))
    {
        </span><span style="color: #5f9ea0; font-weight: bold">New-Item</span><span style="color: #000000"> (</span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$year</span><span style="color: #000000">) -type directory
    }

    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #ff0000">!</span><span style="color: #000000">(</span><span style="color: #5f9ea0; font-weight: bold">Test-Path</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-path</span><span style="color: #000000"> (</span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$year</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">\</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$month</span><span style="color: #000000">)))
    {
        </span><span style="color: #5f9ea0; font-weight: bold">New-Item</span><span style="color: #000000"> (</span><span style="color: #800080">$outputdir</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$year</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">\</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$month</span><span style="color: #000000">) -type directory
    }

    </span><span style="color: #008000">#</span><span style="color: #008000">Move the source file to it's new home.  -Force tells it to overwrite if the file already exists.</span><span style="color: #008000">
</span><span style="color: #000000">    </span><span style="color: #5f9ea0; font-weight: bold">Write-Output</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Moving $f to $targetname</span><span style="color: #800000">&quot;</span><span style="color: #000000">;
    </span><span style="color: #5f9ea0; font-weight: bold">Move-Item</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-Path</span><span style="color: #000000"> </span><span style="color: #800080">$f</span><span style="color: #000000">.fullname </span><span style="font-style: italic; color: #5f9ea0">-Destination</span><span style="color: #000000"> </span><span style="color: #800080">$targetname</span><span style="color: #000000"> </span><span style="font-style: italic; color: #5f9ea0">-Force</span><span style="color: #000000">
}

</span></pre>
<p>&#160;</p>
<p>&#160;</p>
<p>Here are a couple of references that I found helpful in building this script:</p>
<p>&#160;</p>
<p><a title="http://blogs.technet.com/b/jamesone/archive/2007/07/13/exploring-photographic-exif-data-using-powershell-of-course.aspx" href="http://blogs.technet.com/b/jamesone/archive/2007/07/13/exploring-photographic-exif-data-using-powershell-of-course.aspx">http://blogs.technet.com/b/jamesone/archive/2007/07/13/exploring-photographic-exif-data-using-powershell-of-course.aspx</a></p>
<p><a title="http://blog.codeassassin.com/2007/10/13/find-duplicate-files-with-powershell/" href="http://blog.codeassassin.com/2007/10/13/find-duplicate-files-with-powershell/">http://blog.codeassassin.com/2007/10/13/find-duplicate-files-with-powershell/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vallery.net/2012/02/03/organizing-lots-of-pictures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable email notifications in SharePoint 2010</title>
		<link>http://vallery.net/2011/01/13/disable-email-notifications-in-sharepoint-2010/</link>
		<comments>http://vallery.net/2011/01/13/disable-email-notifications-in-sharepoint-2010/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 17:36:42 +0000</pubDate>
		<dc:creator>jvallery</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[sharepoint 2010]]></category>

		<guid isPermaLink="false">http://vallery.net/?p=213</guid>
		<description><![CDATA[Out of the box in SharePoint 2010 all users who have a profile are also defaulted to having email notifications set to &#8220;on&#8221;.   This might make sense in a small scale implementation but for my customer that was unacceptable.  I created a powershell script that iterates through the user profiles and turns the notifications off.  [...]]]></description>
			<content:encoded><![CDATA[<p>Out of the box in SharePoint 2010 all users who have a profile are also defaulted to having email notifications set to &#8220;on&#8221;.   This might make sense in a small scale implementation but for my customer that was unacceptable.  I created a powershell script that iterates through the user profiles and turns the notifications off.  This script is similar to ones I&#8217;ve posted before for working with the user profile however it uses different fields.  The SharePoint field is called SPS-EmailOptin.   This field disables both SharePoint and NewsGator emails.</p>
<p>Of course in future releases these field names might change so you should verify before using this script.  In my case this was SharePoint 2010 October CU and NewsGator Social Sites 1.2.2419.</p>
<pre><span style="color: #008000;">#</span><span style="color: #008000;">Load the SharePoint snap-in</span><span style="color: #008000;">
</span><span style="color: #5f9ea0; font-weight: bold;">Add-PsSnapin</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.SharePoint.PowerShell</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">Load the SharePoint assemblies</span><span style="color: #008000;">
</span><span style="color: #000000;">[</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">]::</span><span style="color: #8b4513;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Microsoft.Office.Server</span><span style="color: #800000;">"</span><span style="color: #000000;">);
[</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">]::</span><span style="color: #8b4513;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Microsoft.Office.Server.UserProfiles</span><span style="color: #800000;">"</span><span style="color: #000000;">);

</span><span style="color: #008000;">#</span><span style="color: #008000;">Specify the MySite URL</span><span style="color: #008000;">
</span><span style="color: #800080;">$MySiteUrl</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">http://sharepoint.vallery.net/</span><span style="color: #800000;">"</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">Get the server context for the profile manager</span><span style="color: #008000;">
</span><span style="color: #800080;">$site</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #5f9ea0; font-weight: bold;">Get-SPSite</span><span style="color: #000000;"> </span><span style="color: #800080;">$MySiteUrl</span><span style="color: #000000;">;
</span><span style="color: #800080;">$ServerContext</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #5f9ea0; font-weight: bold;">Get-SPServiceContext</span><span style="color: #000000;"> </span><span style="color: #800080;">$site</span><span style="color: #000000;">;
</span><span style="color: #800080;">$UPManager</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #5f9ea0; font-weight: bold;">new-object</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Office.Server.UserProfiles.UserProfileManager</span><span style="color: #000000;">(</span><span style="color: #800080;">$ServerContext</span><span style="color: #000000;">);

</span><span style="color: #008000;">#</span><span style="color: #008000;">Count variables</span><span style="color: #008000;">
</span><span style="color: #800080;">$ucount</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;

</span><span style="color: #800080;">$enumProfiles</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$UPManager</span><span style="color: #000000;">.GetEnumerator();
</span><span style="color: #800000;">"</span><span style="color: #800000;">Total User Profiles available:</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #ff0000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">$UPManager</span><span style="color: #000000;">.Count
</span><span style="color: #800080;">$count</span><span style="color: #ff0000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">Loop through the profile entries and update the property</span><span style="color: #008000;">
#</span><span style="color: #008000;">Recieve Instant Notifications - NGAllowMetaEmail (bool)</span><span style="color: #008000;">
#</span><span style="color: #008000;">24 Hour Digest Email - NGReceiveDigestEmail (bool)</span><span style="color: #008000;">
#</span><span style="color: #008000;">RSS NewsFeed Email - NGAllowRssEmail (bool)</span><span style="color: #008000;">
#</span><span style="color: #008000;">SharePoint Notification emails - SPS-EmailOptin (int)
#This field has 3 values one for each email type</span><span style="color: #008000;">
</span><span style="color: #000000;">
</span><span style="color: #0000ff;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">$oUser</span><span style="color: #000000;"> </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$enumProfiles</span><span style="color: #000000;">)
{
    </span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #ff0000;">+</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$u</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">.Item(</span><span style="color: #800000;">"</span><span style="color: #800000;">Accountname</span><span style="color: #800000;">"</span><span style="color: #000000;">);
    </span><span style="color: #5f9ea0; font-weight: bold;">Write-Output</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">($count):  Setting values for $u</span><span style="color: #800000;">"</span><span style="color: #000000;">;

    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800000;">"</span><span style="color: #800000;">NGAllowMetaEmail</span><span style="color: #800000;">"</span><span style="color: #000000;">].Value </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$false</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800000;">"</span><span style="color: #800000;">NGReceiveDigestEmail</span><span style="color: #800000;">"</span><span style="color: #000000;">].Value </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$false</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800000;">"</span><span style="color: #800000;">NGAllowRssEmail</span><span style="color: #800000;">"</span><span style="color: #000000;">].Value </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$false</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800000;">"</span><span style="color: #800000;">SPS-EmailOptin</span><span style="color: #800000;">"</span><span style="color: #000000;">].Value </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">111</span><span style="color: #000000;">; 

    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">.Commit();
} 

</span><span style="color: #008000;">#</span><span style="color: #008000;">Dispose of site object</span><span style="color: #008000;">
</span><span style="color: #800080;">$site</span><span style="color: #000000;">.Dispose();</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://vallery.net/2011/01/13/disable-email-notifications-in-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Enumerating user profile property fields in SharePoint 2010 with PowerShell</title>
		<link>http://vallery.net/2010/11/30/enumerating-user-profile-property-fields-in-sharepoint-2010-with-powershell/</link>
		<comments>http://vallery.net/2010/11/30/enumerating-user-profile-property-fields-in-sharepoint-2010-with-powershell/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 06:31:09 +0000</pubDate>
		<dc:creator>jvallery</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[sharepoint 2010]]></category>

		<guid isPermaLink="false">http://vallery.net/?p=209</guid>
		<description><![CDATA[I&#8217;ve been working quite a bit with SharePoint 2010 lately and have written a number of PowerShell scripts that I think will be useful to folks. This is the first of these. This script connects to the User Profile managed service application and iterates through all of the properties that have been configured dumping the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working quite a bit with SharePoint 2010 lately and have written a number of PowerShell scripts that I think will be useful to folks.   This is the first of these.</p>
<p>This script connects to the User Profile managed service application and iterates through all of the properties that have been configured dumping the result to XML.   The script additionally pulls in any mappings to active directory.</p>
<p>I&#8217;m currently working on a script that will import this XML and update the properties accordingly.   I hope to post that soon as well.</p>
<pre><span style="color: #008000;">#</span><span style="color: #008000;">Define our configuration. This is the name you gave the import connection to AD</span><span style="color: #008000;">
</span><span style="color: #800080;">$url</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">http://sharepoint.vallery.net/</span><span style="color: #800000;">"</span><span style="color: #000000;">;
</span><span style="color: #800080;">$connectionName</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Profile Sync</span><span style="color: #800000;">"</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">Setup our SharePoint objects</span><span style="color: #008000;">
</span><span style="color: #800080;">$site</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">Get-SPSite</span><span style="color: #000000;"> </span><span style="color: #800080;">$url</span><span style="color: #000000;">;
</span><span style="color: #800080;">$serviceContext</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> Get-SPServiceContext(</span><span style="color: #800080;">$site</span><span style="color: #000000;">);
</span><span style="color: #800080;">$upManager</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">new-object</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Office.Server.UserProfiles.UserProfileConfigManager</span><span style="color: #000000;">(</span><span style="color: #800080;">$serviceContext</span><span style="color: #000000;">);
</span><span style="color: #800080;">$syncConnection</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$upManager</span><span style="color: #000000;">.</span><span style="color: #8B4513;">ConnectionManager</span><span style="color: #000000;">[</span><span style="color: #800080;">$connectionName</span><span style="color: #000000;">];

</span><span style="color: #008000;">#</span><span style="color: #008000;">This is a collection of mappings to AD that we will use later </span><span style="color: #008000;">
</span><span style="color: #800080;">$pmc</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$syncConnection</span><span style="color: #000000;">.</span><span style="color: #8B4513;">PropertyMapping</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">This is a collection of all of the properties which we will iterate</span><span style="color: #008000;">
</span><span style="color: #800080;">$properties</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$upManager</span><span style="color: #000000;">.</span><span style="color: #8B4513;">GetProperties</span><span style="color: #000000;">();

</span><span style="color: #008000;">#</span><span style="color: #008000;"> Create a new XML writer settings object </span><span style="color: #008000;">
</span><span style="color: #800080;">$settings</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-Object</span><span style="color: #000000;"> </span><span style="color: #800000;">system.Xml.XmlWriterSettings</span><span style="color: #000000;">;
</span><span style="color: #800080;">$settings</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Indent</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$true</span><span style="color: #000000;">;
</span><span style="color: #800080;">$settings</span><span style="color: #000000;">.</span><span style="color: #8B4513;">OmitXmlDeclaration</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$false</span><span style="color: #000000;">;
</span><span style="color: #800080;">$settings</span><span style="color: #000000;">.</span><span style="color: #8B4513;">NewLineOnAttributes</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$true</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;"> Create a new string writer to capture the output </span><span style="color: #008000;">
</span><span style="color: #800080;">$sw</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">new-object</span><span style="color: #000000;"> </span><span style="color: #800000;">System.IO.StringWriter</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;"> Create a new XmlWriter </span><span style="color: #008000;">
</span><span style="color: #800080;">$writer</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> [</span><span style="color: #008080;">system.xml.XmlWriter</span><span style="color: #000000;">]::</span><span style="color: #8B4513;">Create</span><span style="color: #000000;">(</span><span style="color: #800080;">$sw</span><span style="color: #000000;">, </span><span style="color: #800080;">$settings</span><span style="color: #000000;">); 

</span><span style="color: #008000;">#</span><span style="color: #008000;">Start the document and add the root node</span><span style="color: #008000;">
</span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteStartDocument</span><span style="color: #000000;">();
</span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteStartElement</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">properties</span><span style="color: #800000;">"</span><span style="color: #000000;">);

</span><span style="color: #008000;">#</span><span style="color: #008000;">Iterate through the properties</span><span style="color: #008000;">
</span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">$item</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$properties</span><span style="color: #000000;">);
{

    </span><span style="color: #008000;">#</span><span style="color: #008000;">Create the property element</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteStartElement</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">property</span><span style="color: #800000;">"</span><span style="color: #000000;">);

    </span><span style="color: #008000;">#</span><span style="color: #008000;">Add in the fields as attributes</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Name</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">DisplayName</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">DisplayName</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">ManagedPropertyName</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">ManagedPropertyName</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Type</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Type</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">ChoiceList</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">ChoiceList</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Description</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Description</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">URI</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">URI</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsSystem</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsSystem</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">AllowPolicyOverride</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">AllowPolicyOverride</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsUserEditable</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsUserEditable</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsAdminEditable</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsAdminEditable</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsImported</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsImported</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Length</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Length</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsMultivalued</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsMultivalued</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">ChoiceType</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">ChoiceType</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">DefaultPrivacy</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">DefaultPrivacy</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">UserOverridePrivacy</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">UserOverridePrivacy</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsReplicable</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsReplicable</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">PrivacyPolicy</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">PrivacyPolicy</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">DisplayOrder</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">DisplayOrder</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsColleagueEventLog</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsColleagueEventLog</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsAlias</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsAlias</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsSearchable</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsSearchable</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsUpgrade</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsUpgrade</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsUpgradePrivate</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsUpgradePrivate</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsVisibleOnEditor</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsVisibleOnEditor</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsVisibleOnViewer</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsVisibleOnViewer</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsTaxonomic</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsTaxonomic</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Separator</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Separator</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">MaximumShown</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">MaximumShown</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsSection</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsSection</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsRequired</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">IsRequired</span><span style="color: #000000;">);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">SubtypeName</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">SubtypeName</span><span style="color: #000000;">);

    </span><span style="color: #008000;">#</span><span style="color: #008000;">Look up any AD mappings in the PropertyManagerCollection and include them</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsImport</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$pmc</span><span style="color: #000000;">.Item(</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">).IsImport);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">IsExport</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$pmc</span><span style="color: #000000;">.Item(</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">).IsExport);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">DataSourcePropertyName</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$pmc</span><span style="color: #000000;">.Item(</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">).DataSourcePropertyName);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">OriginalDataSourcePropertyName</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$pmc</span><span style="color: #000000;">.Item(</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">).OriginalDataSourcePropertyName);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">AssociationName</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$pmc</span><span style="color: #000000;">.Item(</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">).AssociationName);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteAttributeString</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Connection</span><span style="color: #800000;">"</span><span style="color: #000000;">,</span><span style="color: #800080;">$pmc</span><span style="color: #000000;">.Item(</span><span style="color: #800080;">$item</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Name</span><span style="color: #000000;">).Connection.DisplayName);
    </span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteEndElement</span><span style="color: #000000;">(); 

}

</span><span style="color: #008000;">#</span><span style="color: #008000;">Finish up</span><span style="color: #008000;">
</span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteEndElement</span><span style="color: #000000;">();
</span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">WriteEndDocument</span><span style="color: #000000;">();
</span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Flush</span><span style="color: #000000;">();
</span><span style="color: #800080;">$writer</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Close</span><span style="color: #000000;">(); 

</span><span style="color: #008000;">#</span><span style="color: #008000;">Capture the output into a string</span><span style="color: #008000;">
</span><span style="color: #800080;">$result</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$sw</span><span style="color: #000000;">.</span><span style="color: #8B4513;">ToString</span><span style="color: #000000;">();

</span><span style="color: #008000;">#</span><span style="color: #008000;"> Write the XML out</span><span style="color: #008000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Write-Output</span><span style="color: #000000;"> </span><span style="color: #800080;">$result</span><span style="color: #000000;">;

</span></pre>
<p>And here is an example of the XML output:</p>
<p><textarea name="code" class="xml" cols="60" rows="10"><xml version="1.0" encoding="utf-16" ?>
<properties>
<property Name="UserProfile_GUID" DisplayName="Id" ManagedPropertyName="" Type="unique identifier" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:UserProfile_GUID" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="1" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SID" DisplayName="SID" ManagedPropertyName="" Type="binary" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SID" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="512" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="2" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="objectSid" OriginalDataSourcePropertyName="objectSid" AssociationName="" Connection="Profile Sync" />
<property Name="ADGuid" DisplayName="Active Directory Id" ManagedPropertyName="" Type="binary" ChoiceList="" Description="" URI="ADGuid" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="128" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="3" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="AccountName" DisplayName="Account name" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:AccountName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="4" IsColleagueEventLog="False" IsAlias="True" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="FirstName" DisplayName="First name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:FirstName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="5" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="givenName" OriginalDataSourcePropertyName="givenName" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-PhoneticFirstName" DisplayName="Phonetic First Name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-PhoneticFirstName" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="64" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="6" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="msDS-PhoneticFirstName" OriginalDataSourcePropertyName="msDS-PhoneticFirstName" AssociationName="" Connection="Profile Sync" />
<property Name="LastName" DisplayName="Last name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:LastName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="7" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="sn" OriginalDataSourcePropertyName="sn" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-PhoneticLastName" DisplayName="Phonetic Last Name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-PhoneticLastName" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="64" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="8" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="msDS-PhoneticLastName" OriginalDataSourcePropertyName="msDS-PhoneticLastName" AssociationName="" Connection="Profile Sync" />
<property Name="PreferredName" DisplayName="Name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:PreferredName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="9" IsColleagueEventLog="True" IsAlias="True" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="displayName" OriginalDataSourcePropertyName="displayName" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-PhoneticDisplayName" DisplayName="Phonetic Display Name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-PhoneticDisplayName" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="10" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="msDS-PhoneticDisplayName" OriginalDataSourcePropertyName="msDS-PhoneticDisplayName" AssociationName="" Connection="Profile Sync" />
<property Name="WorkPhone" DisplayName="Work phone" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:WorkPhone" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="100" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="11" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="telephoneNumber" OriginalDataSourcePropertyName="telephoneNumber" AssociationName="" Connection="Profile Sync" />
<property Name="Department" DisplayName="Department" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Department" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="12" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="department" OriginalDataSourcePropertyName="department" AssociationName="" Connection="Profile Sync" />
<property Name="Title" DisplayName="Title" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Title" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="150" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="13" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-JobTitle" DisplayName="Job Title" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-JobTitle" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="False" Length="150" IsMultivalued="False" ChoiceType="Open" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="14" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="True" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="title" OriginalDataSourcePropertyName="title" AssociationName="" Connection="Profile Sync" />
<property Name="Manager" DisplayName="Manager" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Manager" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="15" IsColleagueEventLog="True" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="manager" OriginalDataSourcePropertyName="manager" AssociationName="" Connection="Profile Sync" />
<property Name="AboutMe" DisplayName="About me" ManagedPropertyName="" Type="HTML" ChoiceList="" Description="Provide a personal description expressing what you would like others to know about you." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:AboutMe" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="3600" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="16" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="PersonalSpace" DisplayName="Personal site" ManagedPropertyName="" Type="URL" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:PersonalSpace" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="False" Length="1024" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="17" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="PictureURL" DisplayName="Picture" ManagedPropertyName="" Type="URL" ChoiceList="" Description="Upload a picture to help others easily recognize you at meetings and events." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:PictureURL" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="2048" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="18" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="UserName" DisplayName="User name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:UserName" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="19" IsColleagueEventLog="False" IsAlias="True" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="sAMAccountName" OriginalDataSourcePropertyName="sAMAccountName" AssociationName="" Connection="Profile Sync" />
<property Name="QuickLinks" DisplayName="Quick links" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:QuickLinks" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="False" IsImported="False" Length="3000" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="20" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="WebSite" DisplayName="Web site" ManagedPropertyName="" Type="URL" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:WebSite" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="1024" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="21" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="PublicSiteRedirect" DisplayName="Public site redirect" ManagedPropertyName="" Type="URL" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:PublicSiteRedirect" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="1024" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="27" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="wWWHomePage" OriginalDataSourcePropertyName="wWWHomePage" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-DataSource" DisplayName="Data source" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-DataSource" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="155" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Private" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Disabled" DisplayOrder="5001" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-MemberOf" DisplayName="MemberOf" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-MemberOf" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="2048" IsMultivalued="True" ChoiceType="Open" DefaultPrivacy="Private" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Disabled" DisplayOrder="5002" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="True" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-Dotted-line" DisplayName="Dotted-line Manager" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Dotted-line" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="False" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5003" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-Peers" DisplayName="Peers" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Peers" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="False" IsImported="False" Length="3000" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5004" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-Responsibility" DisplayName="Ask Me About" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="Update your "Ask Me About" with topics you can help people with, such as your responsibilities or areas of expertise." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Responsibility" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="True" ChoiceType="Open" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="5005" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="True" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-SipAddress" DisplayName="SIP Address" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-SipAddress" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="5010" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="proxyAddresses" OriginalDataSourcePropertyName="proxyAddresses" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-MySiteUpgrade" DisplayName="My Site Upgrade" ManagedPropertyName="" Type="boolean" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-MySiteUpgrade" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5012" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-DontSuggestList" DisplayName="Don't Suggest List" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-DontSuggestList" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="250" IsMultivalued="True" ChoiceType="Off" DefaultPrivacy="Private" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5013" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-ProxyAddresses" DisplayName="Proxy addresses" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ProxyAddresses" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="0" IsMultivalued="True" ChoiceType="Open" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5014" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="True" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-HireDate" DisplayName="Hire date" ManagedPropertyName="" Type="date" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-HireDate" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5015" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-DisplayOrder" DisplayName="Display Order" ManagedPropertyName="" Type="integer" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-DisplayOrder" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5016" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-ClaimID" DisplayName="Claim User Identifier" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ClaimID" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5017" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-ClaimProviderID" DisplayName="Claim Provider Identifier" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ClaimProviderID" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5018" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="Windows" OriginalDataSourcePropertyName="Windows" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-ClaimProviderType" DisplayName="Claim Provider Type" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ClaimProviderType" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5019" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="Windows" OriginalDataSourcePropertyName="Windows" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-LastColleagueAdded" DisplayName="Last Colleague Added" ManagedPropertyName="" Type="date" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-LastColleagueAdded" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Private" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5019" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-OWAUrl" DisplayName="Outlook Web Access URL" ManagedPropertyName="" Type="URL" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-OWAUrl" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="2048" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Private" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5020" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-SavedAccountName" DisplayName="Saved Account Name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-SavedAccountName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="False" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5020" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-SavedSID" DisplayName="Saved SID" ManagedPropertyName="" Type="binary" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-SavedSID" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="False" Length="512" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5021" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-ResourceSID" DisplayName="Resource Forest SID" ManagedPropertyName="" Type="binary" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ResourceSID" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="512" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5021" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-ResourceAccountName" DisplayName="Resource Forest Account Name" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ResourceAccountName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="5022" IsColleagueEventLog="False" IsAlias="True" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-ObjectExists" DisplayName="Object Exists" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-ObjectExists" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5023" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-MasterAccountName" DisplayName="Master Account Name" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-MasterAccountName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="False" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="5028" IsColleagueEventLog="False" IsAlias="True" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-DistinguishedName" DisplayName="Distinguished Name" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-DistinguishedName" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="2048" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5029" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="dn" OriginalDataSourcePropertyName="dn" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-SourceObjectDN" DisplayName="Source Object Distinguished Name" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-SourceObjectDN" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="2048" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="5041" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="msDS-SourceObjectDN" OriginalDataSourcePropertyName="msDS-SourceObjectDN" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-LastKeywordAdded" DisplayName="Last Keyword Added" ManagedPropertyName="" Type="date" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-LastKeywordAdded" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Private" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5100" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="False" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="WorkEmail" DisplayName="Work e-mail" ManagedPropertyName="" Type="Email" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:WorkEmail" IsSystem="True" AllowPolicyOverride="False" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="256" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="5103" IsColleagueEventLog="True" IsAlias="True" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="mail" OriginalDataSourcePropertyName="mail" AssociationName="" Connection="Profile Sync" />
<property Name="CellPhone" DisplayName="Mobile phone" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="This number will be shown on your profile. Also, it will be used for text message (SMS) alerts." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:CellPhone" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="100" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="OptIn" DisplayOrder="5104" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="Fax" DisplayName="Fax" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Fax" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="100" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5105" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="HomePhone" DisplayName="Home phone" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:HomePhone" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="100" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Contacts" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5107" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="Office" DisplayName="Office" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Office" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="True" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="5108" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="physicalDeliveryOfficeName" OriginalDataSourcePropertyName="physicalDeliveryOfficeName" AssociationName="" Connection="Profile Sync" />
<property Name="SPS-Location" DisplayName="Office Location" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="Enter your current location.<br />(e.g. China, Tokyo, West Campus)&#8221; URI=&#8221;urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Location&#8221; IsSystem=&#8221;False&#8221; AllowPolicyOverride=&#8221;True&#8221; IsUserEditable=&#8221;True&#8221; IsAdminEditable=&#8221;True&#8221; IsImported=&#8221;False&#8221; Length=&#8221;0&#8243; IsMultivalued=&#8221;False&#8221; ChoiceType=&#8221;Open&#8221; DefaultPrivacy=&#8221;Public&#8221; UserOverridePrivacy=&#8221;True&#8221; IsReplicable=&#8221;False&#8221; PrivacyPolicy=&#8221;OptIn&#8221; DisplayOrder=&#8221;5109&#8243; IsColleagueEventLog=&#8221;False&#8221; IsAlias=&#8221;False&#8221; IsSearchable=&#8221;True&#8221; IsUpgrade=&#8221;False&#8221; IsUpgradePrivate=&#8221;False&#8221; IsVisibleOnEditor=&#8221;True&#8221; IsVisibleOnViewer=&#8221;False&#8221; IsTaxonomic=&#8221;True&#8221; Separator=&#8221;Unknown&#8221; MaximumShown=&#8221;10&#8243; IsSection=&#8221;False&#8221; IsRequired=&#8221;False&#8221; SubtypeName=&#8221;UserProfile&#8221; IsImport=&#8221;" IsExport=&#8221;" DataSourcePropertyName=&#8221;" OriginalDataSourcePropertyName=&#8221;" AssociationName=&#8221;" Connection=&#8221;" /> </p>
<property Name="SPS-TimeZone" DisplayName="Time Zone" ManagedPropertyName="" Type="timezone" ChoiceList="" Description="Select the time zone for your current location. We will use this information to show the local time on your profile page." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-TimeZone" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5110" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="Assistant" DisplayName="Assistant" ManagedPropertyName="" Type="Person" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Assistant" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="250" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5200" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-PastProjects" DisplayName="Past projects" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="Provide information on previous projects, teams or groups." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-PastProjects" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="True" ChoiceType="Open" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5202" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="True" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-Skills" DisplayName="Skills" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="Include skills used to perform your job or previous projects.<br />(e.g. C++, Public Speaking, Design)&#8221; URI=&#8221;urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Skills&#8221; IsSystem=&#8221;True&#8221; AllowPolicyOverride=&#8221;True&#8221; IsUserEditable=&#8221;True&#8221; IsAdminEditable=&#8221;True&#8221; IsImported=&#8221;False&#8221; Length=&#8221;0&#8243; IsMultivalued=&#8221;True&#8221; ChoiceType=&#8221;Open&#8221; DefaultPrivacy=&#8221;Public&#8221; UserOverridePrivacy=&#8221;True&#8221; IsReplicable=&#8221;False&#8221; PrivacyPolicy=&#8221;OptIn&#8221; DisplayOrder=&#8221;5203&#8243; IsColleagueEventLog=&#8221;True&#8221; IsAlias=&#8221;False&#8221; IsSearchable=&#8221;True&#8221; IsUpgrade=&#8221;False&#8221; IsUpgradePrivate=&#8221;False&#8221; IsVisibleOnEditor=&#8221;True&#8221; IsVisibleOnViewer=&#8221;True&#8221; IsTaxonomic=&#8221;True&#8221; Separator=&#8221;Comma&#8221; MaximumShown=&#8221;10&#8243; IsSection=&#8221;False&#8221; IsRequired=&#8221;False&#8221; SubtypeName=&#8221;UserProfile&#8221; IsImport=&#8221;" IsExport=&#8221;" DataSourcePropertyName=&#8221;" OriginalDataSourcePropertyName=&#8221;" AssociationName=&#8221;" Connection=&#8221;" /> </p>
<property Name="SPS-School" DisplayName="Schools" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="List the schools you have attended." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-School" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="True" ChoiceType="Open" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5204" IsColleagueEventLog="False" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="True" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-Birthday" DisplayName="Birthday" ManagedPropertyName="" Type="datenoyear" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Birthday" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5205" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-StatusNotes" DisplayName="Status Message" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-StatusNotes" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="512" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5300" IsColleagueEventLog="True" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-Interests" DisplayName="Interests" ManagedPropertyName="" Type="string (Multi Value)" ChoiceList="Microsoft.Office.Server.UserProfiles.ChoiceList" Description="Share personal and business related interests. We will help you keep in touch with activities related to these interests through events in your newsfeed." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-Interests" IsSystem="True" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="True" ChoiceType="Open" DefaultPrivacy="Public" UserOverridePrivacy="True" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5402" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="True" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="SPS-EmailOptin" DisplayName="Email Notifications" ManagedPropertyName="" Type="integer" ChoiceList="" Description="" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:SPS-EmailOptin" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="OptIn" DisplayOrder="5500" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Unknown" MaximumShown="10" IsSection="False" IsRequired="False" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="Company" DisplayName="Company" ManagedPropertyName="" Type="string (Single Value)" ChoiceList="" Description="Company" URI="urn:schemas-microsoft-com:sharepoint:portal:profile:Company" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="False" IsAdminEditable="True" IsImported="False" Length="25" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="True" PrivacyPolicy="Mandatory" DisplayOrder="5601" IsColleagueEventLog="True" IsAlias="False" IsSearchable="True" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="True" IsTaxonomic="False" Separator="Comma" MaximumShown="1" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="True" IsExport="False" DataSourcePropertyName="company" OriginalDataSourcePropertyName="company" AssociationName="" Connection="Profile Sync" />
<property Name="NGAllowMetaEmail" DisplayName="Receive Instant Notification Emails" ManagedPropertyName="" Type="boolean" ChoiceList="" Description="Receive email notifications when someone responds to one of your activities." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:NGAllowMetaEmail" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="5603" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="NGReceiveDigestEmail" DisplayName="Receive 24-hour Digest Email" ManagedPropertyName="" Type="boolean" ChoiceList="" Description="Receive digest email of community and colleague activities for the last 24 hours." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:NGReceiveDigestEmail" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="5604" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" />
<property Name="NGAllowRssEmail" DisplayName="Receive News Stream Notification Emails" ManagedPropertyName="" Type="boolean" ChoiceList="" Description="Receive email notifications when new News Stream items match one of your keywords." URI="urn:schemas-microsoft-com:sharepoint:portal:profile:NGAllowRssEmail" IsSystem="False" AllowPolicyOverride="True" IsUserEditable="True" IsAdminEditable="True" IsImported="False" Length="0" IsMultivalued="False" ChoiceType="Off" DefaultPrivacy="Public" UserOverridePrivacy="False" IsReplicable="False" PrivacyPolicy="Mandatory" DisplayOrder="5605" IsColleagueEventLog="False" IsAlias="False" IsSearchable="False" IsUpgrade="False" IsUpgradePrivate="False" IsVisibleOnEditor="True" IsVisibleOnViewer="False" IsTaxonomic="False" Separator="Comma" MaximumShown="10" IsSection="False" IsRequired="True" SubtypeName="UserProfile" IsImport="" IsExport="" DataSourcePropertyName="" OriginalDataSourcePropertyName="" AssociationName="" Connection="" /></properties></xml></textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://vallery.net/2010/11/30/enumerating-user-profile-property-fields-in-sharepoint-2010-with-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using PowerShell and the DirectorySearcher class</title>
		<link>http://vallery.net/2010/04/09/using-powershell-and-the-directorysearched-class/</link>
		<comments>http://vallery.net/2010/04/09/using-powershell-and-the-directorysearched-class/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 22:34:41 +0000</pubDate>
		<dc:creator>jvallery</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://vallery.net/?p=206</guid>
		<description><![CDATA[I needed to locate the LDAP distinguished name of an individual user account in a remote domain via PowerShell.   Assuming your script is running on a box that is part of a domain that has a trust to the remote domain we can do this by running a query against Active Directory with LDAP. By [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to locate the LDAP distinguished name of an individual user account in a remote domain via PowerShell.   Assuming your script is running on a box that is part of a domain that has a trust to the remote domain we can do this by running a query against Active Directory with LDAP.</p>
<p>By using the DirectorySearcher class we can build complex LDAP queries to find objects in Active Directory.   With this information you can do all kinds of fun scripting things.</p>
<p>Here is a sample script:</p>
<pre><span style="color: #000000;">

</span><span style="color: #008000;">#</span><span style="color: #008000;">Specify the search criteria</span><span style="color: #008000;">
</span><span style="color: #800080;">$samname</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">jasonv</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$domain</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">dev.lcl</span><span style="color: #800000;">"</span><span style="color: #000000;">

</span><span style="color: #008000;">#</span><span style="color: #008000;">Get a list of domains in the forest and grab the DN of the one matching the above parameter.</span><span style="color: #008000;">
</span><span style="color: #800080;">$forest</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> [</span><span style="color: #008080;">System.DirectoryServices.ActiveDirectory.Forest</span><span style="color: #000000;">]::</span><span style="color: #8B4513;">GetCurrentForest</span><span style="color: #000000;">()
</span><span style="color: #800080;">$domain</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$forest</span><span style="color: #000000;">.Domains | ? {</span><span style="color: #800080;">$_</span><span style="color: #000000;">.Name </span><span style="color: #FF0000;">-eq</span><span style="color: #000000;"> </span><span style="color: #800080;">$domain</span><span style="color: #000000;">}
</span><span style="color: #800080;">$domainDN</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$domain</span><span style="color: #000000;">.</span><span style="color: #8B4513;">GetDirectoryEntry</span><span style="color: #000000;">().distinguishedName
</span><span style="color: #5F9EA0; font-weight: bold;">Write-Output</span><span style="color: #000000;">  </span><span style="color: #800000;">"</span><span style="color: #800000;">Found the remote domain, the full LDAP distinguished name is $DomainDN</span><span style="color: #800000;">"</span><span style="color: #000000;">

</span><span style="color: #008000;">#</span><span style="color: #008000;">Create an LDAP searcher object and pass in the DN of the domain we wish to query</span><span style="color: #008000;">
</span><span style="color: #800080;">$Searcher</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-Object</span><span style="color: #000000;"> </span><span style="color: #800000;">System.DirectoryServices.DirectorySearcher</span><span style="color: #000000;">([</span><span style="color: #008080;">ADSI</span><span style="color: #000000;">]</span><span style="color: #800000;">"</span><span style="color: #800000;">LDAP://$domainDN</span><span style="color: #800000;">"</span><span style="color: #000000;">)

</span><span style="color: #008000;">#</span><span style="color: #008000;">Pass in the ceriteria we are searching for.</span><span style="color: #008000;">
#</span><span style="color: #008000;">In this case we're looking for users with a particular SAM name.</span><span style="color: #008000;">
</span><span style="color: #800080;">$Searcher</span><span style="color: #000000;">.</span><span style="color: #8B4513;">filter</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">(&amp;(objectCategory=person)(objectClass=user)(sAMAccountName= $samname))</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$results</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$Searcher</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Findall</span><span style="color: #000000;">()

</span><span style="color: #008000;">#</span><span style="color: #008000;">Loop through the results</span><span style="color: #008000;">
</span><span style="color: #0000FF;">Foreach</span><span style="color: #000000;">(</span><span style="color: #800080;">$result</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$results</span><span style="color: #000000;">){
    </span><span style="color: #800080;">$User</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$result</span><span style="color: #000000;">.</span><span style="color: #8B4513;">GetDirectoryEntry</span><span style="color: #000000;">()
    </span><span style="color: #800080;">$userDN</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;">  </span><span style="color: #800080;">$user</span><span style="color: #000000;">.</span><span style="color: #8B4513;">DistinguishedName</span><span style="color: #000000;">
    </span><span style="color: #5F9EA0; font-weight: bold;">Write-Output</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Found a user matching with the distingused name of $userDN</span><span style="color: #800000;">"</span><span style="color: #000000;">
}

</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://vallery.net/2010/04/09/using-powershell-and-the-directorysearched-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using powershell to set SSP profile properties</title>
		<link>http://vallery.net/2010/04/01/using-powershell-to-set-ssp-profile-properties/</link>
		<comments>http://vallery.net/2010/04/01/using-powershell-to-set-ssp-profile-properties/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 13:57:39 +0000</pubDate>
		<dc:creator>jvallery</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SSP]]></category>

		<guid isPermaLink="false">http://vallery.net/?p=180</guid>
		<description><![CDATA[I recently put together a powershell script that can be used to update a profile property of all of the users stored in the SharePoint SSP.  At NewsGator we use a boolean property field to indicate if a particular part of our product has been activated or not.  There are some cases where this boolean [...]]]></description>
			<content:encoded><![CDATA[<p>I recently put together a powershell script that can be used to update a profile property of all of the users stored in the SharePoint SSP.  At NewsGator we use a boolean property field to indicate if a particular part of our product has been activated or not.  There are some cases where this boolean flag needs to be reset for all users.   To do this I put together a simple powershell script to reset this value for all users.</p>
<p>This could easily be adapted for other users so I thought I would post share it.</p>
<pre>
<span style="color: #008000;">#</span><span style="color: #008000;">##########################</span><span style="color: #008000;">
#</span><span style="color: #008000;"> "Configure Settings"</span><span style="color: #008000;">
</span><span style="color: #800080;">$SSPName</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">SSPAdmin</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$MySiteUrl</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">http://mysite/</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$propName</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">newsgator-x-onboarded</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$propValue</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">true</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #008000;">#</span><span style="color: #008000;">##########################</span><span style="color: #008000;">
</span><span style="color: #000000;">
</span><span style="color: #008000;">#</span><span style="color: #008000;">Load the SharePoint assemblies</span><span style="color: #008000;">
</span><span style="color: #000000;">[</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">]::</span><span style="color: #8b4513;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Microsoft.Office.Server</span><span style="color: #800000;">"</span><span style="color: #000000;">)
[</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">]::</span><span style="color: #8b4513;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Microsoft.Office.Server.UserProfiles</span><span style="color: #800000;">"</span><span style="color: #000000;">)

</span><span style="color: #800080;">$ServerContext</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> [Microsoft.Office.Server.ServerContext]::GetContext(</span><span style="color: #800080;">$SSPName</span><span style="color: #000000;">);
</span><span style="color: #800080;">$UPManager</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #5f9ea0; font-weight: bold;">new-object</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Office.Server.UserProfiles.UserProfileManager</span><span style="color: #000000;">(</span><span style="color: #800080;">$ServerContext</span><span style="color: #000000;">);
</span><span style="color: #800080;">$enumProfiles</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$UPManager</span><span style="color: #000000;">.GetEnumerator();
</span><span style="color: #800000;">"</span><span style="color: #800000;">Total User Profiles available:</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #ff0000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">$UPManager</span><span style="color: #000000;">.Count
</span><span style="color: #800080;">$count</span><span style="color: #ff0000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">Loop through the SSP entries and update the property</span><span style="color: #008000;">
</span><span style="color: #0000ff;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">$oUser</span><span style="color: #000000;"> </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$enumProfiles</span><span style="color: #000000;">)
{
    </span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #ff0000;">+</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$u</span><span style="color: #000000;"> </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">.Item(</span><span style="color: #800000;">"</span><span style="color: #800000;">Accountname</span><span style="color: #800000;">"</span><span style="color: #000000;">);
    </span><span style="color: #5f9ea0; font-weight: bold;">Write-Output</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">($count):  Setting '$propName' to '$propValue' for $u</span><span style="color: #800000;">"</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800080;">$propName</span><span style="color: #000000;">].Value </span><span style="color: #ff0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$propValue</span><span style="color: #000000;">;
    </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">.Commit();
} 

</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://vallery.net/2010/04/01/using-powershell-to-set-ssp-profile-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Activating features in bulk on the MySite with PowerShell</title>
		<link>http://vallery.net/2010/04/01/activating-features-in-bulk-on-the-mysite-with-powershell/</link>
		<comments>http://vallery.net/2010/04/01/activating-features-in-bulk-on-the-mysite-with-powershell/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 01:42:46 +0000</pubDate>
		<dc:creator>jvallery</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Feature Activation]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://vallery.net/?p=178</guid>
		<description><![CDATA[I recently came across a client who needed to activate a couple of features on their MySites in batches.   Given that they have a significant number of MySites already created we needed to find a way to stage the deployment of the new functionality that the features offer.   I put together a PowerShell script that [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a client who needed to activate a couple of features on their MySites in batches.   Given that they have a significant number of MySites already created we needed to find a way to stage the deployment of the new functionality that the features offer.   I put together a PowerShell script that iterates through the SSP looking for users who:</p>
<ul>
<li>Have a MySite</li>
<li>Either one of both of the required features are not currently active</li>
</ul>
<p>For each of the users that match the above criteria both of the features are activated.  A counter is incremented and once we reach the desired number of users for the batch the script exits.   When we are ready to process another batch the script effectively picks up where it left off since we&#8217;re skipping the users who are already activated.   </p>
<p>You could then have the execution of this script automatically executed on a regular basis during low utilization hours.  Eventually everyone will have the features activated and the new functionality deployed.   You could continue to let the script execute to catch any new users (if you decide not to staple the features like we are).</p>
<p>For others looking to do something similar I’m posting the original script in its entirety.</p>
<pre>
<span style="color: #000000;">
</span><span style="color: #008000;">#</span><span style="color: #008000;">##########################</span><span style="color: #008000;">
#</span><span style="color: #008000;"> "Configure Settings"</span><span style="color: #008000;">
</span><span style="color: #800080;">$SSPName</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">SSPAdmin</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$mysiteurl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">http://mysite</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$ngsite_feature_id</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">6a91335c-5ecc-4afc-aa68-14d73afbb1bc</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$webpart_feature_id</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">5174F049-99D9-4d68-96E0-93AB2AE1C7BC</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #800080;">$userCount</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">500</span><span style="color: #000000;">
</span><span style="color: #800080;">$stsadm</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">$env:programfiles\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\STSADM.EXE</span><span style="color: #800000;">"</span><span style="color: #000000;">
</span><span style="color: #008000;">#</span><span style="color: #008000;">##########################</span><span style="color: #008000;">
</span><span style="color: #000000;">
</span><span style="color: #008000;">#</span><span style="color: #008000;">Load the SharePoint Assemblies</span><span style="color: #008000;">
</span><span style="color: #000000;">[</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">]::</span><span style="color: #8B4513;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Microsoft.Office.Server</span><span style="color: #800000;">"</span><span style="color: #000000;">)
[</span><span style="color: #008080;">System.Reflection.Assembly</span><span style="color: #000000;">]::</span><span style="color: #8B4513;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #800000;">"</span><span style="color: #800000;">Microsoft.Office.Server.UserProfiles</span><span style="color: #800000;">"</span><span style="color: #000000;">)

</span><span style="color: #008000;">#</span><span style="color: #008000;">Create the SSP objects</span><span style="color: #008000;">
</span><span style="color: #800080;">$ServerContext</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> [Microsoft.Office.Server.ServerContext]::GetContext(</span><span style="color: #800080;">$SSPName</span><span style="color: #000000;">);
</span><span style="color: #800080;">$UPManager</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> new-object Microsoft.Office.Server.UserProfiles.UserProfileManager(</span><span style="color: #800080;">$ServerContext</span><span style="color: #000000;">);

</span><span style="color: #800080;">$enumProfiles</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$UPManager</span><span style="color: #000000;">.GetEnumerator();
</span><span style="color: #800000;">"</span><span style="color: #800000;">Total User Profiles available:</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #FF0000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">$UPManager</span><span style="color: #000000;">.Count
</span><span style="color: #800080;">$count</span><span style="color: #FF0000;">=</span><span style="color: #000000;">0</span><span style="color: #000000;">;

</span><span style="color: #008000;">#</span><span style="color: #008000;">Loop through every user who has an entry in the SSP</span><span style="color: #008000;">
</span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (</span><span style="color: #800080;">$oUser</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> </span><span style="color: #800080;">$enumProfiles</span><span style="color: #000000;">)
{
    </span><span style="color: #008000;">#</span><span style="color: #008000;">Get the username for the user</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #800080;">$u</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">.Item(</span><span style="color: #800000;">"</span><span style="color: #800000;">Accountname</span><span style="color: #800000;">"</span><span style="color: #000000;">)

    </span><span style="color: #008000;">#</span><span style="color: #008000;">How many have we activated?  If more than $userCount above stop processing</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #FF0000;">-ge</span><span style="color: #000000;"> </span><span style="color: #800080;">$userCount</span><span style="color: #000000;">) {
        Write-Output </span><span style="color: #800000;">"</span><span style="color: #800000;">Okay, we're stopping for now because we've activated for $userCount MySites</span><span style="color: #800000;">"</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">break</span><span style="color: #000000;">
    } </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> {

    </span><span style="color: #008000;">#</span><span style="color: #008000;">Does the user have a MySite?  If so continue</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800000;">'</span><span style="color: #800000;">PersonalSpace</span><span style="color: #800000;">'</span><span style="color: #000000;">].Value </span><span style="color: #FF0000;">-ne</span><span style="color: #000000;"> </span><span style="color: #800080;">$null</span><span style="color: #000000;">) {
        </span><span style="color: #008000;">#</span><span style="color: #008000;">Create an SPSite (Site Collection) and SPWeb (Web) object for the given users MySite</span><span style="color: #008000;">
</span><span style="color: #000000;">        </span><span style="color: #800080;">$siteurl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$mysiteurl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">$oUser</span><span style="color: #000000;">[</span><span style="color: #800000;">'</span><span style="color: #800000;">PersonalSpace</span><span style="color: #800000;">'</span><span style="color: #000000;">].Value
        </span><span style="color: #800080;">$spSite</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> new-object Microsoft.SharePoint.SPSite(</span><span style="color: #800080;">$siteurl</span><span style="color: #000000;">)
        </span><span style="color: #800080;">$spWeb</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$spSite</span><span style="color: #000000;">.OpenWeb() 

        </span><span style="color: #008000;">#</span><span style="color: #008000;">Let's check to see if either of the features we want to activate are currently activated.  </span><span style="color: #008000;">
</span><span style="color: #000000;">        </span><span style="color: #008000;">#</span><span style="color: #008000;">If not we should activate them.   Remember that the NewsGator Site Feature is "site" scoped thus we use SPWeb</span><span style="color: #008000;">
</span><span style="color: #000000;">        </span><span style="color: #008000;">#</span><span style="color: #008000;">The web part feature is Site Collection scoped so we have to use SPSite</span><span style="color: #008000;">
</span><span style="color: #000000;">        </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> ((</span><span style="color: #800080;">$spWeb</span><span style="color: #000000;">.Features[</span><span style="color: #800080;">$ngsite_feature_id</span><span style="color: #000000;">] </span><span style="color: #FF0000;">-eq</span><span style="color: #000000;"> </span><span style="color: #800080;">$null</span><span style="color: #000000;">) </span><span style="color: #FF0000;">-or</span><span style="color: #000000;"> (</span><span style="color: #800080;">$spSite</span><span style="color: #000000;">.Features[</span><span style="color: #800080;">$webpart_feature_id</span><span style="color: #000000;">] </span><span style="color: #FF0000;">-eq</span><span style="color: #000000;"> </span><span style="color: #800080;">$null</span><span style="color: #000000;">)) {

            </span><span style="color: #008000;">#</span><span style="color: #008000;">Execute STSADM -o activatefeature to activate the NewsGator Site Feature for this user, if it fails capture that and stop execution of the program.</span><span style="color: #008000;">
</span><span style="color: #000000;">            </span><span style="color: #800080;">$sResult</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> &amp;stsadm -o activatefeature -id </span><span style="color: #800080;">$ngsite_feature_id</span><span style="color: #000000;"> -force -url  </span><span style="color: #800080;">$siteurl</span><span style="color: #000000;">
            </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(</span><span style="color: #FF0000;">!</span><span style="color: #000000;">(</span><span style="color: #800080;">$sResult</span><span style="color: #000000;"> </span><span style="color: #FF0000;">-like</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">*Operation completed successfully*</span><span style="color: #800000;">"</span><span style="color: #000000;">)){
                Write-Host -ForegroundColor </span><span style="color: #800000;">"</span><span style="color: #800000;">red</span><span style="color: #800000;">"</span><span style="color: #000000;"> -BackgroundColor </span><span style="color: #800000;">"</span><span style="color: #800000;">white</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Activate of site upgrade feature failed for $u on $siteurl : `n $sResult</span><span style="color: #800000;">"</span><span style="color: #000000;">
                </span><span style="color: #0000FF;">break</span><span style="color: #000000;">
            }

            </span><span style="color: #008000;">#</span><span style="color: #008000;">Execute STSADM -o activatefeature to activate the Webpart deployment feature, if it fails capture that and stop execution</span><span style="color: #008000;">
</span><span style="color: #000000;">            </span><span style="color: #800080;">$sResult</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> &amp;stsadm -o activatefeature -id </span><span style="color: #800080;">$webpart_feature_id</span><span style="color: #000000;"> -force -url  </span><span style="color: #800080;">$siteurl</span><span style="color: #000000;">
            </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(</span><span style="color: #FF0000;">!</span><span style="color: #000000;">(</span><span style="color: #800080;">$sResult</span><span style="color: #000000;"> </span><span style="color: #FF0000;">-like</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">*Operation completed successfully*</span><span style="color: #800000;">"</span><span style="color: #000000;">)){
                Write-Host -ForegroundColor </span><span style="color: #800000;">"</span><span style="color: #800000;">red</span><span style="color: #800000;">"</span><span style="color: #000000;"> -BackgroundColor </span><span style="color: #800000;">"</span><span style="color: #800000;">white</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Activate of mysite web parts feature failed for $u on $siteurl : `n $sResult</span><span style="color: #800000;">"</span><span style="color: #000000;">
                </span><span style="color: #0000FF;">break</span><span style="color: #000000;">
            }

            </span><span style="color: #008000;">#</span><span style="color: #008000;">increment the count and output a status</span><span style="color: #008000;">
</span><span style="color: #000000;">            </span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$count</span><span style="color: #000000;"> </span><span style="color: #FF0000;">+</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">;
            Write-Output </span><span style="color: #800000;">"</span><span style="color: #800000;">($count):  Features activated on $siteurl for $u succesfully</span><span style="color: #800000;">"</span><span style="color: #000000;">;
        } </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> {
            Write-Output </span><span style="color: #800000;">"</span><span style="color: #800000;">Skipping $siteurl for $u as they are already active.</span><span style="color: #800000;">"</span><span style="color: #000000;">
        }
    } </span><span style="color: #0000FF;">else</span><span style="color: #000000;"> {
        Write-Output </span><span style="color: #800000;">"</span><span style="color: #800000;">Skipping $siteurl for $u as they do not have a MySite.</span><span style="color: #800000;">"</span><span style="color: #000000;">
    }

    </span><span style="color: #008000;">#</span><span style="color: #008000;">Clean up our objects to prevent a memory leak</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #800080;">$spWeb</span><span style="color: #000000;">.Dispose();
    </span><span style="color: #800080;">$spSite</span><span style="color: #000000;">.Dispose();
    </span><span style="color: #800080;">$siteurl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$null</span><span style="color: #000000;">;
    }
} 

</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://vallery.net/2010/04/01/activating-features-in-bulk-on-the-mysite-with-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

