<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Adventures in SPWonderland. - PowerShell</title>
    <link>http://blogs.flexnetconsult.co.uk/colinbyrne/</link>
    <description>Taking apart and putting back together</description>
    <language>en-us</language>
    <copyright>Colin Byrne</copyright>
    <lastBuildDate>Tue, 16 Jun 2009 14:10:27 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>webparts@flexnetconsult.co.uk</managingEditor>
    <webMaster>webparts@flexnetconsult.co.uk</webMaster>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=fe815927-3c14-4837-94f7-41d6125f3345</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,fe815927-3c14-4837-94f7-41d6125f3345.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,fe815927-3c14-4837-94f7-41d6125f3345.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=fe815927-3c14-4837-94f7-41d6125f3345</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
You know how it is, you start developing a project and then 6 months later you look
back and realise you have to document everything you've produced. 
</p>
        <p>
I've just gone through that process and need a quick list of all the features ids
scattered around various subdirectories of a large project.
</p>
        <p>
sample:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;Feature
Id=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"886f12cf-97ca-4789-baf8-6f13f9f2cedf"</span> Title=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"PGPSO
Contract Management Project Upgrade"</span> Description=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Feature
that upgrades Project Sites for Contract Management."</span> Version=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"12.0.0.0"</span> Hidden=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FALSE"</span> Scope=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Web"</span> DefaultResourceFile=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"core"</span> ReceiverAssembly=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"PGPSO_CM_Project_Upgrade,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=aa0408b86137366a"</span> ReceiverClass=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"PGPSO_CM_Project_Upgrade.PGPSO_CM_Project_Upgrade"</span> xmlns=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/sharepoint/"</span>&gt;</span>
        </pre>
        <p>
Firing up Powershell navigating to the root of the solution folders and running
this command gets me the list 
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">gci
-recurse -filter feature.xml <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">%</span> {
$contents=get-content $_.fullname; $x=[XML]$contents; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"{0}
{1}"</span> -f $x.Feature.Id, $x.feature.title }</span>
        </pre>
        <p>
result:
</p>
        <p>
          <img src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/ListFeatures.png" border="0" />
        </p>
        <p>
 
</p>
        <p>
gci is an alias for get-childitem which allow you to recurse subfolders and provide
a filter parameter. Then use get-content to open the file, convert to an XML object
and then directly reference the Id and title of the feature.xml file.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=fe815927-3c14-4837-94f7-41d6125f3345" />
      </body>
      <title>PowerShell quickie: Extract the feature IDs used in large SharePoint projects</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,fe815927-3c14-4837-94f7-41d6125f3345.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2009/06/16/PowerShellQuickieExtractTheFeatureIDsUsedInLargeSharePointProjects.aspx</link>
      <pubDate>Tue, 16 Jun 2009 14:10:27 GMT</pubDate>
      <description>&lt;p&gt;
You know how it is, you start developing a project and then 6 months later you look
back and realise you have to document everything you've produced. 
&lt;/p&gt;
&lt;p&gt;
I've just gone through that process and need a quick list of all the features ids
scattered around various subdirectories of a large project.
&lt;/p&gt;
&lt;p&gt;
sample:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;Feature
Id=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"886f12cf-97ca-4789-baf8-6f13f9f2cedf"&lt;/span&gt; Title=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"PGPSO
Contract Management Project Upgrade"&lt;/span&gt; Description=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Feature
that upgrades Project Sites for Contract Management."&lt;/span&gt; Version=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"12.0.0.0"&lt;/span&gt; Hidden=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FALSE"&lt;/span&gt; Scope=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Web"&lt;/span&gt; DefaultResourceFile=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"core"&lt;/span&gt; ReceiverAssembly=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"PGPSO_CM_Project_Upgrade,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=aa0408b86137366a"&lt;/span&gt; ReceiverClass=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"PGPSO_CM_Project_Upgrade.PGPSO_CM_Project_Upgrade"&lt;/span&gt; xmlns=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/sharepoint/"&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Firing up Powershell&amp;nbsp;navigating to the root of the solution folders and running
this command gets me the list 
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;gci
-recurse -filter feature.xml &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;%&lt;/span&gt; {
$contents=get-content $_.fullname; $x=[XML]$contents; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"{0}
{1}"&lt;/span&gt; -f $x.Feature.Id, $x.feature.title }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
result:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/ListFeatures.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
gci is an alias for get-childitem which allow you to recurse subfolders and provide
a filter parameter. Then use get-content to open the file, convert to an XML object
and then directly reference the Id and title of the feature.xml file.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=fe815927-3c14-4837-94f7-41d6125f3345" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,fe815927-3c14-4837-94f7-41d6125f3345.aspx</comments>
      <category>PowerShell</category>
      <category>Sharepoint 2007</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=d3be1633-fe28-4b87-b5c5-37da791ae87a</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,d3be1633-fe28-4b87-b5c5-37da791ae87a.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,d3be1633-fe28-4b87-b5c5-37da791ae87a.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=d3be1633-fe28-4b87-b5c5-37da791ae87a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://www.ukusergroups.co.uk/index.html" target="_blank">UK Microsoft
User Groups</a> have organised another huge gathering at Microsoft Reading next week. 
</p>
        <p>
This time it's split over 2 days April 8th and 9th and features a lot of great sessions.
User groups that I'm active in such as the <a href="http://suguk.org" target="_blank">UK
SharePoint user group</a>, <a href="http://www.culminisconnections.com/sites/get-psuguk/default.aspx" target="_blank">PowerShell
user group</a> and the <a href="http://vistasquad.co.uk/" target="_blank">Vista squad</a> will
be there along with the user groups for Exchange, SQL Server and others.
</p>
        <p>
It's not often you get a host of experts on these subjects in one location so <a href="http://www.ukusergroups.co.uk/SessionTable.html" target="_blank">check
out the agenda</a> and see if any sessions take your fancy. 
</p>
        <p>
I'm doing a session on day 2 crossing over two groups SharePoint and PowerShell on
moving data in SharePoint using the Content Deployment API (aka Prime API) and PowerShell.
I'll go through some of the functions and cmdlets I've written to make moving data
easier, samples include moving list items, lists, webs and site collections within
and between farms.
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=d3be1633-fe28-4b87-b5c5-37da791ae87a" />
      </body>
      <title>UK Community Day at Microsoft Reading</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,d3be1633-fe28-4b87-b5c5-37da791ae87a.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2008/04/02/UKCommunityDayAtMicrosoftReading.aspx</link>
      <pubDate>Wed, 02 Apr 2008 13:28:02 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://www.ukusergroups.co.uk/index.html" target="_blank"&gt;UK Microsoft
User Groups&lt;/a&gt; have organised another huge gathering at Microsoft Reading next week. 
&lt;/p&gt;
&lt;p&gt;
This time it's split over 2 days April 8th and 9th and features a lot of great sessions.
User groups that I'm active in such as the &lt;a href="http://suguk.org" target="_blank"&gt;UK
SharePoint user group&lt;/a&gt;, &lt;a href="http://www.culminisconnections.com/sites/get-psuguk/default.aspx" target="_blank"&gt;PowerShell
user group&lt;/a&gt; and the &lt;a href="http://vistasquad.co.uk/" target="_blank"&gt;Vista squad&lt;/a&gt; will
be there along with the user groups for Exchange, SQL Server and others.
&lt;/p&gt;
&lt;p&gt;
It's not often you get a host of experts on these subjects in one location so &lt;a href="http://www.ukusergroups.co.uk/SessionTable.html" target="_blank"&gt;check
out the agenda&lt;/a&gt; and see if any sessions take your fancy. 
&lt;/p&gt;
&lt;p&gt;
I'm doing a session on day 2 crossing over two groups SharePoint and PowerShell on
moving data in SharePoint using the Content Deployment API (aka Prime API) and PowerShell.
I'll go through some of the functions and cmdlets I've written to make moving data
easier, samples include moving list items, lists, webs and site collections within
and between farms.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=d3be1633-fe28-4b87-b5c5-37da791ae87a" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,d3be1633-fe28-4b87-b5c5-37da791ae87a.aspx</comments>
      <category>PowerShell</category>
      <category>Sharepoint 2007</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=e76c4e80-587b-46ac-891e-d08d9ab785bb</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,e76c4e80-587b-46ac-891e-d08d9ab785bb.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,e76c4e80-587b-46ac-891e-d08d9ab785bb.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=e76c4e80-587b-46ac-891e-d08d9ab785bb</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=9" target="_blank">Zach
Rosenfield</a> has a nice post on calling WebServices from PowerShell. The steps are
pretty simple: generate a proxy cs file, compile it into a DLL and then load that
DLL up into Powershell AppDomain. 
</p>
        <p>
Well I've been doing some work with quite a few of the WebServices and I wanted to
compile all the proxys into a single DLL. 
</p>
        <p>
Use Zach's post to setup the PowerShell environment variables needed to call the Visual
Studio SDK utilities wsdl.exe and csc.exe
</p>
        <p>
Heres the script to compile all the available SharePoint Webservice's into one DLL.
</p>
        <p>
It simply enumerates all the ASMX files in the ISAPI directory and passes each item
in that list to WSDL.exe which generates the proxy cs files.
</p>
        <p>
You need to change the URL in this script to point to a valid SharePoint site and
make sure there are no other .cs files in the directory before running this script.
</p>
        <div>
          <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$asmxlist= dir <span style="color: #006080">"C:\Program
Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI"</span> *.asmx
| select name $asmxlist | <span style="color: #0000ff">foreach</span>-object { write-host <span style="color: #006080">"Generating
SharePoint Proxy Library for $($_.name)"</span> -foregroundcolor green $outputfilename=<span style="color: #006080">"FlexnetConsult.SharePoint.$($_.name).cs"</span> $namespace=[IO.Path]::GetFileNameWithoutExtension($_.name)
wsdl <span style="color: #006080">"http://portal.contoso.com/matters/sites/_vti_bin/$($_.name)"</span> /o:$outputfilename
/namespace:$namespace } write-host <span style="color: #006080">"Compiling SharePoint
Proxy Library"</span> -foregroundcolor green csc /t:library /out:FlexnetConsult.SharePoint.WebServices.dll
*.cs </pre>
        </div>
        <p>
 
</p>
        <p>
So the output should be something like this
</p>
        <p>
 
</p>
        <p>
          <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/image_2.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="447" alt="image" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/image_thumb.png" width="848" border="0" />
          </a>
        </p>
        <p>
 
</p>
        <p>
Now three of the WebServices generate an error SlideShow.asmx. FormserverProxy.asmx
and contentareatoolboxservice.asmx but as I'm unlikely to use them I'm not going to
worry about those.
</p>
        <p>
So now we have a DLL called FlexnetConsult.SharePoint.WebServices.dll in our directory
that we can use to call the (almost) any SharePoint Web Service. 
</p>
        <p>
I've attached the compiled dll and script.
</p>
        <p>
In my next post I'll use the DLL to do something I've wanted to do for ages and that's
list, add and delete Web Parts on a page using PowerShell. 
</p>
        <p>
Now your probably shouting, hey why not just call the object model and GetLimitedWebPartManager,
yep but that doesn't work as without a web.config and possibly a HttpContext all you
get back are Error WebParts as the WebPart safecontrollist cannot be accessed.
</p>
        <p>
  
</p>
        <div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:bdd73ff3-7ce5-4c77-b39b-9bf22a6af7b4" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">
          <p>
            <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/GenerateSharePointProxyLibrary.ps1" target="_blank">GenerateSharePointProxyLibrary.ps1</a>
          </p>
        </div>
  
<p></p><div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:8a96d3f8-dfc2-4e58-b57b-54555752ee91" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"><p><a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/FlexnetConsult.SharePoint.WebServices.dll" target="_blank">FlexnetConsult.SharePoint.WebServices.dll</a></p></div><img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=e76c4e80-587b-46ac-891e-d08d9ab785bb" /></body>
      <title>PowerShell: Generating a proxy for all the SharePoint WebServices</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,e76c4e80-587b-46ac-891e-d08d9ab785bb.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2008/03/21/PowerShellGeneratingAProxyForAllTheSharePointWebServices.aspx</link>
      <pubDate>Fri, 21 Mar 2008 19:59:44 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=9" target="_blank"&gt;Zach
Rosenfield&lt;/a&gt; has a nice post on calling WebServices from PowerShell. The steps are
pretty simple: generate a proxy cs file, compile it into a DLL and then load that
DLL up into Powershell AppDomain. 
&lt;/p&gt;
&lt;p&gt;
Well I've been doing some work with quite a few of the WebServices and I wanted to
compile all the proxys into a single DLL. 
&lt;/p&gt;
&lt;p&gt;
Use Zach's post to setup the PowerShell environment variables needed to call the Visual
Studio SDK utilities wsdl.exe and csc.exe
&lt;/p&gt;
&lt;p&gt;
Heres the script to compile all the available SharePoint Webservice's into one DLL.
&lt;/p&gt;
&lt;p&gt;
It simply enumerates all the ASMX files in the ISAPI directory and passes each item
in that list to WSDL.exe which generates the proxy cs files.
&lt;/p&gt;
&lt;p&gt;
You need to change the URL in this script to point to a valid SharePoint site and
make sure there are no other .cs files in the directory before running this script.
&lt;/p&gt;
&lt;div&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;$asmxlist= dir &lt;span style="color: #006080"&gt;"C:\Program
Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI"&lt;/span&gt; *.asmx
| select name $asmxlist | &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt;-object { write-host &lt;span style="color: #006080"&gt;"Generating
SharePoint Proxy Library for $($_.name)"&lt;/span&gt; -foregroundcolor green $outputfilename=&lt;span style="color: #006080"&gt;"FlexnetConsult.SharePoint.$($_.name).cs"&lt;/span&gt; $namespace=[IO.Path]::GetFileNameWithoutExtension($_.name)
wsdl &lt;span style="color: #006080"&gt;"http://portal.contoso.com/matters/sites/_vti_bin/$($_.name)"&lt;/span&gt; /o:$outputfilename
/namespace:$namespace } write-host &lt;span style="color: #006080"&gt;"Compiling SharePoint
Proxy Library"&lt;/span&gt; -foregroundcolor green csc /t:library /out:FlexnetConsult.SharePoint.WebServices.dll
*.cs &lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So the output should be something like this
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="447" alt="image" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/image_thumb.png" width="848" border="0"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now three of the WebServices generate an error SlideShow.asmx. FormserverProxy.asmx
and contentareatoolboxservice.asmx but as I'm unlikely to use them I'm not going to
worry about those.
&lt;/p&gt;
&lt;p&gt;
So now we have a DLL called FlexnetConsult.SharePoint.WebServices.dll in our directory
that we can use to call the (almost) any SharePoint Web Service. 
&lt;/p&gt;
&lt;p&gt;
I've attached the compiled dll and script.
&lt;/p&gt;
&lt;p&gt;
In my next post I'll use the DLL to do something I've wanted to do for ages and that's
list, add and delete Web Parts on a page using PowerShell. 
&lt;/p&gt;
&lt;p&gt;
Now your probably shouting, hey why not just call the object model and GetLimitedWebPartManager,
yep but that doesn't work as without a web.config and possibly a HttpContext all you
get back are Error WebParts as the WebPart safecontrollist cannot be accessed.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp; 
&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:bdd73ff3-7ce5-4c77-b39b-9bf22a6af7b4" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/GenerateSharePointProxyLibrary.ps1" target="_blank"&gt;GenerateSharePointProxyLibrary.ps1&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:8a96d3f8-dfc2-4e58-b57b-54555752ee91" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/PowerShellGeneratingaproxyforalltheShare_11675/FlexnetConsult.SharePoint.WebServices.dll" target="_blank"&gt;FlexnetConsult.SharePoint.WebServices.dll&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=e76c4e80-587b-46ac-891e-d08d9ab785bb" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,e76c4e80-587b-46ac-891e-d08d9ab785bb.aspx</comments>
      <category>PowerShell</category>
      <category>Sharepoint 2007</category>
      <category>WebParts</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=5c6f6021-c6b1-468a-a60a-53250cc86b0b</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,5c6f6021-c6b1-468a-a60a-53250cc86b0b.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,5c6f6021-c6b1-468a-a60a-53250cc86b0b.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=5c6f6021-c6b1-468a-a60a-53250cc86b0b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I forgot to post this before but Microsoft has created a virtual lab based on my blog
postings. If you're interested in Powershell and SharePoint its definitely worth checking
out
</p>
        <p>
          <a title="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032346304&amp;EventCategory=3&amp;culture=en-US&amp;CountryCode=US" href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032346304&amp;EventCategory=3&amp;culture=en-US&amp;CountryCode=US">http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032346304&amp;EventCategory=3&amp;culture=en-US&amp;CountryCode=US</a>
        </p>
        <p>
As noted on Ben Pierce's blog Powershell is now a CER common engineering requirement
for all products released in 2009 and beyond, that should mean as Office 14 is due
for release in 2009 PowerShell should be a mandatory feature in SharePoint. 
</p>
        <p>
Thats good news and a big change as when I'd asked the question about PowerShell support
in SharePoint to Mike Fitzmaurice back in February last year the answer was they had
no plan to do so.
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=5c6f6021-c6b1-468a-a60a-53250cc86b0b" />
      </body>
      <title>Sharepoint and Powershell Virtual lab</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,5c6f6021-c6b1-468a-a60a-53250cc86b0b.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2008/02/25/SharepointAndPowershellVirtualLab.aspx</link>
      <pubDate>Mon, 25 Feb 2008 12:12:27 GMT</pubDate>
      <description>&lt;p&gt;
I forgot to post this before but Microsoft has created a virtual lab based on my blog
postings. If you're interested in Powershell and SharePoint its definitely worth checking
out
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032346304&amp;amp;EventCategory=3&amp;amp;culture=en-US&amp;amp;CountryCode=US" href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032346304&amp;amp;EventCategory=3&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032346304&amp;amp;EventCategory=3&amp;amp;culture=en-US&amp;amp;CountryCode=US&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
As noted on Ben Pierce's blog Powershell is now a CER common engineering requirement
for all products released in 2009 and beyond, that should mean as Office 14 is due
for release in 2009 PowerShell should be a mandatory feature in SharePoint. 
&lt;/p&gt;
&lt;p&gt;
Thats good news and a big change as when I'd asked the question about PowerShell support
in SharePoint to Mike Fitzmaurice back in February last year the answer was they had
no plan to do so.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=5c6f6021-c6b1-468a-a60a-53250cc86b0b" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,5c6f6021-c6b1-468a-a60a-53250cc86b0b.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=5180cfd7-2294-416f-b231-79e9037f4443</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,5180cfd7-2294-416f-b231-79e9037f4443.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,5180cfd7-2294-416f-b231-79e9037f4443.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=5180cfd7-2294-416f-b231-79e9037f4443</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m presenting at the EVO (Exchange, Vista, Office) Community day next Thursday the
21st June.
</p>
        <p>
          <br />
I’ll be doing a session that shows how you can use Powershell to read information
from Exchange and getting it into SharePoint 2007. 
<br />
Its really hard to know how to pitch a presentation like this as the mix of experiences
is probably going to be wide, from people seeing this stuff for the first time to
old hands. Anyway I’m looking forward to it. 
</p>
        <p>
The talk will cover some Powershell basics, calling the new Exchange Web Services
from PowerShell and why we might still need to use WebDAV(hint Public Folders) and
of course how we write to SharePoint. 
<br />
I'll start posting some of the code samples over the next week.
</p>
        <p>
There’s lots of other sessions including ones from <a href="http://suguk.org/blogs/combined_knowledge/default.aspx">Steve
Smith</a> on SharePoint and <a href="http://richardsiddaway.spaces.live.com/">Richard
Siddaway</a> on PowerShell, should be a good one.
</p>
        <p>
Heres the details of the Event:<br />
The Next EVO Community Day - June 21st: Microsoft Campus Thames Valley Park Reading<br /></p>
        <p>
Event Agenda<br />
09:30 Start<br />
09:30 - 10:00 Keynote<br />
10:00 - 10:25 Introductions to groups (Including LiveMeeting, Longhorn, Virtualisation)<br />
10:25 - 10:55 Vista<br />
10:55 - 11:10 Break<br />
11:10 - 12:40 Office, SharePoint, Groove<br />
12:40 - 13:25 Lunch<br />
13:25 - 14:55 Break-out sessions<br />
14:55 - 15:10 Break<br />
15:10 - 15:40 OCS + UM<br />
15:40 - 16:40 Exchange and PowerShell<br />
16:40 - 16:55 Break<br />
16:55 - 17:30 Q&amp;A
</p>
        <p>
Further agenda information can be found here:  <a href="http://www.ukusergroups.co.uk/Agenda.html">http://www.ukusergroups.co.uk/Agenda.html</a></p>
        <p>
To sign up and more information: <a href="http://www.ukusergroups.co.uk/">http://www.ukusergroups.co.uk/</a></p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=5180cfd7-2294-416f-b231-79e9037f4443" />
      </body>
      <title>EVO Community Day - June 21st: Microsoft Campus Thames Valley Park Reading</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,5180cfd7-2294-416f-b231-79e9037f4443.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2007/06/15/EVOCommunityDayJune21stMicrosoftCampusThamesValleyParkReading.aspx</link>
      <pubDate>Fri, 15 Jun 2007 09:57:30 GMT</pubDate>
      <description>&lt;p&gt;
I’m presenting at the EVO (Exchange, Vista, Office) Community day next Thursday the
21st June.
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
I’ll be doing a session that shows how you can use Powershell to read information
from Exchange and getting it into SharePoint 2007. 
&lt;br&gt;
Its really hard to know how to pitch a presentation like this as the mix of experiences
is probably going to be wide, from people seeing this stuff for the first time to
old hands. Anyway I’m looking forward to it. 
&lt;/p&gt;
&lt;p&gt;
The talk will cover some Powershell basics, calling the new Exchange Web Services
from PowerShell and why we might still need to use WebDAV(hint Public Folders) and
of course how we write to SharePoint. 
&lt;br&gt;
I'll start posting some of the code samples over the next week.
&lt;/p&gt;
&lt;p&gt;
There’s lots of other sessions including ones from &lt;a href="http://suguk.org/blogs/combined_knowledge/default.aspx"&gt;Steve
Smith&lt;/a&gt; on SharePoint and &lt;a href="http://richardsiddaway.spaces.live.com/"&gt;Richard
Siddaway&lt;/a&gt;&amp;nbsp;on PowerShell, should be a good one.
&lt;/p&gt;
&lt;p&gt;
Heres the details of the Event:&lt;br&gt;
The Next EVO Community Day - June 21st: Microsoft Campus Thames Valley Park Reading&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Event Agenda&lt;br&gt;
09:30 Start&lt;br&gt;
09:30 - 10:00 Keynote&lt;br&gt;
10:00 - 10:25 Introductions to groups (Including LiveMeeting, Longhorn, Virtualisation)&lt;br&gt;
10:25 - 10:55 Vista&lt;br&gt;
10:55 - 11:10 Break&lt;br&gt;
11:10 - 12:40 Office, SharePoint, Groove&lt;br&gt;
12:40 - 13:25 Lunch&lt;br&gt;
13:25 - 14:55 Break-out sessions&lt;br&gt;
14:55 - 15:10 Break&lt;br&gt;
15:10 - 15:40 OCS + UM&lt;br&gt;
15:40 - 16:40 Exchange and PowerShell&lt;br&gt;
16:40 - 16:55 Break&lt;br&gt;
16:55 - 17:30 Q&amp;amp;A
&lt;/p&gt;
&lt;p&gt;
Further agenda information can be found here:&amp;nbsp; &lt;a href="http://www.ukusergroups.co.uk/Agenda.html"&gt;http://www.ukusergroups.co.uk/Agenda.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
To sign up and more information: &lt;a href="http://www.ukusergroups.co.uk/"&gt;http://www.ukusergroups.co.uk/&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=5180cfd7-2294-416f-b231-79e9037f4443" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,5180cfd7-2294-416f-b231-79e9037f4443.aspx</comments>
      <category>Office 2007</category>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=fa33d522-a91f-43db-98fb-e51acd91b373</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,fa33d522-a91f-43db-98fb-e51acd91b373.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,fa33d522-a91f-43db-98fb-e51acd91b373.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=fa33d522-a91f-43db-98fb-e51acd91b373</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
I’m presenting at the next <a href="http://www.culminisconnections.com/sites/get-psuguk/default.aspx">UK
PowerShell User Group</a> meeting on March 22nd doing an updated talk around using
PowerShell with SharePoint featuring an intro to PowerShell,  Demos and roundup
with SharePoint/PowerShell gotchas and 'tips and tricks'. 
</p>
        <p>
The talk should be be of interest of anyone who might like to talk to a managed
API with Powershell.<br /></p>
        <p>
I’m doing the first talk and <a href="http://richardsiddaway.spaces.live.com/">Richard
Siddaway</a> is doing the second session with a talk on using ActiveDirectory with
PowerShell. 
<br />
If you need an intro to using PowerShell or want or ask more advanced questions this
will be a good place to be.
</p>
        <p>
          <strong>Location:</strong>
          <br />
Memphis Room 
<br />
Microsoft Building 3 
<br />
Thames Valley Park 
<br />
Reading 
</p>
        <p>
Registration 18:00 
<br />
Start           18:30
</p>
        <p>
You need to register for attendance so follow the instructions in this link: <a href="http://www.culminisconnections.com/sites/get-psuguk/Lists/Events/DispForm.aspx?ID=2">http://www.culminisconnections.com/sites/get-psuguk/Lists/Events/DispForm.aspx?ID=2</a></p>
        <p>
Hope to see you there.<br /></p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=fa33d522-a91f-43db-98fb-e51acd91b373" />
      </body>
      <title>Presenting at the UK PowerShell User Group 22 March Meeting</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,fa33d522-a91f-43db-98fb-e51acd91b373.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2007/03/14/PresentingAtTheUKPowerShellUserGroup22MarchMeeting.aspx</link>
      <pubDate>Wed, 14 Mar 2007 14:29:09 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
I’m presenting at the next &lt;a href="http://www.culminisconnections.com/sites/get-psuguk/default.aspx"&gt;UK
PowerShell User Group&lt;/a&gt; meeting on March 22nd doing an updated talk around using
PowerShell with SharePoint featuring an intro to PowerShell,&amp;nbsp; Demos and roundup
with SharePoint/PowerShell gotchas and 'tips and tricks'. 
&lt;/p&gt;
&lt;p&gt;
The&amp;nbsp;talk should be be of interest of anyone who might like to talk to a managed
API with Powershell.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
I’m doing the first talk and &lt;a href="http://richardsiddaway.spaces.live.com/"&gt;Richard
Siddaway&lt;/a&gt; is doing the second session with a talk on using ActiveDirectory with
PowerShell. 
&lt;br&gt;
If you need an intro to using PowerShell or want or ask more advanced questions this
will be a good place to be.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Location:&lt;/strong&gt;
&lt;br&gt;
Memphis Room 
&lt;br&gt;
Microsoft Building 3 
&lt;br&gt;
Thames Valley Park 
&lt;br&gt;
Reading 
&lt;/p&gt;
&lt;p&gt;
Registration 18:00 
&lt;br&gt;
Start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 18:30
&lt;/p&gt;
&lt;p&gt;
You need to register for attendance so follow the instructions in this link: &lt;a href="http://www.culminisconnections.com/sites/get-psuguk/Lists/Events/DispForm.aspx?ID=2"&gt;http://www.culminisconnections.com/sites/get-psuguk/Lists/Events/DispForm.aspx?ID=2&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Hope to see you there.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=fa33d522-a91f-43db-98fb-e51acd91b373" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,fa33d522-a91f-43db-98fb-e51acd91b373.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=cbad89bd-f36a-40dd-9750-ec69665b2504</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,cbad89bd-f36a-40dd-9750-ec69665b2504.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,cbad89bd-f36a-40dd-9750-ec69665b2504.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=cbad89bd-f36a-40dd-9750-ec69665b2504</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
 
</p>
        <p>
Following on from the work in my previous post where I set the users Picture property
in their profile the next step is to add a Contact Web Part to our imported publishing
pages. I’m using the default layout page to add the contact Web Part to, this page
has the Web Part Zones underneath the content fields but you could use another layout
that has a Web Part zones to the right of the content fields and of course you can
use SharePoint Designer to create your own layout formats and embed the Contact control
without using code. 
</p>
        <p>
This is how our publishing pages will look once we have added the Web Part to each
page
</p>
        <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageWithPicture4.gif" atomicselection="true">
          <img height="539" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageWithPicture_thumb2.gif" width="818" />
        </a>
        <p>
        </p>
        <p>
An interesting feature of a Publishing page is that it has a contact property
where you can assign user details to each page, you can either lookup the user from
the picker in which case the page will pull the users details from the profile database
or you can type in the details yourself.
</p>
        <p>
          <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageSetContact3.gif" atomicselection="true">
            <img height="559" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageSetContact_thumb1.gif" width="819" />
          </a>
        </p>
        <p>
 
</p>
        <p>
The nice thing about the Contact Web Part is that once you have added it to a publishing
page it will automatically pull the picture and the users description (if set in the
Web Part) that has been assigned to the page from the profile database. 
</p>
        <p>
One bad thing about the part is you only get the choice to put the users name left
or right not top or bottom.
</p>
        <p>
So on to the code, I need a function that will take a site URL and then set the default
Publishing Page’s contact property and then add the Web Part to the page. 
</p>
        <p>
  
</p>
        <p>
 
</p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:78a7f32e-0503-478d-8d7b-5209d97a76b5" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
          <pre style="background-color:White;">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="color: #000000; ">#
Function: Add</span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; ">ContactWebPart
# Description: Adds the Contact User Web Part to a publishing page # Parameters: SiteURL </span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; "> Server
relative URL of the Area # UserName </span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; "> UserName
to show </span>
              <span style="color: #0000FF; ">as</span>
              <span style="color: #000000; "> the
contact </span>
              <span style="color: #0000FF; ">in</span>
              <span style="color: #000000; "> domain\user
format # # Requirements: Needs to have the System.Web assembly loaded # function Add</span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; ">ContactWebPart($SiteURL,
$UserName) { $comment </span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">Contact
WebPart Added</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> $site </span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #0000FF; ">new</span>
              <span style="color: #000000; ">-</span>
              <span style="color: #0000FF; ">object</span>
              <span style="color: #000000; "> Microsoft.sharePoint.SPSite($SiteURL)
$web</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">$site.OpenWeb()
$user</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; "> $web.Users.get_item($UserName)
$pubweb </span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; "> [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$defaultpage</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">$pubweb.GetPublishingPages()[$pubweb.DefaultPage]
$defaultpage.CheckOut() # Set Contact </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">Setting
Contact on </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #000000; ">+</span>
              <span style="color: #000000; "> $pubweb.url </span>
              <span style="color: #000000; ">+</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> to </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #000000; ">+</span>
              <span style="color: #000000; "> $user.Name
$defaultpage.set_Contact($user) $defaultpage.Update() $webpartmanager</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">$web.GetLimitedWebPartManager($defaultpage.Url,
[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) $webpart</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #0000FF; ">new</span>
              <span style="color: #000000; ">-</span>
              <span style="color: #0000FF; ">object</span>
              <span style="color: #000000; "> Microsoft.SharePoint.Portal.WebControls.ContactFieldControl
$webpart.ChromeType</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">[System.Web.UI.WebControls.WebParts.PartChromeType]::TitleOnly;
$webpart.Title</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">Page
Contact</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> $webpart.PicturePosition</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">[Microsoft.SharePoint.Portal.WebControls.PictureDirection]::Left
$webpart.IsDisplayJobTitle</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">$</span>
              <span style="color: #0000FF; ">true</span>
              <span style="color: #000000; "> $webpart.IsDisplayPicture</span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; ">$</span>
              <span style="color: #0000FF; ">true</span>
              <span style="color: #000000; "> $webpartmanager.AddWebPart($webpart, </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">LeftColumnZone</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">, </span>
              <span style="color: #000000; ">0</span>
              <span style="color: #000000; ">); </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> Checking
in page</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> $defaultpage.CheckIn($comment)
# Publish </span>
              <span style="color: #0000FF; ">if</span>
              <span style="color: #000000; ">($defaultpage.listItem.ParentList.EnableMinorVersions </span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; ">eq
$</span>
              <span style="color: #0000FF; ">true</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; ">and
$publishingPage.ListItem.File.MinorVersion </span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; ">ne </span>
              <span style="color: #000000; ">0</span>
              <span style="color: #000000; ">)
{ </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> Publishing</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> $defaultpage.listItem.File.Publish($comment)
} # If moderation </span>
              <span style="color: #0000FF; ">is</span>
              <span style="color: #000000; "> being
used handle the approval </span>
              <span style="color: #0000FF; ">if</span>
              <span style="color: #000000; "> ($defaultpage.listItem.ParentList.EnableModeration)
{ $modInformation </span>
              <span style="color: #000000; ">=</span>
              <span style="color: #000000; "> $defaultpage.listItem.ModerationInformation </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> Moderation
on, Current Status: </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; ">
              </span>
              <span style="color: #000000; ">+</span>
              <span style="color: #000000; "> $modInformation.Status
# Check </span>
              <span style="color: #0000FF; ">for</span>
              <span style="color: #000000; "> pending
approval </span>
              <span style="color: #0000FF; ">if</span>
              <span style="color: #000000; ">($modInformation.Status </span>
              <span style="color: #000000; ">-</span>
              <span style="color: #000000; ">ne
[Microsoft.SharePoint.SPModerationStatusType]::Approved) { </span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> Approving</span>
              <span style="color: #000000; ">"</span>
              <span style="color: #000000; "> $defaultpage.ListItem.File.Approve($comment)
} } # Clean up $pubweb.Close() $web.Close() $site.Close() } </span>
            </div>
          </pre>
        </div>
        <p>
 
</p>
        <p>
In this code we find the SPUser object for the given username and set the Contact
property of the PublishingPage to it. We then add the web Part using the new SPLimitedWebPartManager
class. Most of the code is concerned with checking the page out and back in and assumes
the page is not already checked out.
</p>
        <p>
An interesting line is 
</p>
        <p>
$defaultpage=$pubweb.GetPublishingPages()[$pubweb.DefaultPage] 
</p>
        <p>
I'm indexing into the collection return by GetPublishingPages because Powershell doesn't
support generics in the current version.
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=cbad89bd-f36a-40dd-9750-ec69665b2504" />
      </body>
      <title>SharePoint/PowerShell 8: The one with the Contact Web Part</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,cbad89bd-f36a-40dd-9750-ec69665b2504.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2007/02/10/SharePointPowerShell8TheOneWithTheContactWebPart.aspx</link>
      <pubDate>Sat, 10 Feb 2007 20:17:59 GMT</pubDate>
      <description>&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Following on from the work in my previous post where I set the users Picture property
in their profile the next step is to add a Contact Web Part to our imported publishing
pages. I’m using the default layout page to add the contact Web Part to, this page
has the Web Part Zones underneath the content fields but you could use another layout
that has a Web Part zones to the right of the content fields and of course you can
use SharePoint Designer to create your own layout formats and embed the Contact control
without using code. 
&lt;p&gt;
This is how our publishing pages will look once we have added the Web Part to each
page
&lt;/p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageWithPicture4.gif" atomicselection="true"&gt;&lt;img height="539" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageWithPicture_thumb2.gif" width="818"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
An interesting feature&amp;nbsp;of a Publishing page is that it has a contact property
where you can assign user details to each page, you can either lookup the user from
the picker in which case the page will pull the users details from the profile database
or you can type in the details yourself.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageSetContact3.gif" atomicselection="true"&gt;&lt;img height="559" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell8TheonewiththeContac_106E6/ContentPageSetContact_thumb1.gif" width="819"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The nice thing about the Contact Web Part is that once you have added it to a publishing
page it will automatically pull the picture and the users description (if set in the
Web Part) that has been assigned to the page from the profile database. 
&lt;/p&gt;
&lt;p&gt;
One bad thing about the part is you only get the choice to put the users name left
or right not top or bottom.
&lt;/p&gt;
&lt;p&gt;
So on to the code, I need a function that will take a site URL and then set the default
Publishing Page’s contact property and then add the Web Part to the page. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:78a7f32e-0503-478d-8d7b-5209d97a76b5" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #000000; "&gt;#
Function: Add&lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt;ContactWebPart
# Description: Adds the Contact User Web Part to a publishing page # Parameters: SiteURL &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt; Server
relative URL of the Area # UserName &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt; UserName
to show &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;as&lt;/span&gt;&lt;span style="color: #000000; "&gt; the
contact &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;in&lt;/span&gt;&lt;span style="color: #000000; "&gt; domain\user
format # # Requirements: Needs to have the System.Web assembly loaded # function Add&lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt;ContactWebPart($SiteURL,
$UserName) { $comment &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;Contact
WebPart Added&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; $site &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;new&lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;object&lt;/span&gt;&lt;span style="color: #000000; "&gt; Microsoft.sharePoint.SPSite($SiteURL)
$web&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;$site.OpenWeb()
$user&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; $web.Users.get_item($UserName)
$pubweb &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$defaultpage&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;$pubweb.GetPublishingPages()[$pubweb.DefaultPage]
$defaultpage.CheckOut() # Set Contact &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;Setting
Contact on &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; $pubweb.url &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; to &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; $user.Name
$defaultpage.set_Contact($user) $defaultpage.Update() $webpartmanager&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;$web.GetLimitedWebPartManager($defaultpage.Url,
[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) $webpart&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;new&lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;object&lt;/span&gt;&lt;span style="color: #000000; "&gt; Microsoft.SharePoint.Portal.WebControls.ContactFieldControl
$webpart.ChromeType&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;[System.Web.UI.WebControls.WebParts.PartChromeType]::TitleOnly;
$webpart.Title&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;Page
Contact&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; $webpart.PicturePosition&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;[Microsoft.SharePoint.Portal.WebControls.PictureDirection]::Left
$webpart.IsDisplayJobTitle&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;$&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;true&lt;/span&gt;&lt;span style="color: #000000; "&gt; $webpart.IsDisplayPicture&lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt;$&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;true&lt;/span&gt;&lt;span style="color: #000000; "&gt; $webpartmanager.AddWebPart($webpart, &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;LeftColumnZone&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt;, &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;); &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; Checking
in page&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; $defaultpage.CheckIn($comment)
# Publish &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;if&lt;/span&gt;&lt;span style="color: #000000; "&gt;($defaultpage.listItem.ParentList.EnableMinorVersions &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt;eq
$&lt;/span&gt;&lt;span style="color: #0000FF; "&gt;true&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt;and
$publishingPage.ListItem.File.MinorVersion &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt;ne &lt;/span&gt;&lt;span style="color: #000000; "&gt;0&lt;/span&gt;&lt;span style="color: #000000; "&gt;)
{ &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; Publishing&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; $defaultpage.listItem.File.Publish($comment)
} # If moderation &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;is&lt;/span&gt;&lt;span style="color: #000000; "&gt; being
used handle the approval &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;if&lt;/span&gt;&lt;span style="color: #000000; "&gt; ($defaultpage.listItem.ParentList.EnableModeration)
{ $modInformation &lt;/span&gt;&lt;span style="color: #000000; "&gt;=&lt;/span&gt;&lt;span style="color: #000000; "&gt; $defaultpage.listItem.ModerationInformation &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; Moderation
on, Current Status: &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; &lt;/span&gt;&lt;span style="color: #000000; "&gt;+&lt;/span&gt;&lt;span style="color: #000000; "&gt; $modInformation.Status
# Check &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;for&lt;/span&gt;&lt;span style="color: #000000; "&gt; pending
approval &lt;/span&gt;&lt;span style="color: #0000FF; "&gt;if&lt;/span&gt;&lt;span style="color: #000000; "&gt;($modInformation.Status &lt;/span&gt;&lt;span style="color: #000000; "&gt;-&lt;/span&gt;&lt;span style="color: #000000; "&gt;ne
[Microsoft.SharePoint.SPModerationStatusType]::Approved) { &lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; Approving&lt;/span&gt;&lt;span style="color: #000000; "&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; "&gt; $defaultpage.ListItem.File.Approve($comment)
} } # Clean up $pubweb.Close() $web.Close() $site.Close() } &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
In this code we find the SPUser object for the given username and set the Contact
property of the PublishingPage to it. We then add the web Part using the new SPLimitedWebPartManager
class. Most of the code is concerned with checking the page out and back in and assumes
the page is not already checked out.
&lt;/p&gt;
&lt;p&gt;
An interesting line is 
&lt;/p&gt;
&lt;p&gt;
$defaultpage=$pubweb.GetPublishingPages()[$pubweb.DefaultPage] 
&lt;p&gt;
I'm indexing into the collection return by GetPublishingPages because Powershell doesn't
support generics in the current version.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=cbad89bd-f36a-40dd-9750-ec69665b2504" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,cbad89bd-f36a-40dd-9750-ec69665b2504.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
      <category>WebParts</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=a332015d-c5dc-4433-a0f3-247fd37b0b04</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a332015d-c5dc-4433-a0f3-247fd37b0b04.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,a332015d-c5dc-4433-a0f3-247fd37b0b04.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=a332015d-c5dc-4433-a0f3-247fd37b0b04</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
Now we have the portal setup I want to add a Contact WebPart to each page but before
I can do that I have to add a picture for each user I have imported, in order to keep
this post a little shorter I’m only going to concentrate on using the UserProfile
API’s to set our picture for each user.<br />
(The Contact WebPart is MOSS WebPart that shows a users name and description and optionally
their picture)<br />
The field that we are going to set programmatically is accessed on the Users edit
profile page as Picture: 
</p>
        <p>
        </p>
        <p>
          <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BrianB_Profile%5B7%5D.gif" atomicselection="true">
            <img height="301" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BrianB_Profile_thumb%5B5%5D.gif" width="700" />
          </a>
        </p>
        <p>
Once set this will display the picture on the user profile like this
</p>
        <p>
          <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BriansPersonalSite%5B4%5D.gif" atomicselection="true">
            <img height="504" src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BriansPersonalSite_thumb%5B2%5D.gif" width="660" />
          </a>
        </p>
        <p>
          <br />
To do this I need to revisit our User.csv import file and add an extra field that
gives the name of the JPG file that holds the users picture.<br />
I’m going to assume that the previous blog post <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a326572f-8f78-4c80-86d5-1fe52cbd6fe5.aspx">Upload
a directory of files in 4 lines</a> has already uploaded the users picture to the
SiteCollectionImages picture library, in real life you’d probably use a separate picture
library. 
</p>
        <p>
          <br />
Ideally a profile import has occurred after we have added the users to Active Directory
and populated the SharePoint profile database. 
<br /></p>
        <p>
Now to set the Users Picture property we know to know the Property Name of the Picture
Field.<br />
To make this easy to find out here’s the first function for our toolbox Get-SPUserProfileConfigManager. 
<br />
This function returns a UserProfileConfigManager (<a href="http://msdn2.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofileconfigmanager.aspx)">http://msdn2.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofileconfigmanager.aspx)</a>,
note this is the new class that resides in the Microsoft.Office.Server namespace not
the v2 obsolete one that lives in Microsoft.sharePoint.Portal.UserProfiles.<br />
Also ignore the sample currently given in the MSDN documentation above, it won’t work
as it uses the old classes where you pass a PortalContext to the constructor whereas
the new version of the classes take a ServerContext object.
</p>
        <p>
 
</p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:f03c9c5a-cb1a-407f-b4a6-7b3d8391bdb7" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000"> #
Function: Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserProfileConfigManager
# Description: </span>
              <span style="COLOR: #0000ff">return</span>
              <span style="COLOR: #000000"> a
UserProfileConfigManager </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> which </span>
              <span style="COLOR: #0000ff">is</span>
              <span style="COLOR: #000000"> used </span>
              <span style="COLOR: #0000ff">for</span>
              <span style="COLOR: #000000"> management
of MOSS User Profiles # Parameters: PortalURL URL </span>
              <span style="COLOR: #0000ff">for</span>
              <span style="COLOR: #000000"> the
Portal Site Collection # # function Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserProfileConfigManager([</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]$PortalURL)
{ # Need to </span>
              <span style="COLOR: #0000ff">get</span>
              <span style="COLOR: #000000"> a
PortalContext </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> # </span>
              <span style="COLOR: #0000ff">as</span>
              <span style="COLOR: #000000"> we </span>
              <span style="COLOR: #0000ff">do</span>
              <span style="COLOR: #000000"> not
have a HttpContext we need to source one the hard way $site</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #0000ff">new</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> Microsoft.SharePoint.SPSite($PortalURL)
$servercontext</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000">[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up # Return the UserProfileConfigManager </span>
              <span style="COLOR: #0000ff">new</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> Microsoft.Office.Server.UserProfiles.UserProfileConfigmanager($servercontext)
}</span>
            </div>
          </pre>
        </div>
        <p>
        </p>
        <p>
        </p>
        <p>
 
</p>
        <p>
Once we get the UserProfileConfigManager we can call GetProperties and list the internal
and display names for each profile property 
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:df4400ea-56bc-45b0-8597-9d03eebc6046" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: white">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">$cm</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #0000ff">get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">userprofileconfigmanager </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">http://sps:2828</span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000"> $cm.getproperties() </span>
              <span style="COLOR: #000000">|</span>
              <span style="COLOR: #000000"> select
name, displayname Name DisplayName </span>
              <span style="COLOR: #000000">----</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">-----------</span>
              <span style="COLOR: #000000"> UserProfile_GUID
Id SID SID ADGuid Active Directory Id AccountName Account name FirstName First name
LastName Last name PreferredName Name WorkPhone Work phone Office Office Department
Department Title Title Manager Manager AboutMe About me PersonalSpace Personal site
PictureURL Picture UserName User name QuickLinks Quick links WebSite Web site PublicSiteRedirect
Public site redirect SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Dotted</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">line
Dotted</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">line
Manager SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Peers
Peers SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Responsibility
Responsibilities SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Skills
Skills SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">PastProjects
Past projects SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Interests
Interests SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">School
Schools SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SipAddress
SIP Address SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Birthday
Birthday SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">MySiteUpgrade
My Site Upgrade SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">DontSuggestList
Don</span>
              <span style="COLOR: #000000">'</span>
              <span style="COLOR: #000000">t Suggest
List </span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">ProxyAddresses
Proxy addresses SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">HireDate
Hire date SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">LastColleagueAdded
Last Colleague Added SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">OWAUrl
Outlook Web Access URL SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">ResourceSID
Resource Forest SID SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">ResourceAccountName
Resource Forest Account Name SPS</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">MasterAccountName
Master Account Name Assistant Assistant WorkEmail Work e</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">mail
CellPhone Mobile phone Fax Fax HomePhone Home phone </span>
            </div>
          </pre>
        </div>
        <p>
        </p>
        <p>
So from this list I see that I need to set the PictureURL property, to get
a UserProfile we first need a UserProfileManager object: 
</p>
        <p>
        </p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:7c115796-d7b7-4db2-ba54-61b544e8f4f8" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">#
Function: Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SPProfileManager
# Description: Return a UserProfileManager </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> which </span>
              <span style="COLOR: #0000ff">is</span>
              <span style="COLOR: #000000"> used </span>
              <span style="COLOR: #0000ff">for</span>
              <span style="COLOR: #000000"> accessing
MOSS User Profiles # Parameters: PortalURL URL </span>
              <span style="COLOR: #0000ff">for</span>
              <span style="COLOR: #000000"> the
Portal Site Collection # function Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SPProfileManager([</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]$PortalURL)
{ # Need to </span>
              <span style="COLOR: #0000ff">get</span>
              <span style="COLOR: #000000"> a
PortalContext </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> # </span>
              <span style="COLOR: #0000ff">as</span>
              <span style="COLOR: #000000"> we </span>
              <span style="COLOR: #0000ff">do</span>
              <span style="COLOR: #000000"> not
have a HttpContext we need to source one the hard way $site</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #0000ff">new</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> Microsoft.SharePoint.SPSite($PortalURL)
$servercontext</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000">[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up # Return the UserProfileManager </span>
              <span style="COLOR: #0000ff">new</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> Microsoft.Office.Server.UserProfiles.UserProfileManager($servercontext)
} </span>
            </div>
          </pre>
        </div>
        <p>
        </p>
        <p>
And then a helper function Get-SPUserProfile to obtain the UserProfile object itself:
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:739dfb37-41ea-48a3-a4c5-22392daee3d5" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">#
Function: Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SPUserProfile
# Description: Return a UserProfile </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000">, </span>
              <span style="COLOR: #0000ff">this</span>
              <span style="COLOR: #000000"> will
be created </span>
              <span style="COLOR: #0000ff">if</span>
              <span style="COLOR: #000000"> it
does not exist # Parameters: PortalURL URL </span>
              <span style="COLOR: #0000ff">for</span>
              <span style="COLOR: #000000"> the
Portal Site Collection # DomainUser UserName </span>
              <span style="COLOR: #0000ff">in</span>
              <span style="COLOR: #000000"> Domain\user
format function Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SPUserProfile([</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]$PortalURL,
[</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">] $DomainUser)
{ $upm</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000"> Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SPProfileManager([</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]$PortalURL) </span>
              <span style="COLOR: #0000ff">if</span>
              <span style="COLOR: #000000"> ($upm.UserExists($DomainUser) </span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">eq
$</span>
              <span style="COLOR: #0000ff">false</span>
              <span style="COLOR: #000000">) {
$upm.CreateUserProfile($DomainUser) } $upm.GetUserProfile($DomainUser) } </span>
            </div>
          </pre>
        </div>
        <p>
        </p>
        <p>
        </p>
        <p>
Note that this function will create the UserProfile if it does not already exist. 
</p>
        <p>
Now we just need a function that makes it easy to set a single UserProfile property,
if you have multiple properties to set it would be best to do them all at once and
then call commit. 
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:08f7de37-2adb-4300-829c-38f405485c2e" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver; WORD-WRAP: break-word">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">#
Function: Set</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserProfileProperty
# Description: Sets a property on a User Profile # Parameters: UserName [optional]
UserName </span>
              <span style="COLOR: #0000ff">in</span>
              <span style="COLOR: #000000"> Domain\user
format # PropertyName Property to </span>
              <span style="COLOR: #0000ff">set</span>
              <span style="COLOR: #000000"> #
PropertyValue Property Value to </span>
              <span style="COLOR: #0000ff">set</span>
              <span style="COLOR: #000000"> #
$UserProfile UserProfile </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000">, </span>
              <span style="COLOR: #0000ff">if</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #0000ff">using</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #0000ff">this</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #0000ff">in</span>
              <span style="COLOR: #000000"> a
loop </span>
              <span style="COLOR: #0000ff">this</span>
              <span style="COLOR: #000000"> should
be </span>
              <span style="COLOR: #0000ff">set</span>
              <span style="COLOR: #000000"> # function
Set</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserProfileProperty([</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]$UserName,
[</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">] $PropertyName,
[</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">] $PropertyValue,
[Microsoft.Office.Server.UserProfiles.UserProfile] $UserProfile) { # If we are not
passed a UserProfile </span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> then
create it # </span>
              <span style="COLOR: #0000ff">if</span>
              <span style="COLOR: #000000"> ($UserProfile </span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">eq
$</span>
              <span style="COLOR: #0000ff">null</span>
              <span style="COLOR: #000000">) { $UserProfile </span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000"> Get</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">SPUserProfile($UserName)
} $UserProfile[$PropertyName].Value</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000"> $PropertyValue
$UserProfile.Commit() } </span>
            </div>
          </pre>
        </div>
        <p>
Note this function can either be called with a pre-created userProfile object or a
UserName. 
</p>
        <p>
Heres the updated Users.CSV with the Picture Field added at the end   
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f7247e94-13f2-494c-825d-cb127082faeb" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">LoginName,
DisplayName, FirstName, LastName, Email, Picture brianb, Brian Ballack, Brian, Ballack,
brianb@contoso.com, cowner10.jpg walterf, Walter French, Walter, French, walterf@contoso.com,
cowner12.jpg </span>
            </div>
          </pre>
        </div>
        <p>
Now a function to tie this all together, it imports the CSV files, locates the user
profile by login name and updates the user’s Picture URL: 
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:08f8305b-c24e-46fc-96f9-efcdf8b8d407" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">function
Set</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserPictures([</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]
$PortalURL, [</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]
$UserFile, [</span>
              <span style="COLOR: #0000ff">string</span>
              <span style="COLOR: #000000">]
$Domain ) { Import</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">Csv
$UserFile </span>
              <span style="COLOR: #000000">|</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #0000ff">foreach</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #0000ff">object</span>
              <span style="COLOR: #000000"> {
$name</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000">$Domain </span>
              <span style="COLOR: #000000">+</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">\"
+ $_.LoginName; </span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000"> $fullURL</span>
              <span style="COLOR: #000000">=</span>
              <span style="COLOR: #000000">$PortalURL </span>
              <span style="COLOR: #000000">+</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">/</span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">+</span>
              <span style="COLOR: #000000"> $_.Picture;
Set</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserProfileProperty
$PortalURL $name </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">PictureURL</span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000"> $fullURL
} } </span>
            </div>
          </pre>
        </div>
        <p>
        </p>
        <p>
 And you can make use of all of the above code by running this command:
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:15f42277-8809-43c7-8718-b1baf3e0fc66" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
          <pre style="BACKGROUND-COLOR: silver">
            <div>
              <!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
              <span style="COLOR: #000000">Set</span>
              <span style="COLOR: #000000">-</span>
              <span style="COLOR: #000000">UserPictures </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">http://sps:2828</span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">users.csv</span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">
              </span>
              <span style="COLOR: #000000">"</span>
              <span style="COLOR: #000000">contoso</span>
              <span style="COLOR: #000000">"</span>
            </div>
          </pre>
        </div>
        <p>
        </p>
        <p>
Ok now we're all set to add the Contact WebPart to each publishing page in the next
post. 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=a332015d-c5dc-4433-a0f3-247fd37b0b04" />
      </body>
      <title>SharePoint/PowerShell 7: Put the User in the Picture</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a332015d-c5dc-4433-a0f3-247fd37b0b04.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2007/01/28/SharePointPowerShell7PutTheUserInThePicture.aspx</link>
      <pubDate>Sun, 28 Jan 2007 18:24:37 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Now we have the portal setup I want to add a Contact WebPart to each page but before
I can do that I have to add a picture for each user I have imported, in order to keep
this post a little shorter I’m only going to concentrate on using the UserProfile
API’s to set our picture for each user.&lt;br&gt;
(The Contact WebPart is MOSS WebPart that shows a users name and description and optionally
their picture)&lt;br&gt;
The field that we are going to set programmatically is accessed on the Users edit
profile page as Picture: 
&lt;p&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BrianB_Profile%5B7%5D.gif" atomicselection="true"&gt;&lt;img height=301 src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BrianB_Profile_thumb%5B5%5D.gif" width=700&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Once set this will display the picture on the user profile like this
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BriansPersonalSite%5B4%5D.gif" atomicselection="true"&gt;&lt;img height=504 src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/WindowsLiveWriter/SharePointPowerShell7PuttheUserinthePict_EDA6/BriansPersonalSite_thumb%5B2%5D.gif" width=660&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
To do this I need to revisit our User.csv import file and add an extra field that
gives the name of the JPG file that holds the users picture.&lt;br&gt;
I’m going to assume that the previous blog post &lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a326572f-8f78-4c80-86d5-1fe52cbd6fe5.aspx"&gt;Upload
a directory of files in 4 lines&lt;/a&gt; has already uploaded the users picture to the
SiteCollectionImages picture library, in real life you’d probably use a separate picture
library. 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
Ideally a profile import has occurred after we have added the users to Active Directory
and populated the SharePoint profile database. 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Now to set the Users Picture property we know to know the Property Name of the Picture
Field.&lt;br&gt;
To make this easy to find out here’s the first function for our toolbox Get-SPUserProfileConfigManager. 
&lt;br&gt;
This function returns a UserProfileConfigManager (&lt;a href="http://msdn2.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofileconfigmanager.aspx)"&gt;http://msdn2.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofileconfigmanager.aspx)&lt;/a&gt;,
note this is the new class that resides in the Microsoft.Office.Server namespace not
the v2 obsolete one that lives in Microsoft.sharePoint.Portal.UserProfiles.&lt;br&gt;
Also ignore the sample currently given in the MSDN documentation above, it won’t work
as it uses the old classes where you pass a PortalContext to the constructor whereas
the new version of the classes take a ServerContext object.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:f03c9c5a-cb1a-407f-b4a6-7b3d8391bdb7 contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt; #
Function: Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserProfileConfigManager
# Description: &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; a
UserProfileConfigManager &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; which &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;is&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; used &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;for&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; management
of MOSS User Profiles # Parameters: PortalURL URL &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;for&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; the
Portal Site Collection # # function Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserProfileConfigManager([&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]$PortalURL)
{ # Need to &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; a
PortalContext &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; # &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; we &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;do&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; not
have a HttpContext we need to source one the hard way $site&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Microsoft.SharePoint.SPSite($PortalURL)
$servercontext&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up # Return the UserProfileConfigManager &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Microsoft.Office.Server.UserProfiles.UserProfileConfigmanager($servercontext)
}&lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Once we get the UserProfileConfigManager we can call GetProperties and list the internal
and display names for each profile property 
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:df4400ea-56bc-45b0-8597-9d03eebc6046 contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: white"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;$cm&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;userprofileconfigmanager &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;http://sps:2828&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; $cm.getproperties() &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;|&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; select
name, displayname Name DisplayName &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;----&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-----------&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; UserProfile_GUID
Id SID SID ADGuid Active Directory Id AccountName Account name FirstName First name
LastName Last name PreferredName Name WorkPhone Work phone Office Office Department
Department Title Title Manager Manager AboutMe About me PersonalSpace Personal site
PictureURL Picture UserName User name QuickLinks Quick links WebSite Web site PublicSiteRedirect
Public site redirect SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Dotted&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;line
Dotted&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;line
Manager SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Peers
Peers SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Responsibility
Responsibilities SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Skills
Skills SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;PastProjects
Past projects SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Interests
Interests SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;School
Schools SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SipAddress
SIP Address SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Birthday
Birthday SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;MySiteUpgrade
My Site Upgrade SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;DontSuggestList
Don&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;'&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;t Suggest
List &lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;ProxyAddresses
Proxy addresses SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;HireDate
Hire date SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;LastColleagueAdded
Last Colleague Added SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;OWAUrl
Outlook Web Access URL SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;ResourceSID
Resource Forest SID SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;ResourceAccountName
Resource Forest Account Name SPS&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;MasterAccountName
Master Account Name Assistant Assistant WorkEmail Work e&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;mail
CellPhone Mobile phone Fax Fax HomePhone Home phone &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So from this list I&amp;nbsp;see that I&amp;nbsp;need to set the PictureURL property, to get
a UserProfile we first need a UserProfileManager object: 
&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:7c115796-d7b7-4db2-ba54-61b544e8f4f8 contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;#
Function: Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPProfileManager
# Description: Return a UserProfileManager &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; which &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;is&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; used &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;for&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; accessing
MOSS User Profiles # Parameters: PortalURL URL &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;for&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; the
Portal Site Collection # function Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPProfileManager([&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]$PortalURL)
{ # Need to &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; a
PortalContext &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; # &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;as&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; we &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;do&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; not
have a HttpContext we need to source one the hard way $site&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Microsoft.SharePoint.SPSite($PortalURL)
$servercontext&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up # Return the UserProfileManager &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;new&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Microsoft.Office.Server.UserProfiles.UserProfileManager($servercontext)
} &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
And then a helper function Get-SPUserProfile to obtain the UserProfile object itself:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:739dfb37-41ea-48a3-a4c5-22392daee3d5 contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;#
Function: Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPUserProfile
# Description: Return a UserProfile &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;, &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; will
be created &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; it
does not exist # Parameters: PortalURL URL &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;for&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; the
Portal Site Collection # DomainUser UserName &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Domain\user
format function Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPUserProfile([&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]$PortalURL,
[&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;] $DomainUser)
{ $upm&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPProfileManager([&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]$PortalURL) &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ($upm.UserExists($DomainUser) &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;eq
$&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;false&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;) {
$upm.CreateUserProfile($DomainUser) } $upm.GetUserProfile($DomainUser) } &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Note that this function will create the UserProfile if it does not already exist. 
&lt;/p&gt;
&lt;p&gt;
Now we just need a function that makes it easy to set a single UserProfile property,
if you have multiple properties to set it would be best to do them all at once and
then call commit. 
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:08f7de37-2adb-4300-829c-38f405485c2e contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver; WORD-WRAP: break-word"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;#
Function: Set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserProfileProperty
# Description: Sets a property on a User Profile # Parameters: UserName [optional]
UserName &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Domain\user
format # PropertyName Property to &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; #
PropertyValue Property Value to &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; #
$UserProfile UserProfile &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;, &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;using&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;in&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; a
loop &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;this&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; should
be &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; # function
Set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserProfileProperty([&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]$UserName,
[&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;] $PropertyName,
[&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;] $PropertyValue,
[Microsoft.Office.Server.UserProfiles.UserProfile] $UserProfile) { # If we are not
passed a UserProfile &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; then
create it # &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; ($UserProfile &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;eq
$&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;) { $UserProfile &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; Get&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;SPUserProfile($UserName)
} $UserProfile[$PropertyName].Value&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; $PropertyValue
$UserProfile.Commit() } &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Note this function can either be called with a pre-created userProfile object or a
UserName. 
&lt;p&gt;
Heres the updated Users.CSV with the Picture Field added at the end&amp;nbsp;&amp;nbsp; 
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f7247e94-13f2-494c-825d-cb127082faeb contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;LoginName,
DisplayName, FirstName, LastName, Email, Picture brianb, Brian Ballack, Brian, Ballack,
brianb@contoso.com, cowner10.jpg walterf, Walter French, Walter, French, walterf@contoso.com,
cowner12.jpg &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Now a function to tie this all together, it imports the CSV files, locates the user
profile by login name and updates the user’s Picture URL: 
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:08f8305b-c24e-46fc-96f9-efcdf8b8d407 contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;function
Set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserPictures([&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]
$PortalURL, [&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]
$UserFile, [&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;]
$Domain ) { Import&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;Csv
$UserFile &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;|&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;foreach&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; {
$name&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;$Domain &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;+&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;\"
+ $_.LoginName; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt; $fullURL&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;=&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;$PortalURL &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;+&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;/&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;+&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; $_.Picture;
Set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserProfileProperty
$PortalURL $name &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;PictureURL&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; $fullURL
} } &lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;And you can make use of all of the above code by running this command:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:15f42277-8809-43c7-8718-b1baf3e0fc66 contenteditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;pre style="BACKGROUND-COLOR: silver"&gt;
&lt;div&gt;
&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="COLOR: #000000"&gt;Set&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;-&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;UserPictures &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;http://sps:2828&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;users.csv&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt; &lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;contoso&lt;/span&gt;&lt;span style="COLOR: #000000"&gt;"&lt;/span&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Ok now we're all set to add the Contact WebPart to each publishing page in the next
post. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=a332015d-c5dc-4433-a0f3-247fd37b0b04" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,a332015d-c5dc-4433-a0f3-247fd37b0b04.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
      <category>WebParts</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=24fde49d-bc53-4773-a679-2bc62db4cae5</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,24fde49d-bc53-4773-a679-2bc62db4cae5.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,24fde49d-bc53-4773-a679-2bc62db4cae5.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=24fde49d-bc53-4773-a679-2bc62db4cae5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Made the <a href="http://www.get-psuguk.org.uk/">UK PowerShell User Group</a> meeting
last night in Wokingham, just, the weather and people having accidents on the M3 and
M4 kept me late. Got to try out my new Acer GPS unit based on Windows Mobile 5, worked
beautifully until setting the return journey when a fatal exception dialog popped
up on route calculation, I had to reboot the unit, having seen that dialog many times
developing on WM I just had to laugh.
</p>
        <p>
Nice to meet other PowerShell enthusiasts, kudos to <a href="http://www.powergadgets.com/">PowerGadgets</a> for
supplying the beer and pizza and <a href="http://www.globalknowledge.co.uk/">Global
Knowledge</a> for hosting.
</p>
        <p>
The meeting was hosted by all round good guy <a href="http://tfl09.blogspot.com/">Thomas
Lee</a> along with <a href="http://richardsiddaway.spaces.live.com/">Richard Siddaway</a>.
Thomas gave an interesting presentation on PowerShell installation a lot of which
I didn't know. 
</p>
        <p>
One point to come out of the discussion was the number of profiles that PowerShell
will load when it first starts up. Here are the locations and order the profiles get
loaded in, note these files won't exist unless you or your admin has created
them
</p>
        <ol>
          <li>
%windir%\system32\WindowsPowerShell\v1.0\profile.ps1  (all users, all shells) 
</li>
          <li>
%windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1 ( all users,
the Windows Powershell shell) 
</li>
          <li>
%userprofile%\My Documents\WindowsPowerShell\profile.ps1  (per user, all PowerShell
versions) 
</li>
          <li>
%userprofile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 ( per
user and the default Windows Powershell shell)</li>
        </ol>
        <p>
Now you can put code or functions in each of these files but the last loaded file
wins if there are any conflicts.
</p>
        <p>
This could be a problem with some companies that would like to define a corporate
wide profile for every user and put it in system32\WindowsPowerShell\v1.0, as a
user I can override any of the company function definitions with my own code in my
own profile. You could lock down the PowerShell %userprofile% files but that might
cause other problems. 
</p>
        <p>
Someone pointed out at the meeting what was needed is a readonly profile that
can be loaded globally and last for every user but hey presto there's a PowerShell
team blog out today on making functions read-only <a href="http://blogs.msdn.com/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx">http://blogs.msdn.com/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx</a> ,
now that's what I call service.
</p>
        <p>
 
</p>
        <p>
As the meeting closed Thomas also gave out a USB Pen drive to everyone who turned
up loaded with PowerShell related goodies, woo hoo free stuff, and oh yeah I'll be
speaking at the next meeting about controlling SharePoint with PowerShell, should
happen sometime in March.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=24fde49d-bc53-4773-a679-2bc62db4cae5" />
      </body>
      <title>Powershell User Group Meeting</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,24fde49d-bc53-4773-a679-2bc62db4cae5.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2007/01/25/PowershellUserGroupMeeting.aspx</link>
      <pubDate>Thu, 25 Jan 2007 21:36:19 GMT</pubDate>
      <description>&lt;p&gt;
Made the &lt;a href="http://www.get-psuguk.org.uk/"&gt;UK PowerShell User Group&lt;/a&gt; meeting
last night in Wokingham, just, the weather and people having accidents on the M3 and
M4 kept me late. Got to try out my new Acer GPS unit based on Windows Mobile 5, worked
beautifully until setting the return journey when a fatal exception dialog popped
up on route calculation, I had to reboot the unit, having seen that dialog many times
developing on WM I just had to laugh.
&lt;/p&gt;
&lt;p&gt;
Nice to meet other PowerShell enthusiasts, kudos to &lt;a href="http://www.powergadgets.com/"&gt;PowerGadgets&lt;/a&gt; for
supplying the&amp;nbsp;beer and pizza and &lt;a href="http://www.globalknowledge.co.uk/"&gt;Global
Knowledge&lt;/a&gt; for hosting.
&lt;/p&gt;
&lt;p&gt;
The meeting was hosted by all round good guy &lt;a href="http://tfl09.blogspot.com/"&gt;Thomas
Lee&lt;/a&gt; along with &lt;a href="http://richardsiddaway.spaces.live.com/"&gt;Richard Siddaway&lt;/a&gt;.
Thomas gave an interesting presentation on PowerShell installation a lot of which
I didn't know. 
&lt;/p&gt;
&lt;p&gt;
One point to come out of the discussion was the number of profiles that PowerShell
will load when it first starts up. Here are the locations and order the profiles get
loaded in, note these files won't&amp;nbsp;exist unless you or your admin has created
them
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
%windir%\system32\WindowsPowerShell\v1.0\profile.ps1&amp;nbsp; (all users, all shells) 
&lt;li&gt;
%windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1 ( all users,
the Windows Powershell shell) 
&lt;li&gt;
%userprofile%\My Documents\WindowsPowerShell\profile.ps1&amp;nbsp; (per user, all PowerShell
versions) 
&lt;li&gt;
%userprofile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 ( per
user and the default Windows Powershell shell)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Now you can put code or functions in each of these files but the last loaded file
wins if there are any conflicts.
&lt;/p&gt;
&lt;p&gt;
This could be&amp;nbsp;a problem with some companies that would like to define a corporate
wide profile for every user and put it in system32\WindowsPowerShell\v1.0, as&amp;nbsp;a
user I can override any of the company function definitions with my own code in my
own profile. You could lock down the PowerShell %userprofile% files but that might
cause other problems. 
&lt;/p&gt;
&lt;p&gt;
Someone pointed out at the meeting what&amp;nbsp;was needed is a readonly profile that
can be loaded globally and last for every user but hey presto there's a PowerShell
team blog out today on making functions read-only &lt;a href="http://blogs.msdn.com/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx"&gt;http://blogs.msdn.com/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx&lt;/a&gt;&amp;nbsp;,
now that's what I call service.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
As the meeting closed Thomas also gave out a USB Pen drive to everyone who turned
up loaded with PowerShell related goodies, woo hoo free stuff, and oh yeah I'll be
speaking at the next meeting about controlling SharePoint with PowerShell, should
happen sometime in March.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=24fde49d-bc53-4773-a679-2bc62db4cae5" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,24fde49d-bc53-4773-a679-2bc62db4cae5.aspx</comments>
      <category>PowerShell</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=bc62e425-3328-47f3-a7b8-b828e3aa0755</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,bc62e425-3328-47f3-a7b8-b828e3aa0755.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,bc62e425-3328-47f3-a7b8-b828e3aa0755.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=bc62e425-3328-47f3-a7b8-b828e3aa0755</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>MOSS Personal Sites - Sizing up</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,bc62e425-3328-47f3-a7b8-b828e3aa0755.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/12/17/MOSSPersonalSitesSizingUp.aspx</link>
      <pubDate>Sun, 17 Dec 2006 16:58:38 GMT</pubDate>
      <description>&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;As a follow on from my &lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,0afe1aa7-010d-4cbb-bbfc-2cc275b08951.aspx"&gt;previous
post&lt;/a&gt; we can do some neat calculations on the amount of data stored in MOSS personal
sites using Powershell.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;Using the measure-object CmdLet against the StorageUsedMB property
we can&amp;nbsp;calculate the number of personal sites (+1 one as it includes the root
site), average size of of each site, smallest, largest and total storage size of all
sites.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;Again assuming &lt;/font&gt;&lt;a href="http://sps:20488/"&gt;http://sps:20488&lt;/a&gt;&lt;font color=#000000&gt; is
where your personal sites are hosted&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PoSH
C:\demo&amp;gt; $output=stsadm -o enumsites -url &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://sps:20488"&lt;/span&gt;
&lt;br&gt;
PoSH C:\demo&amp;gt; $xml=[XML]$output&lt;br&gt;
PoSH C:\demo&amp;gt; $xml.sites.site &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; measure-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; storageusedmb
-min -max -sum -average &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; format-table&lt;br&gt;
&lt;br&gt;
Count Average Sum Maximum Minimum Property 
&lt;br&gt;
----- ------- --- ------- ------- -------- 
&lt;br&gt;
5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.62&amp;nbsp;&amp;nbsp; 3.1 0.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StorageUs...&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;To get a list of the sites in question with the largest at the
top use -descending on the sort CmdLet:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PoSH
C:\demo&amp;gt; $xml.sites.site &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; sort
storageusedmb -descending &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; select
url, owner, storageusedMB &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; format-table&lt;br&gt;
&lt;br&gt;
Url&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Owner&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
StorageUsedMB 
&lt;br&gt;
---&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
-----&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
------------- 
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/person...
CONTOSO\mike&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
0.7 &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/person...
CONTOSO\jeff&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
0.7 &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/person...
CONTOSO\administrator&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.7 &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
CONTOSO\administrator&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.6 &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/person...
CONTOSO\brianb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.4 &lt;/span&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;And if you just want the top 2 offenders us the -first option
on the select-object CmdLet&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PoSH
C:\demo&amp;gt; $xml.sites.site &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; sort
storageusedmb -descending &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; select
url, owner, storageusedMB -first 2 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; format-table&lt;br&gt;
&lt;br&gt;
Url Owner StorageUsedMB 
&lt;br&gt;
--- ----- ------------- 
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/person...
CONTOSO\mike 0.7 &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/person...
CONTOSO\jeff 0.7 &lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;&lt; P&gt;
Obviously in real life those figures would be a lot larger!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=bc62e425-3328-47f3-a7b8-b828e3aa0755" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,bc62e425-3328-47f3-a7b8-b828e3aa0755.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=0afe1aa7-010d-4cbb-bbfc-2cc275b08951</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,0afe1aa7-010d-4cbb-bbfc-2cc275b08951.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,0afe1aa7-010d-4cbb-bbfc-2cc275b08951.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=0afe1aa7-010d-4cbb-bbfc-2cc275b08951</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font color="#000000">A point came up at the UK SharePoint User Group Chrismas drink,
about Personal sites and whether they were top level sites i.e they exist as records
in the Sites table and are the top level container for all its subwebs, I hadn’t checked
this in v3 so a quick check with PowerShell and stsadm confirms that this is still
the case as in V2</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font color="#000000">Assuming </font>
          <a href="http://sps:20488/">http://sps:20488</a>
          <font color="#000000"> is
where your personal sites are hosted calling stsadm -o enumsites and processing the
returned XML in PowerShell gives us</font>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PoSH
C:\demo&gt; $output=stsadm -o enumsites -url <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://sps:20488"</span><br />
PoSH C:\demo&gt; $xml=[XML]$output<br />
PoSH C:\demo&gt; $xml.sites.site<br /><br />
Url : http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488</span><br />
Owner : CONTOSO\administrator<br />
ContentDatabase : WSS_Content_11fba01f-f0c4-4a05-a3c3-868499fd31ce<br />
StorageUsedMB : 0.6<br />
StorageWarningMB : 0<br />
StorageMaxMB : 0<br /><br />
Url : http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488/personal/administrator</span><br />
Owner : CONTOSO\administrator<br />
ContentDatabase : WSS_Content_11fba01f-f0c4-4a05-a3c3-868499fd31ce<br />
StorageUsedMB : 0.7<br />
StorageWarningMB : 80<br />
StorageMaxMB : 100<br />
Etc…</span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
            <font face="Verdana" size="2">Tiding up the output a little</font>
            <font face="Calibri" size="3">
            </font>
          </p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PoSH
C:\demo&gt; $xml.sites.site | select url, owner<br /><br />
Url Owner 
<br />
--- ----- 
<br />
http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488                           CONTOSO\administrator </span><br />
http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488/personal/administrator    CONTOSO\administrator </span><br />
http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488/personal/brianb          
CONTOSO\brianb </span><br />
http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488/personal/jeff             CONTOSO\jeff </span><br />
http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//sps:20488/personal/mike            
CONTOSO\mike</span><br />
….<br /></span>
          </p>
        </span>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          </span> 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
</span>
        </p>
        <p>
          <br />
        </p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=0afe1aa7-010d-4cbb-bbfc-2cc275b08951" />
      </body>
      <title>MOSS Personal Sites – Still Top Level </title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,0afe1aa7-010d-4cbb-bbfc-2cc275b08951.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/12/17/MOSSPersonalSitesStillTopLevel.aspx</link>
      <pubDate>Sun, 17 Dec 2006 16:40:58 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;A point came up at the UK SharePoint User Group Chrismas drink,
about Personal sites and whether they were top level sites i.e they exist as records
in the Sites table and are the top level container for all its subwebs, I hadn’t checked
this in v3 so a quick check with PowerShell and stsadm confirms that this is still
the case as in V2&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;Assuming &lt;/font&gt;&lt;a href="http://sps:20488/"&gt;http://sps:20488&lt;/a&gt;&lt;font color=#000000&gt; is
where your personal sites are hosted calling stsadm -o enumsites and processing the
returned XML in PowerShell gives us&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PoSH
C:\demo&amp;gt; $output=stsadm -o enumsites -url &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://sps:20488"&lt;/span&gt;
&lt;br&gt;
PoSH C:\demo&amp;gt; $xml=[XML]$output&lt;br&gt;
PoSH C:\demo&amp;gt; $xml.sites.site&lt;br&gt;
&lt;br&gt;
Url : http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488&lt;/span&gt;
&lt;br&gt;
Owner : CONTOSO\administrator&lt;br&gt;
ContentDatabase : WSS_Content_11fba01f-f0c4-4a05-a3c3-868499fd31ce&lt;br&gt;
StorageUsedMB : 0.6&lt;br&gt;
StorageWarningMB : 0&lt;br&gt;
StorageMaxMB : 0&lt;br&gt;
&lt;br&gt;
Url : http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/personal/administrator&lt;/span&gt;
&lt;br&gt;
Owner : CONTOSO\administrator&lt;br&gt;
ContentDatabase : WSS_Content_11fba01f-f0c4-4a05-a3c3-868499fd31ce&lt;br&gt;
StorageUsedMB : 0.7&lt;br&gt;
StorageWarningMB : 80&lt;br&gt;
StorageMaxMB : 100&lt;br&gt;
Etc…&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font face=Verdana size=2&gt;Tiding up the output a little&lt;/font&gt;&lt;font face=Calibri size=3&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PoSH
C:\demo&amp;gt; $xml.sites.site | select url, owner&lt;br&gt;
&lt;br&gt;
Url Owner 
&lt;br&gt;
--- ----- 
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CONTOSO\administrator &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/personal/administrator&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CONTOSO\administrator &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/personal/brianb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
CONTOSO\brianb &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/personal/jeff&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CONTOSO\jeff &lt;/span&gt;
&lt;br&gt;
http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//sps:20488/personal/mike&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
CONTOSO\mike&lt;/span&gt;
&lt;br&gt;
….&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/span&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&gt;&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=0afe1aa7-010d-4cbb-bbfc-2cc275b08951" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,0afe1aa7-010d-4cbb-bbfc-2cc275b08951.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=69610010-18e1-4f6f-b815-c342b4180fe5</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,69610010-18e1-4f6f-b815-c342b4180fe5.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,69610010-18e1-4f6f-b815-c342b4180fe5.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=69610010-18e1-4f6f-b815-c342b4180fe5</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Everyone and their dog will have this link but I'll post it anyway.
</p>
        <p>
          <strong>Windows PowerShell 1.0 has been released.</strong> This page has a list of
the download links for XP, Windows Server 2003 and Vista . 
</p>
        <p>
          <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx">http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx</a>
        </p>
        <p>
You might have to be patient as the links were a bit flakey when I tried them. 
</p>
        <p>
A point to note is that the Vista version is at <strong>RC2 </strong>status.
Jeffrey Snover explains the Vista release delay here <a href="http://blogs.msdn.com/powershell/archive/2006/11/15/windows-powershell-windows-vista.aspx">http://blogs.msdn.com/powershell/archive/2006/11/15/windows-powershell-windows-vista.aspx</a>.
Checking the comments it seems some people are getting hot under the collar about
the delay but as I see it the PowerShell team have done a great job and by all
accounts the only difference between RC2 and RTM is the installer. Personally given
my bad beta experiences of Vista I'm happier installing the RC2 of PowerShell
than the RTM of Vista.
</p>
        <p>
Also worth a download is the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B4720B00-9A66-430F-BD56-EC48BFCA154F&amp;displaylang=en">Documentation
Pack</a> as it contains a Getting Started Guide and a User Guide.
</p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=69610010-18e1-4f6f-b815-c342b4180fe5" />
      </body>
      <title>Windows PowerShell 1.0 Released!</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,69610010-18e1-4f6f-b815-c342b4180fe5.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/11/15/WindowsPowerShell10Released.aspx</link>
      <pubDate>Wed, 15 Nov 2006 09:57:09 GMT</pubDate>
      <description>&lt;p&gt;
Everyone and their dog will have this link but I'll post it anyway.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Windows PowerShell 1.0 has been released.&lt;/strong&gt; This page has a list of
the download links for XP, Windows Server 2003 and Vista&amp;nbsp;. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx"&gt;http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
You might have to be patient as the links were a bit flakey when I tried them. 
&lt;/p&gt;
&lt;p&gt;
A point to note is that the Vista version is at &lt;strong&gt;RC2&amp;nbsp;&lt;/strong&gt;status.
Jeffrey Snover explains the Vista release delay here &lt;a href="http://blogs.msdn.com/powershell/archive/2006/11/15/windows-powershell-windows-vista.aspx"&gt;http://blogs.msdn.com/powershell/archive/2006/11/15/windows-powershell-windows-vista.aspx&lt;/a&gt;.
Checking the comments it seems some people are getting hot under the collar about
the delay but&amp;nbsp;as I see it the PowerShell team have done a great job and by all
accounts the only difference between RC2 and RTM is the installer. Personally given
my bad beta experiences of Vista I'm happier installing&amp;nbsp;the RC2 of PowerShell
than the RTM of Vista.
&lt;/p&gt;
&lt;p&gt;
Also worth a download is the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B4720B00-9A66-430F-BD56-EC48BFCA154F&amp;amp;displaylang=en"&gt;Documentation
Pack&lt;/a&gt; as it contains a Getting Started Guide and&amp;nbsp;a User Guide.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=69610010-18e1-4f6f-b815-c342b4180fe5" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,69610010-18e1-4f6f-b815-c342b4180fe5.aspx</comments>
      <category>PowerShell</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=7ad355ec-75f5-4edd-bf9f-f396085a85e5</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,7ad355ec-75f5-4edd-bf9f-f396085a85e5.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,7ad355ec-75f5-4edd-bf9f-f396085a85e5.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=7ad355ec-75f5-4edd-bf9f-f396085a85e5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ok now we have the users in AD we can add them to the portal. Again we can use import-csv
to add them from the users CSV file
</p>
        <p>
heres the routine 
</p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#
Function:         Add-UsersToSP<br />
# Description:        Add each user <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> the
import CSV file to the given role 
<br />
# Parameters:        SiteCollectionURL     URL <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> the
root of the Site Collection    <br />
#            UserFile
        Location of the CSV file containing
the users<br />
#            Domain            Users
domain<br />
#            Role             Name
of the SharePoint Role e.g Reader, Contribute<br />
#<br />
function Add-UsersToSP([<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$SiteCollectionURL,[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$UserFile,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$Domain,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$Role)<br />
{<br />
Import-Csv $UserFile <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">foreach</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> {$spsite=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> Microsoft.SharePoint.SPSite($SiteCollectionURL)
} {$spsite.RootWeb.Roles[$Role].AddUser($Domain <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"\"
+ $_.LoginName, $_.Email, $_.DisplayName, "</span>") } 
<br />
}</span>
          </p>
          <p>
          </p>
        </span>In this script we get a SPSite object, get its rootweb and index into the
roles collection to return the role we want. We then use the AddUser method to add
the user.
<p>
And we call it like this Add-UsersToSP "<a href="http://sps:2828/">http://sps:2828</a>"
"users.csv" "contoso" "contribute"
</p><p>
Now there is something a little different going on in this script. In the foreach-object
loop there are 2 scriptblocks (the curly braces). This is because you can have up
to 3 scriptblocks in the foreach clause: Begin, Process and End
</p><p>
The Begin scriptblock will be called once at the start of the iteration, Process is
called for each object in the collection and End will be called at yes the end of
the iteration allowing you to clean up your objects. I don't have an end in this case
but you could call dispose on the SPSite object.
</p><p>
In v3 the Roles collection is deprecated and you should start using the new SPRoleDefinition
and SPRoleAssignment classes. These new classes have full support for the new
security features but for now I'm keeping things as simple as I can. 
</p><p>
Now is a good time to point out how easy it is to explore the SharePoint OM interactively,
in this case the Roles collection.
</p><p>
First of all from the command line do this
</p><p>
PS C:\demo&gt; $spsite=new-object microsoft.sharepoint.spsite("<a href="http://sps:2828">http://sps:2828</a>")<br />
PS C:\demo&gt; $spsite.rootweb.roles
</p><p>
this produces a listing like this
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Name
: Full Control<br />
Users : {}<br />
Groups : {SUGUK Intranet Owners}<br />
Type : Administrator<br />
Description : Has full control.<br />
Xml : &lt;Role ID=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1073741829"</span> Name=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Full
Control"</span> Description=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Has
ful<br />
l control."</span> Type=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"5"</span> /&gt;<br />
ID : 1073741829<br />
PermissionMask : FullMask<br />
ParentWeb : SUGUK Intranet<br /><br />
Name : Design<br />
Users : {}<br />
Groups : {Designers}<br />
Type : WebDesigner<br />
Description : Can view, add, update, delete, approve, and customize.<br />
Xml : &lt;Role ID=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1073741828"</span> Name=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Design"</span> Description=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Can
view, add<br />
, update, delete, approve, and customize."</span> Type=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"4"</span> /&gt;<br />
ID : 1073741828<br />
PermissionMask : 1012866047<br />
ParentWeb : SUGUK Intranet<br /></span></p><p>
.....
</p><p>
You can use the select CmdLet to produce a simple table listing
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">PS C:\demo&gt;
$spsite.rootweb.roles | select name, users</font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">Name                                   
Users                                  
<br />
----                                   
-----                                  
<br />
Full Control                           
{}                                     
<br />
Design                                 
{}                                     
<br />
Manage Hierarchy                   {}                                     
<br />
Approve                                {}                                     
<br />
Contribute                             {Brian
Ballack, Walter French}         
<br />
Read                                   
{}                                     
<br />
Restricted Read                      {}                                     
<br />
Limited Access                       {NT
AUTHORITY\authenticated users, S...<br />
View Only                              {}   </font></span></p><p>
 
</p><p>
If we want to see the full object of say the RootWeb you can do this
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">PS C:\demo&gt;
$spsite.rootweb | get-member</font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">or
just its properties </font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">PS C:\demo&gt;
$spsite.rootweb | get-member -membertype property</font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">or
just its methods</font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">PS C:\demo&gt;
$spsite.rootweb | get-member -membertype methods </font></span></font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">I
find myself using this lot before coding C# against an object as I can try out
the API and mess around with it before running up VS2005 </font></span></font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2">The
next step will be to create a host of portal areas as defined in a CSV file.</font></span></font></span></p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"></span></font></span> 
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"></span></font></span> 
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"></span></font></span> 
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font face="Verdana" color="#003300" size="2"></font></span> 
</p><p>
 
</p><img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=7ad355ec-75f5-4edd-bf9f-f396085a85e5" /></body>
      <title>SharePoint/PowerShell 3: Now add the users to SharePoint</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,7ad355ec-75f5-4edd-bf9f-f396085a85e5.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/11/01/SharePointPowerShell3NowAddTheUsersToSharePoint.aspx</link>
      <pubDate>Wed, 01 Nov 2006 20:05:34 GMT</pubDate>
      <description>&lt;p&gt;
Ok now we have the users in AD we can add them to the portal. Again we can use import-csv
to add them from the users CSV file
&lt;/p&gt;
&lt;p&gt;
heres the routine 
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#
Function: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Add-UsersToSP&lt;br&gt;
# Description:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Add each user &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; the
import CSV file to the given role 
&lt;br&gt;
# Parameters:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SiteCollectionURL &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;URL &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; the
root of the Site Collection&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserFile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Location of the CSV file containing
the users&lt;br&gt;
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Domain&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Users
domain&lt;br&gt;
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Role &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Name
of the SharePoint Role e.g Reader, Contribute&lt;br&gt;
#&lt;br&gt;
function Add-UsersToSP([&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$SiteCollectionURL,[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$UserFile,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$Domain,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$Role)&lt;br&gt;
{&lt;br&gt;
Import-Csv $UserFile &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;foreach&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; {$spsite=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; Microsoft.SharePoint.SPSite($SiteCollectionURL)
} {$spsite.RootWeb.Roles[$Role].AddUser($Domain &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"\"
+ $_.LoginName, $_.Email, $_.DisplayName, "&lt;/span&gt;") } 
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/span&gt;In this script we get a SPSite object, get its rootweb and index into the roles
collection to return the role we want. We then use the AddUser method to add the user.&gt;
&lt;p&gt;
And we call it like this Add-UsersToSP "&lt;a href="http://sps:2828/"&gt;http://sps:2828&lt;/a&gt;"
"users.csv" "contoso" "contribute"
&lt;/p&gt;
&lt;p&gt;
Now there is something a little different going on in this script. In the foreach-object
loop there are 2 scriptblocks (the curly braces). This is because you can have up
to 3 scriptblocks in the foreach clause: Begin,&amp;nbsp;Process and End
&lt;/p&gt;
&lt;p&gt;
The Begin scriptblock will be called once at the start of the iteration, Process is
called for each object in the collection and End will be called at yes the end of
the iteration allowing you to clean up your objects. I don't have an end in this case
but you could call dispose on the SPSite object.
&lt;/p&gt;
&lt;p&gt;
In v3 the Roles collection is deprecated and you should start using the new SPRoleDefinition
and&amp;nbsp;SPRoleAssignment classes. These new classes have full support for the new
security features but for now I'm keeping things as simple as I can.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now is a good time to point out how easy it is to explore the SharePoint OM interactively,
in this case the Roles collection.
&lt;/p&gt;
&lt;p&gt;
First of all from the command line do this
&lt;/p&gt;
&lt;p&gt;
PS&amp;nbsp;C:\demo&amp;gt; $spsite=new-object microsoft.sharepoint.spsite("&lt;a href="http://sps:2828"&gt;http://sps:2828&lt;/a&gt;")&lt;br&gt;
PS&amp;nbsp;C:\demo&amp;gt; $spsite.rootweb.roles
&lt;/p&gt;
&lt;p&gt;
this produces a listing like this
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Name
: Full Control&lt;br&gt;
Users : {}&lt;br&gt;
Groups : {SUGUK Intranet Owners}&lt;br&gt;
Type : Administrator&lt;br&gt;
Description : Has full control.&lt;br&gt;
Xml : &amp;lt;Role ID=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1073741829"&lt;/span&gt; Name=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Full
Control"&lt;/span&gt; Description=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Has
ful&lt;br&gt;
l control."&lt;/span&gt; Type=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"5"&lt;/span&gt; /&amp;gt;&lt;br&gt;
ID : 1073741829&lt;br&gt;
PermissionMask : FullMask&lt;br&gt;
ParentWeb : SUGUK Intranet&lt;br&gt;
&lt;br&gt;
Name : Design&lt;br&gt;
Users : {}&lt;br&gt;
Groups : {Designers}&lt;br&gt;
Type : WebDesigner&lt;br&gt;
Description : Can view, add, update, delete, approve, and customize.&lt;br&gt;
Xml : &amp;lt;Role ID=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1073741828"&lt;/span&gt; Name=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Design"&lt;/span&gt; Description=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Can
view, add&lt;br&gt;
, update, delete, approve, and customize."&lt;/span&gt; Type=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"4"&lt;/span&gt; /&amp;gt;&lt;br&gt;
ID : 1073741828&lt;br&gt;
PermissionMask : 1012866047&lt;br&gt;
ParentWeb : SUGUK Intranet&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
.....
&lt;/p&gt;
&lt;p&gt;
You can use the select CmdLet to produce a simple table listing
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;PS&amp;nbsp;C:\demo&amp;gt;
$spsite.rootweb.roles | select name, users&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Users&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
----&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
-----&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Full Control&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Design&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Manage Hierarchy&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Approve&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Contribute&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{Brian
Ballack, Walter French}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Read&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Restricted Read&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
Limited Access&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{NT
AUTHORITY\authenticated users, S...&lt;br&gt;
View Only&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{}&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
If we want to see the full object of say the RootWeb you can do this
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;PS&amp;nbsp;C:\demo&amp;gt;
$spsite.rootweb | get-member&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;or
just its properties &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;PS&amp;nbsp;C:\demo&amp;gt;
$spsite.rootweb | get-member -membertype property&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;or
just its methods&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;PS&amp;nbsp;C:\demo&amp;gt;
$spsite.rootweb | get-member -membertype methods &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;I
find myself using this&amp;nbsp;lot before coding C# against an object as I can try out
the API and mess around with it before running up VS2005 &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;The
next step will be to create a host of portal areas as defined in a CSV file.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=7ad355ec-75f5-4edd-bf9f-f396085a85e5" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,7ad355ec-75f5-4edd-bf9f-f396085a85e5.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=00544739-c0e8-42f2-aa30-2105b873ddfe</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,00544739-c0e8-42f2-aa30-2105b873ddfe.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,00544739-c0e8-42f2-aa30-2105b873ddfe.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=00544739-c0e8-42f2-aa30-2105b873ddfe</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Step 2 in our series is to add some users to Active Directory.
</p>
        <p>
First we need a simple routine to add users to Active Directory
</p>
        <p>
Update 3-11-2006 : The original add-aduser would only work in versions of PowerShell
pre RC2. RC2 included some breaking changes to how the DirectoryEntry object handled.
I;ve added an RC2 compatible routine.
</p>
        <p>
          <font color="#ff0000">Pre RC2 version</font>
        </p>
        <p>
          <hr />
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">function
add-aduser([<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$LoginName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$DisplayName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$FirstName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$LastName)<br />
{<br /><br />
    $cn=$LoginName<br />
    $sam=$LoginName<br />
    $pw=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"P@ssword1"</span><br /><br /><br />
    $ad= <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> System.DirectoryServices.DirectoryEntry 
<br />
    $u <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $ad.get_Children().Find(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CN=Users"</span>) 
<br />
    $NewUser <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $u.get_Children().add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CN=$cn"</span>,'User') 
<br /><br />
    <br />
    $NewUser.InvokeSet(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"sAMAccountName"</span>,$sam)<br />
    $NewUser.InvokeSet(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"displayName"</span>,$DisplayName)<br />
    $NewUser.InvokeSet(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"FirstName"</span>,$FirstName)<br />
    $NewUser.InvokeSet(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"LastName"</span>,$LastName)<br />
    <br />
    $NewUser.CommitChanges() 
<br /><br />
    $ad=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> System.DirectoryServices.DirectoryEntry 
<br />
    $u <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $ad.get_Children().Find(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CN=Users"</span>) 
<br /><br />
    $NewUser= $u.get_Children().Find(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CN=$cn"</span>);<br />
    $NewUser.Invoke(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"SetPassword"</span>,$pw) 
<br />
    $NewUser.InvokeSet(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"AccountDisabled"</span>,$<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>) 
<br /><br />
    # set that the password never expires<br />
    $NewUser.userAccountControl[0] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $NewUser.userAccountControl[0]
-bor (65536) 
<br /><br />
    $NewUser.CommitChanges() 
<br /><br />
}<br /><br /></span>
        </p>
        <p>
 
</p>
        <p>
          <font color="#ff0000">RC2 Version</font>
        </p>
        <p>
          <hr />
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">function
add-aduser([<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$LoginName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$DisplayName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$FirstName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$LastName)</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          </span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">{<br /><br /><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   $cn=$LoginName<br />
   $sam=$LoginName<br />
   $pw=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"P@ssword1"</span><br /><br />
   # Get an ADSI <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> the <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">default</span> domain<br />
   $ad= [ADSI]<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">""</span><br /><br />
   # Get the Users OU <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">default</span><br />
   $ou <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $ad.psbase.Children.Find(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CN=Users"</span>)<br /><br />
   # Add the user<br />
   $NewUser <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $ou.psbase.Children.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"CN=$cn"</span>,'User') <br /><br />
   # Set the basic properties<br />
   $NewUser.Put(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"sAMAccountName"</span>,$sam)<br />
   $NewUser.Put(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"displayName"</span>,$DisplayName)<br />
   $NewUser.Put(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"givenname"</span>,$FirstName)<br />
   $NewUser.Put(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"sn"</span>,$LastName)<br /><br />
   # Commit changes <br />
   $NewUser.SetInfo() <br /><br />
   <br />
   # Set our password <br />
   $NewUser.psbase.Invoke(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"SetPassword"</span>,$pw) <br /><br />
   # And enable the account<br />
   $NewUser.psbase.InvokeSet(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"AccountDisabled"</span>,$<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>) <br /><br />
   # set that the password never expires<br />
   $NewUser.userAccountControl[0] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $NewUser.userAccountControl[0]
-bor (65536) <br /><br />
   # Commit changes<br />
   $NewUser.SetInfo() </span></span>
        </p>
        <p>
          <br />
}<br /></p>
        <p>
          <hr />
          <br />
        </p>
        <p>
This gets us a function we can call to add test users. Note we're hardcoding
the OU to users, to make this more production you'd want to parameterize the OU, passwords
and set the AccountControl flags to Change Password on next login, there's a lot of
other resources out there to help with that.
</p>
        <p>
So If we put that in a script file loaded from our Profile we can call it like this
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">add-aduser <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"joeb"</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"joe
blogs"</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"joe"</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"blogs"</span><br /></span>
        </p>
        <p>
That's nice but with PowerShell we can do better. We really want to data drive this
and the built-in import-csv function will parse a CSV and create a collection of objects
that match the CSV schema. 
</p>
        <p>
Take a simple User's CSV file like this
</p>
        <font size="2">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">LoginName,
DisplayName, FirstName, LastName, Email<br /><br />
brianb, Brian Ballack, Brian, Ballack, brianb<br />
walterf, Walter French, Walter, French, walterf</span>
          </p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <br />
 
</span>
          </p>
        </font>
        <p>
Now if we run an import-xml command on the CSV file this is the output
</p>
        <p>
 
</p>
        <p>
          <img src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/PowerShell-Import-CSV.gif" border="0" />
        </p>
        <p>
Each line has been parsed and an object created. To see this more clearly we can use
the get-member command to reflect over the object and see what the object looks like.
</p>
        <p>
 
</p>
        <p>
          <img src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/PowerShell-Import-CSV2.gif" border="0" />
        </p>
        <p>
(Note: it will be PSCustomObject not MshCustomObject in post RC0 builds , I'm running
Exchange 2007 on this VPC which requires PowerShell RC0)
</p>
        <p>
As you can see the CSV columns have been added as a NoteProperty property (this is
part of the extensible type system).
</p>
        <p>
So now we can create a really simple function to import a CSV file of users, pipe
the output to a foreach loop and add each user to Active Directory.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#
Function:         Import-Users<br />
# Description:        Create users <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> active
directory <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> listed <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> the
import CSV file<br />
# Parameters:        UserFile         Location
of the CSV file containing the users<br />
#<br />
function Import-Users([<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$UserFile)<br />
{<br />
    Import-Csv $UserFile <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">foreach</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> {
add-aduser $_.LoginName $_.DisplayName $_.FirstName $_.LastName } 
<br />
}</span>
        </p>
        <p>
Note that when you receiving a collection of objects in the pipeline in a scriptblock
you have to loop over each object. The $_ is a special variable that gives you the
current object in the loop which you can use to access properties and methods.
</p>
        <p>
To call we just do 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Import-Users
Users.CSV</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          </span>With
this power 500 users are as easy as 1 user. 
</p>
        <p>
We're not limited to just using CSV files, I've just picked that format as I'm always
amazed at the amount of data I get given in Excel spreadsheets and word documents
and CSV is the easiest intermediate format to work with. There is also an import-xml
command which we will use later to import an XML file containing portal content.
As Powershell can call any .Net library the System.Data set of classes could also
be used to pull information from databases. 
</p>
        <p>
The next entry will be adding our users to SharePoint.
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=00544739-c0e8-42f2-aa30-2105b873ddfe" />
      </body>
      <title>SharePoint/PowerShell 2: Add some Users to Active Directory, maybe 1, maybe 500</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,00544739-c0e8-42f2-aa30-2105b873ddfe.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/10/31/SharePointPowerShell2AddSomeUsersToActiveDirectoryMaybe1Maybe500.aspx</link>
      <pubDate>Tue, 31 Oct 2006 09:13:15 GMT</pubDate>
      <description>&lt;p&gt;
Step 2 in our series is to add some users to Active Directory.
&lt;/p&gt;
&lt;p&gt;
First we need a simple routine to add users to Active Directory
&lt;/p&gt;
&lt;p&gt;
Update 3-11-2006 : The original add-aduser would only work in versions of PowerShell
pre RC2. RC2 included some breaking changes to how the DirectoryEntry object handled.
I;ve added an RC2 compatible routine.
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#ff0000&gt;Pre RC2 version&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;hr&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;function
add-aduser([&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$LoginName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$DisplayName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$FirstName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$LastName)&lt;br&gt;
{&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$cn=$LoginName&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sam=$LoginName&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$pw=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"P@ssword1"&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ad= &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; System.DirectoryServices.DirectoryEntry 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$u &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $ad.get_Children().Find(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CN=Users"&lt;/span&gt;) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $u.get_Children().add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CN=$cn"&lt;/span&gt;,'User') 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.InvokeSet(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"sAMAccountName"&lt;/span&gt;,$sam)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.InvokeSet(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"displayName"&lt;/span&gt;,$DisplayName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.InvokeSet(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"FirstName"&lt;/span&gt;,$FirstName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.InvokeSet(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"LastName"&lt;/span&gt;,$LastName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.CommitChanges() 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$ad=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; System.DirectoryServices.DirectoryEntry 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$u &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $ad.get_Children().Find(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CN=Users"&lt;/span&gt;) 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser= $u.get_Children().Find(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CN=$cn"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.Invoke(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SetPassword"&lt;/span&gt;,$pw) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.InvokeSet(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"AccountDisabled"&lt;/span&gt;,$&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;) 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# set that the password never expires&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.userAccountControl[0] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $NewUser.userAccountControl[0]
-bor (65536) 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.CommitChanges() 
&lt;br&gt;
&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#ff0000&gt;RC2 Version&lt;/font&gt; 
&lt;p&gt;
&lt;hr&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;function
add-aduser([&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$LoginName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$DisplayName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$FirstName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$LastName)&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;{&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$cn=$LoginName&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$sam=$LoginName&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$pw=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"P@ssword1"&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Get an ADSI &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; the &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;default&lt;/span&gt; domain&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$ad= [ADSI]&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;""&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Get the Users OU &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;default&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$ou &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $ad.psbase.Children.Find(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CN=Users"&lt;/span&gt;)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Add the user&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $ou.psbase.Children.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CN=$cn"&lt;/span&gt;,'User')&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Set the basic properties&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.Put(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"sAMAccountName"&lt;/span&gt;,$sam)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.Put(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"displayName"&lt;/span&gt;,$DisplayName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.Put(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"givenname"&lt;/span&gt;,$FirstName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.Put(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"sn"&lt;/span&gt;,$LastName)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Commit changes&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.SetInfo()&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Set our password&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.psbase.Invoke(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SetPassword"&lt;/span&gt;,$pw)&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# And enable the account&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.psbase.InvokeSet(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"AccountDisabled"&lt;/span&gt;,$&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;)&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# set that the password never expires&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.userAccountControl[0] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $NewUser.userAccountControl[0]
-bor (65536)&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;# Commit changes&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;$NewUser.SetInfo() &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;hr&gt;
&lt;br&gt;
&lt;/p&gt;
&gt; 
&lt;p&gt;
This gets us&amp;nbsp;a function we can call to add test users. Note we're hardcoding
the OU to users, to make this more production you'd want to parameterize the OU, passwords
and set the AccountControl flags to Change Password on next login, there's a lot of
other resources out there to help with that.
&lt;/p&gt;
&lt;p&gt;
So If we put that in a script file loaded from our Profile we can call it like this
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;add-aduser &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"joeb"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"joe
blogs"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"joe"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"blogs"&lt;/span&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
That's nice but with PowerShell we can do better. We really want to data drive this
and the built-in import-csv function will parse a CSV and create a collection of objects
that match the CSV schema. 
&lt;/p&gt;
&lt;p&gt;
Take a simple User's CSV file like this
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;LoginName,
DisplayName, FirstName, LastName, Email&lt;br&gt;
&lt;br&gt;
brianb, Brian Ballack, Brian, Ballack, brianb&lt;br&gt;
walterf, Walter French, Walter, French, walterf&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&gt;&lt;/font&gt; 
&lt;p&gt;
Now if we run an import-xml command on the CSV file this is the output
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/PowerShell-Import-CSV.gif" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Each line has been parsed and an object created. To see this more clearly we can use
the get-member command to reflect over the object and see what the object looks like.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/PowerShell-Import-CSV2.gif" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
(Note: it will be PSCustomObject not MshCustomObject in post RC0 builds , I'm running
Exchange 2007 on this VPC which requires PowerShell RC0)
&lt;/p&gt;
&lt;p&gt;
As you can see the CSV columns have been added as a NoteProperty property (this is
part of the extensible type system).
&lt;/p&gt;
&lt;p&gt;
So now we can create a really simple function to import a CSV file of users, pipe
the output to a foreach loop and add each user to Active Directory.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#
Function: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Import-Users&lt;br&gt;
# Description:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Create users &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; active
directory &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; listed &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; the
import CSV file&lt;br&gt;
# Parameters:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserFile &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Location
of the CSV file containing the users&lt;br&gt;
#&lt;br&gt;
function Import-Users([&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$UserFile)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Import-Csv $UserFile &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;foreach&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; {
add-aduser $_.LoginName $_.DisplayName $_.FirstName $_.LastName } 
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Note that when you receiving a collection of objects in the pipeline in a scriptblock
you have to loop over each object. The $_ is a special variable that gives you the
current object in the loop which you can use to access properties and methods.
&lt;/p&gt;
&lt;p&gt;
To call we just do 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Import-Users
Users.CSV&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;With
this power 500 users are as easy as 1 user. 
&lt;/p&gt;
&lt;p&gt;
We're not limited to just using CSV files, I've just picked that format as I'm always
amazed at the amount of data I get given in Excel&amp;nbsp;spreadsheets and word documents
and CSV is the easiest intermediate format to work with. There is also an import-xml
command which we will use later to import&amp;nbsp;an XML file containing portal content.
As Powershell can call any .Net library the System.Data set of classes could also
be used to pull information from databases. 
&lt;/p&gt;
&lt;p&gt;
The next entry will be adding our users to SharePoint.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=00544739-c0e8-42f2-aa30-2105b873ddfe" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,00544739-c0e8-42f2-aa30-2105b873ddfe.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Hi,
</p>
        <p>
Just like to thank all those who attended the Presentation last Thursday on controlling
SharePoint with PowerShell and Extending the Administration Object model.
</p>
        <p>
I know it was pretty fast paced and technical so I plan to follow it up with a series
of blogs entries recapping the steps and scripts in greater detail. 
</p>
        <p>
Some of the topics covered were:
</p>
        <p>
   Powershell Basics
</p>
        <p>
   Exchange produces PowerShell samples from the new UI console
</p>
        <p>
   Creating a new SharePoint WebApplication and applying a portal template
</p>
        <p>
   Adding users defined in a CSV file to Active Directory
</p>
        <p>
   Adding those users defined in a CSV file to SharePoint roles
</p>
        <p>
   Adding in webs as defined in a CSV file
</p>
        <p>
   Adding content in an XML file to a Publishing Web
</p>
        <p>
   Uploading a directory of files in 4 lines of Script.
</p>
        <p>
   Creating a custom STSAdm command
</p>
        <p>
   Creating an application to sync User Profile properties back to
Active Directory
</p>
        <p>
I've attached the PowerShell scripts and PowerPoint Slides.
</p>
        <p>
I'm not able to post the sample code of the AD Sync application as parts of the code
is proprietary but I will post a sample application that does a scheduled backup using
exactly the same template.
</p>
        <p>
          <a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/Presentation-SPPowerShell.zip">Presentation-SPPowerShell.zip
(46.78 KB)</a>
        </p>
Colin Byrne 
<p></p><p>
Flexnet Consultants
</p><img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f" /></body>
      <title>Presention Slides and PowerShell code from UK SharePoint User Group Thursday 26'th October</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/10/30/PresentionSlidesAndPowerShellCodeFromUKSharePointUserGroupThursday26thOctober.aspx</link>
      <pubDate>Mon, 30 Oct 2006 10:53:00 GMT</pubDate>
      <description>&lt;p&gt;
Hi,
&lt;/p&gt;
&lt;p&gt;
Just like to thank all those who attended the Presentation last Thursday on controlling
SharePoint with PowerShell and Extending the Administration Object model.
&lt;/p&gt;
&lt;p&gt;
I know it was pretty fast paced and technical so I plan to follow it up with a series
of blogs entries recapping the steps and scripts in greater detail. 
&lt;/p&gt;
&lt;p&gt;
Some of the topics covered were:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Powershell Basics
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Exchange produces PowerShell samples from the new UI console
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Creating a new SharePoint WebApplication and applying a portal template
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Adding users defined in a CSV file to Active Directory
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Adding those users defined in a CSV file to SharePoint roles
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Adding in webs as defined in a CSV file
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Adding content in an XML file to a Publishing Web
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Uploading a directory of files in 4 lines of Script.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Creating a custom STSAdm command
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Creating an application to sync User Profile properties back to
Active Directory
&lt;/p&gt;
&lt;p&gt;
I've attached the PowerShell scripts and PowerPoint Slides.
&lt;/p&gt;
&lt;p&gt;
I'm not able to post the sample code of the AD Sync application as parts of the code
is proprietary but I will post a sample application that does a scheduled backup using
exactly the same template.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.flexnetconsult.co.uk/colinbyrne/content/binary/Presentation-SPPowerShell.zip"&gt;Presentation-SPPowerShell.zip
(46.78 KB)&lt;/a&gt; 
&lt;/p&gt;
Colin Byrne 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Flexnet Consultants
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,1a36fc6f-0262-47e1-bb5f-59e96b6d2c0f.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=a326572f-8f78-4c80-86d5-1fe52cbd6fe5</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a326572f-8f78-4c80-86d5-1fe52cbd6fe5.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,a326572f-8f78-4c80-86d5-1fe52cbd6fe5.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=a326572f-8f78-4c80-86d5-1fe52cbd6fe5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A quickie. 
</p>
        <p>
Heres 4 lines of code to upload a whole directory of files, in this case pictures,
to a SharePoint document or image library. 
</p>
        <p>
The directory pictures contains the images.
</p>
        <p>
The destination is the image library SiteCollectionImages for the portal running on
port 2828
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">$wc <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> System.Net.WebClient<br />
$wc.Credentials <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> [System.Net.CredentialCache]::DefaultCredentials<br />
function getdestname($filename){ <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://sps:2828/sitecollectionimages/"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> $(split-path
-leaf $filename)}<br />
dir <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"pictures"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">%</span> {
$uploadname=getdestname $_; $wc.UploadFile($uploadname,<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"PUT"</span>,
$_.FullName) } </span>
        </p>
        <p>
Have I mentioned PowerShell just rocks?
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=a326572f-8f78-4c80-86d5-1fe52cbd6fe5" />
      </body>
      <title>SharePoint/Powershell Quickie: Upload a directory of files in 4 lines</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,a326572f-8f78-4c80-86d5-1fe52cbd6fe5.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/10/30/SharePointPowershellQuickieUploadADirectoryOfFilesIn4Lines.aspx</link>
      <pubDate>Mon, 30 Oct 2006 10:03:35 GMT</pubDate>
      <description>&lt;p&gt;
A quickie. 
&lt;/p&gt;
&lt;p&gt;
Heres 4 lines of code to upload a whole directory of files, in this case pictures,
to a SharePoint document or image library. 
&lt;/p&gt;
&lt;p&gt;
The directory pictures contains the images.
&lt;/p&gt;
&lt;p&gt;
The destination is the image library SiteCollectionImages for the portal running on
port 2828
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;$wc &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; System.Net.WebClient&lt;br&gt;
$wc.Credentials &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; [System.Net.CredentialCache]::DefaultCredentials&lt;br&gt;
function getdestname($filename){ &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://sps:2828/sitecollectionimages/"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; $(split-path
-leaf $filename)}&lt;br&gt;
dir &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"pictures"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;%&lt;/span&gt; {
$uploadname=getdestname $_; $wc.UploadFile($uploadname,&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"PUT"&lt;/span&gt;,
$_.FullName) } &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Have I mentioned PowerShell just rocks?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=a326572f-8f78-4c80-86d5-1fe52cbd6fe5" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,a326572f-8f78-4c80-86d5-1fe52cbd6fe5.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=f48e17ef-2db6-48ce-a612-628e19b4c6b6</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,f48e17ef-2db6-48ce-a612-628e19b4c6b6.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,f48e17ef-2db6-48ce-a612-628e19b4c6b6.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=f48e17ef-2db6-48ce-a612-628e19b4c6b6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In this PowerShell and SharePoint series I'd thought I'd spin through, in order of
use, the commands used to create the demo Portal site in the SUGUK user group presentation. 
</p>
        <p>
First step: Creating a Web Application using the API.
</p>
        <p>
The new SPWebApplicationBuilder object makes this easy. This object creates a Web
Application using a default port and the default settings, you can override any settings
you like in your script but for simplicity I'm just changing the default timezone. 
</p>
        <p>
SPWebApplicationBuilder also creates an AppPool to go along with the new IIS Website
which has Network Service as the user. In Beta 2TR that account doesn't have the correct
permissions so you need to change it to a local administrator. I tend to dev on a
Virtual machine DC so I'd use the domain admin. 
</p>
        <p>
So we have three routines 
</p>
        <p>
   new-SpWebApplication - Create the IIS Website and SharePoint settings
</p>
        <p>
   set-apidentity   - set the Application Pool credentials
</p>
        <p>
   get-defaulttimezoneid   - returns the Greenwich Meantime
TimeZone ID (adjust this one to suit)
</p>
        <p>
We also then need to create the set of webs that will live inside the Web Application,
this is done by calling the Add Method on the Sites method of the Web Application
passing it various parameters the most important of which is the template ID, in this
case SPSPORTAL to give us the default SharePoint Intranet portal look.
</p>
        <p>
The Powershell commands to tie all this together are
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">$webapp=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-SPWebApplication<br /><br />
set-apIdentity "<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"><a href="http://sps:yourportnumber">http://sps:yourportnumber</a>"</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"contoso\administrator"</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"password"</span><br /><br />
#Create Portal Site Collection<br /><br />
$webapp.Sites.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"/"</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"SUGUK
Intranet"</span>,<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"SUGUK
Intranet"</span>,1033, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"SPSPORTAL"</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"contoso\administrator"</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"administrator"</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"administrator@contoso.com"</span>)<br /></span>
        </p>
        <p>
Here's new-SPWebApplication
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#
Function:         <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-SPWebApplication    <br />
# Description:        Create and <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> a <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> SPWebApplication <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span><br />
#             Use the <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">default</span> values
which will create the web site at a random port 
<br />
# Parameters:        none<br />
#<br />
function <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-SPWebApplication()<br />
{<br /><br />
    # Get our local SPFarm <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span><br />
    $spfarm <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> [Microsoft.SharePoint.Administration.SPfarm]::Local<br /><br />
    # Use the <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> SPWebApplicationBuilder<br />
    $appbuilder= <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> Microsoft.SharePoint.Administration.SPWebApplicationBuilder
$spfarm<br /><br />
    # Create Web Application with the <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">default</span> settings<br />
    <br />
    $webapplication <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $appbuilder.Create()<br /><br />
    # Set the timezone to Greenwich Mean Time 
<br />
    $timezone=get-defaulttimezoneid<br />
    $webapplication.DefaultTimeZone <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> $timezone.ID<br />
    $webapplication.Update()<br /><br />
    # Actually queue the application <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> creation<br />
    $webapplication.Provision()<br /><br />
    # <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> the
SPWebApplication <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span><br />
    $webapplication<br /><br />
}</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          </span> 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#
Return the Default TimeZone <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span> used <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> the
majority of our sites<br />
#<br />
function get-defaulttimezoneid<br />
{<br />
    [Microsoft.SharePoint.SPregionalSettings]::Globaltimezones <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> where-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> {
$_.Description -like <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"*greenwich*"</span> } 
<br />
}</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
 
</span>
        </p>
        <p>
Now to change the Credentials for the AppPool is also really simple in V3. The SPWebApplication
object exposes a ApplicationPool property which you can use to set its credentials
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#
Function:         set-apidentity    <br />
# Description:        Set the credentials <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> the
application pool <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> the
given Web Application<br />
# Parameters:        Url        Site
Collection URL<br />
#            UserName
    UserName<br />
#            Password
    Password<br />
function set-apidentity([<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$SiteCollectionURL,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$UserName,
[<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>]$Password)<br />
{<br /><br />
        <br />
    $webapp=get-spwebapplication $SiteCollectionURL<br />
    <br />
    <br />
    $webapp.ApplicationPool.CurrentIdentityType= [Microsoft.SharePoint.Administration.IdentityType]::SpecificUser<br />
    $webapp.ApplicationPool.UserName= $Username<br />
    $webapp.ApplicationPool.Password= $Password<br />
    <br />
    # Save the settings<br />
    $webapp.ApplicationPool.Update()<br /><br />
    # Roll the settings <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">out</span> via
a Admin Job<br />
    $webapp.ApplicationPool.Provision()<br /><br /><br />
}</span>
        </p>
        <p>
 
</p>
        <p>
To me this is way easier than using the UI.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=f48e17ef-2db6-48ce-a612-628e19b4c6b6" />
      </body>
      <title>SharePoint/PowerShell 1: Make me a portal</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,f48e17ef-2db6-48ce-a612-628e19b4c6b6.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/10/30/SharePointPowerShell1MakeMeAPortal.aspx</link>
      <pubDate>Mon, 30 Oct 2006 09:46:17 GMT</pubDate>
      <description>&lt;p&gt;
In this PowerShell and SharePoint series I'd thought I'd spin through, in order of
use, the commands used to create the demo Portal site in the SUGUK user group presentation. 
&lt;/p&gt;
&lt;p&gt;
First step: Creating a Web Application using the API.
&lt;/p&gt;
&lt;p&gt;
The new SPWebApplicationBuilder object makes this easy. This object creates a Web
Application using a default port and the default settings, you can override any settings
you like in your script but for simplicity I'm just changing the default timezone. 
&lt;/p&gt;
&lt;p&gt;
SPWebApplicationBuilder also creates an AppPool to go along with the new IIS Website
which has Network Service as the user. In Beta 2TR that account doesn't have the correct
permissions so you need to change it to a local administrator. I tend to dev on a
Virtual machine DC so I'd use the domain admin. 
&lt;/p&gt;
&lt;p&gt;
So we have three routines 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;new-SpWebApplication - Create the IIS Website and SharePoint settings
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;set-apidentity&amp;nbsp;&amp;nbsp;&amp;nbsp;- set the Application Pool credentials
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;get-defaulttimezoneid&amp;nbsp;&amp;nbsp;&amp;nbsp;- returns the Greenwich Meantime
TimeZone ID (adjust this one to suit)
&lt;/p&gt;
&lt;p&gt;
We also then need to create the set of webs that will live inside the Web Application,
this is done by calling the Add Method on the Sites method of the Web Application
passing it various parameters the most important of which is the template ID, in this
case SPSPORTAL to give us the default SharePoint Intranet portal look.
&lt;/p&gt;
&lt;p&gt;
The Powershell commands to tie all this together are
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;$webapp=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-SPWebApplication&lt;br&gt;
&lt;br&gt;
set-apIdentity "&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;&lt;a href="http://sps:yourportnumber"&gt;http://sps:yourportnumber&lt;/a&gt;"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"contoso\administrator"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"password"&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
#Create Portal Site Collection&lt;br&gt;
&lt;br&gt;
$webapp.Sites.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"/"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SUGUK
Intranet"&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SUGUK
Intranet"&lt;/span&gt;,1033, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SPSPORTAL"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"contoso\administrator"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"administrator"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"administrator@contoso.com"&lt;/span&gt;)&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Here's new-SPWebApplication
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#
Function: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-SPWebApplication&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
# Description:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Create and &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; a &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; SPWebApplication &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;
&lt;br&gt;
# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Use the &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;default&lt;/span&gt; values
which will create the web site at a random port 
&lt;br&gt;
# Parameters:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;none&lt;br&gt;
#&lt;br&gt;
function &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-SPWebApplication()&lt;br&gt;
{&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Get our local SPFarm &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$spfarm &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; [Microsoft.SharePoint.Administration.SPfarm]::Local&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Use the &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; SPWebApplicationBuilder&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$appbuilder= &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; Microsoft.SharePoint.Administration.SPWebApplicationBuilder
$spfarm&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Create Web Application with the &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;default&lt;/span&gt; settings&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapplication &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $appbuilder.Create()&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Set the timezone to Greenwich Mean Time 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$timezone=get-defaulttimezoneid&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapplication.DefaultTimeZone &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; $timezone.ID&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapplication.Update()&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Actually queue the application &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; creation&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapplication.Provision()&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; the
SPWebApplication &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapplication&lt;br&gt;
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#
Return the Default TimeZone &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; used &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; the
majority of our sites&lt;br&gt;
#&lt;br&gt;
function get-defaulttimezoneid&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[Microsoft.SharePoint.SPregionalSettings]::Globaltimezones &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; where-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; {
$_.Description -like &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"*greenwich*"&lt;/span&gt; } 
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&gt; 
&lt;p&gt;
Now to change the Credentials for the AppPool is also really simple in V3. The SPWebApplication
object exposes a ApplicationPool property which you can use to set its credentials
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#
Function: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set-apidentity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
# Description:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set the credentials &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; the
application pool &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; the
given Web Application&lt;br&gt;
# Parameters:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Url&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Site
Collection URL&lt;br&gt;
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserName&lt;br&gt;
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Password
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Password&lt;br&gt;
function set-apidentity([&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$SiteCollectionURL,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$UserName,
[&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;]$Password)&lt;br&gt;
{&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapp=get-spwebapplication $SiteCollectionURL&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapp.ApplicationPool.CurrentIdentityType= [Microsoft.SharePoint.Administration.IdentityType]::SpecificUser&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapp.ApplicationPool.UserName= $Username&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapp.ApplicationPool.Password= $Password&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Save the settings&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapp.ApplicationPool.Update()&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Roll the settings &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;out&lt;/span&gt; via
a Admin Job&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$webapp.ApplicationPool.Provision()&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
To me this is way easier than using the UI.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=f48e17ef-2db6-48ce-a612-628e19b4c6b6" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,f48e17ef-2db6-48ce-a612-628e19b4c6b6.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=1665700b-e0de-4b8a-bb1c-014d6fbcf2db</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,1665700b-e0de-4b8a-bb1c-014d6fbcf2db.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,1665700b-e0de-4b8a-bb1c-014d6fbcf2db.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=1665700b-e0de-4b8a-bb1c-014d6fbcf2db</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Hi, 
</p>
        <p>
I'm about to start off a new series of entries about using Powershell to control SharePoint. 
There's a big gap in the ability to script SharePoint between stsadm commands and
custom .net programs and PowerShell fills it nicely. 
</p>
        <p>
All my entries from now on will focus on SharePoint version 3. 
</p>
        <p>
PowerShell is 'DOS for the .NET generation' (c) :-) and its a fantastic way to
both interactively control SharePoint via its Object Model from a command line and
to create scripts that can be run in a batch. Its currently at version RC2 and is
available from here <a href="http://support.microsoft.com/kb/925228"><font color="#669966">http://support.microsoft.com/kb/925228</font></a><br />
It installs as a windows update package rather than a separate install as it used
to in earlier betas, thats a sign of its being a core element of Windows going forward. 
</p>
        <p>
Ok lets do some Powershell SharePoint basics. 
</p>
        <p>
First although Powershell can call any .net class the assembly must be loaded first. 
<br />
By default Powershell loads a small list of assemblies, this command will get the
list of loaded assemblies: 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[System.AppDomain]::CurrentDomain.GetAssemblies()</span>
        </p>
        <p>
        </p>
        <p>
The syntax for calling a .NET class's static method is for the brackets go around
the Class name and the double colon between the class and the static method 
</p>
        <p>
The output from that is a little hard to read lets just list the files involved 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[AppDomain]::CurrentDomain.GetAssemblies() <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">foreach</span>-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> {
split-path $_.Location -leaf } <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> sort 
<br /><br /></span>
        </p>
        <p>
Here's the list of files the above command gives on my machine 
</p>
        <p>
Microsoft.PowerShell.Commands.Management.dll<br />
Microsoft.PowerShell.Commands.Utility.dll<br />
Microsoft.PowerShell.Commands.Utility.resources.dll<br />
Microsoft.PowerShell.ConsoleHost.dll<br />
Microsoft.PowerShell.ConsoleHost.resources.dll<br />
Microsoft.PowerShell.Security.dll<br />
Microsoft.PowerShell.Security.resources.dll<br />
mscorlib.dll<br />
System.Configuration.Install.dll<br />
System.Data.dll<br />
System.DirectoryServices.dll<br />
System.dll<br />
System.Management.Automation.dll<br />
System.Management.Automation.resources.dll<br />
System.Management.dll<br />
System.ServiceProcess.dll<br />
System.Xml.dll 
</p>
        <p>
As you can see SharePoint is not one of those in the list, also missing that could
be useful is the System.Web assembly 
</p>
        <p>
There are a few ways to load an assembly onto your AppDomain but the easiest is to
call the static method LoadWithPartialName on the Assembly class. 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[System.Reflection.Assembly]::LoadWithPartialName(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Microsoft.SharePoint"</span>) 
<br /></span>
        </p>
        <p>
LoadWithPartialName is great because you dont need to specify the full name to the
assembly which in SharePoint v3 would be 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[System.Reflection.Assembly]::Load(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Microsoft.SharePoint,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"</span>) 
<br /></span>
        </p>
        <p>
and for MOSS 
</p>
        <p>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[System.Reflection.Assembly]::Load(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Microsoft.SharePoint.Portal,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"</span>) 
<br /></span>
        </p>
        <p>
Now a lot of people will cry LoadWithPartialName has been deprecated as MS have got
concerned how it has to make to many guesses over locating the assembly. 
<br />
Personally I want to see a method that will simply load the latest version of the
assembly I've told it to load, in a controlled environment like a SharePoint server
thats exactly the behaviour I want to see. &lt;rant&gt; MS for god's sake just document
the method properly and let devs choose whether to use it or not. &lt;/rant&gt; 
</p>
        <p>
Anyway if you want to use the Load method take a look at this blog entry: <a href="http://www.leeholmes.com/blog/HowDoIEasilyLoadAssembliesWhenLoadWithPartialNameHasBeenDeprecated.aspx"><font color="#669966">http://www.leeholmes.com/blog/HowDoIEasilyLoadAssembliesWhenLoadWithPartialNameHasBeenDeprecated.aspx</font></a></p>
        <p>
Now you don't want to type the load commands each time so put them in your Powershell
Profile script. 
<br />
This changes location a lot depending on which version of Powershell your running
so see this entry for the full details <a href="http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx"><font color="#669966">http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx</font></a></p>
        <p>
So now what can we do with this? 
</p>
        <p>
Well first lets get a site collection we can play with 
</p>
        <p>
First create an SPSite object and pass it a valid site url 
</p>
        <p>
          <br />
        </p>
        <p>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      $spsite=
Microsoft.SharePoint.SPSite(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://portal.contoso.com"</span>)<br /></span>
        </p>
        <p>
        </p>
        <p>
to see the contents of the object just type the object on the command line 
</p>
        <blockquote>
          <p>
          </p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">$spsite </span>
          </p>
        </blockquote>
        <p>
To just get a list of the methods on the SPSite object 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   $spsite <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> get-member
-membertype method 
<br /></span>
        </p>
        <p>
To just get a list of the properties on the SPSite object 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   $spsite <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> get-member
-membertype property </span>
        </p>
        <p>
To get a list of all sub sites 
<br /></p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   $spsite.AllWebs 
<br /></span>
        </p>
        <p>
Get a list of webs ordered by the last time that the contents have been changed 
</p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   $spsite.allwebs <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> select
LastItemModifiedDate, URL , Created <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> sort
LastItemModifiedDate 
<br /><br /></span>
        </p>
        <p>
        </p>
        <p>
There's lots more that you can do and I'll post them as I go.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=1665700b-e0de-4b8a-bb1c-014d6fbcf2db" />
      </body>
      <title>PowerShell and SharePoint - Oh Yes</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,1665700b-e0de-4b8a-bb1c-014d6fbcf2db.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/10/25/PowerShellAndSharePointOhYes.aspx</link>
      <pubDate>Wed, 25 Oct 2006 10:01:53 GMT</pubDate>
      <description>&lt;p&gt;
Hi, 
&lt;p&gt;
I'm about to start off a new series of entries about using Powershell to control SharePoint.&amp;nbsp;
There's a big gap in the ability to script SharePoint between stsadm commands and
custom .net programs and PowerShell fills it nicely. 
&lt;p&gt;
All my entries from now on will focus on SharePoint version 3. 
&lt;p&gt;
PowerShell is 'DOS for the .NET generation' (c) :-)&amp;nbsp;and its a fantastic way to
both interactively control SharePoint via its Object Model from a command line and
to create scripts that can be run in a batch. Its currently at version RC2 and is
available from here &lt;a href="http://support.microsoft.com/kb/925228"&gt;&lt;font color=#669966&gt;http://support.microsoft.com/kb/925228&lt;/font&gt;&lt;/a&gt;
&lt;br&gt;
It installs as a windows update package rather than a separate install as it used
to in earlier betas, thats a sign of its being a core element of Windows going forward. 
&lt;/p&gt;
&lt;p&gt;
Ok lets do some Powershell SharePoint basics. 
&lt;p&gt;
First although Powershell can call any .net class the assembly must be loaded first. 
&lt;br&gt;
By default Powershell loads a small list of assemblies, this command will get the
list of loaded assemblies: 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[System.AppDomain]::CurrentDomain.GetAssemblies()&lt;/span&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The syntax for calling a .NET class's static method is for the brackets go around
the Class name and the double colon between the class and the static method 
&lt;p&gt;
The output from that is a little hard to read lets just list the files involved 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[AppDomain]::CurrentDomain.GetAssemblies() &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;foreach&lt;/span&gt;-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; {
split-path $_.Location -leaf } &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; sort 
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Here's the list of files the above command gives on my machine 
&lt;/p&gt;
&lt;p&gt;
Microsoft.PowerShell.Commands.Management.dll&lt;br&gt;
Microsoft.PowerShell.Commands.Utility.dll&lt;br&gt;
Microsoft.PowerShell.Commands.Utility.resources.dll&lt;br&gt;
Microsoft.PowerShell.ConsoleHost.dll&lt;br&gt;
Microsoft.PowerShell.ConsoleHost.resources.dll&lt;br&gt;
Microsoft.PowerShell.Security.dll&lt;br&gt;
Microsoft.PowerShell.Security.resources.dll&lt;br&gt;
mscorlib.dll&lt;br&gt;
System.Configuration.Install.dll&lt;br&gt;
System.Data.dll&lt;br&gt;
System.DirectoryServices.dll&lt;br&gt;
System.dll&lt;br&gt;
System.Management.Automation.dll&lt;br&gt;
System.Management.Automation.resources.dll&lt;br&gt;
System.Management.dll&lt;br&gt;
System.ServiceProcess.dll&lt;br&gt;
System.Xml.dll 
&lt;p&gt;
As you can see SharePoint is not one of those in the list, also missing that could
be useful is the System.Web assembly 
&lt;p&gt;
There are a few ways to load an assembly onto your AppDomain but the easiest is to
call the static method LoadWithPartialName on the Assembly class. 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[System.Reflection.Assembly]::LoadWithPartialName(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Microsoft.SharePoint"&lt;/span&gt;) 
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
LoadWithPartialName is great because you dont need to specify the full name to the
assembly which in SharePoint v3 would be 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[System.Reflection.Assembly]::Load(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Microsoft.SharePoint,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"&lt;/span&gt;) 
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
and for MOSS 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[System.Reflection.Assembly]::Load(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Microsoft.SharePoint.Portal,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"&lt;/span&gt;) 
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Now a lot of people will cry LoadWithPartialName has been deprecated as MS have got
concerned how it has to make to many guesses over locating the assembly. 
&lt;br&gt;
Personally I want to see a method that will simply load the latest version of the
assembly I've told it to load, in a controlled environment like a SharePoint server
thats exactly the behaviour I want to see. &amp;lt;rant&amp;gt; MS for god's sake just document
the method properly and let devs choose whether to use it or not. &amp;lt;/rant&amp;gt; 
&lt;p&gt;
Anyway if you want to use the Load method take a look at this blog entry: &lt;a href="http://www.leeholmes.com/blog/HowDoIEasilyLoadAssembliesWhenLoadWithPartialNameHasBeenDeprecated.aspx"&gt;&lt;font color=#669966&gt;http://www.leeholmes.com/blog/HowDoIEasilyLoadAssembliesWhenLoadWithPartialNameHasBeenDeprecated.aspx&lt;/font&gt;&lt;/a&gt; 
&lt;p&gt;
Now you don't want to type the load commands each time so put them in your Powershell
Profile script. 
&lt;br&gt;
This changes location a lot depending on which version of Powershell your running
so see this entry for the full details &lt;a href="http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx"&gt;&lt;font color=#669966&gt;http://www.leeholmes.com/blog/TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx&lt;/font&gt;&lt;/a&gt; 
&lt;p&gt;
So now what can we do with this? 
&lt;p&gt;
Well first lets get a site collection we can play with 
&lt;p&gt;
First create an SPSite object and pass it a valid site url 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$spsite=
Microsoft.SharePoint.SPSite(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://portal.contoso.com"&lt;/span&gt;)&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
to see the contents of the object just type the object on the command line &lt;blockquote&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;$spsite &lt;/span&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
To just get a list of the methods on the SPSite object 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$spsite &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; get-member
-membertype method 
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
To just get a list of the properties on the SPSite object 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$spsite &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; get-member
-membertype property &lt;/span&gt; 
&lt;p&gt;
To get a list of all sub sites 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$spsite.AllWebs 
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Get a list of webs ordered by the last time that the contents have been changed 
&lt;p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;$spsite.allwebs &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; select
LastItemModifiedDate, URL , Created &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; sort
LastItemModifiedDate 
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
There's lots more that you can do and I'll post them as I go.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=1665700b-e0de-4b8a-bb1c-014d6fbcf2db" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,1665700b-e0de-4b8a-bb1c-014d6fbcf2db.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
    <item>
      <trackback:ping>http://blogs.flexnetconsult.co.uk/colinbyrne/Trackback.aspx?guid=7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56</trackback:ping>
      <pingback:server>http://blogs.flexnetconsult.co.uk/colinbyrne/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56.aspx</pingback:target>
      <dc:creator>Colin Byrne</dc:creator>
      <wfw:comment>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.flexnetconsult.co.uk/colinbyrne/SyndicationService.asmx/GetEntryCommentsRss?guid=7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
Whoa, its been a while since I've blogged but sundry projects and SharePoint v3 has
taken up all my time. 
</p>
        <p>
Just to let you know that I'm presenting at the UK SharePoint users group meeting
this Thursday the 26th October. 
</p>
        <p>
I'm doing 2 sessions; one on using Powershell with SharePoint v3 in which I'll go
through Powershell basics and how to use it to control SharePoint. Then I will
attempt to build a portal without touching any settings in the UI! Wish me luck. 
</p>
        <p>
The second one will explore the new extensible admin object model.<br />
This will demonstrate creating custom stsadm commands along with creating an application
that syncs changed MOSS User profile information back to Active Directory.<br />
It will be a small application integrated into SharePoint and built using the new
SPService, SPServiceInstance and SPJobDefinition classes.<br />
I'll be describing how they work together, its cool stuff. 
</p>
        <p>
Everybody is welcome (you just need to register on the suguk site) so if you are in
London this Thursday it would be great to see you.  The meeting kicks off
at 6.30pm 
</p>
        <p>
If you plan to attend just register on the SUGUK site and leave your name on
this list 
<br /><a href="http://suguk.org/forums/thread/1490.aspx">http://suguk.org/forums/thread/1490.aspx</a></p>
        <p>
cheers,<br />
Colin
</p>
        <img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56" />
      </body>
      <title>Presenting at the SUGUK Meeting 26th October</title>
      <guid isPermaLink="false">http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56.aspx</guid>
      <link>http://blogs.flexnetconsult.co.uk/colinbyrne/2006/10/25/PresentingAtTheSUGUKMeeting26thOctober.aspx</link>
      <pubDate>Wed, 25 Oct 2006 08:37:47 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Whoa, its been a while since I've blogged but sundry projects and SharePoint v3 has
taken up all my time. 
&lt;p&gt;
Just to let you know that I'm presenting at the UK SharePoint users group meeting
this Thursday the 26th October. 
&lt;p&gt;
I'm doing 2 sessions; one on using Powershell with SharePoint v3 in which I'll go
through Powershell basics and how to use it to control SharePoint. Then&amp;nbsp;I will
attempt to build a portal without touching any settings in the UI! Wish me luck. 
&lt;p&gt;
The second one will explore the new extensible admin object model.&lt;br&gt;
This will demonstrate creating custom stsadm commands along with creating an application
that syncs changed MOSS User profile information back to Active Directory.&lt;br&gt;
It will be a small application integrated into SharePoint and built using the new
SPService, SPServiceInstance and SPJobDefinition classes.&lt;br&gt;
I'll be describing how they work together, its cool stuff. 
&lt;p&gt;
Everybody is welcome (you just need to register on the suguk site) so if you are in
London&amp;nbsp;this Thursday it would be great to see you.&amp;nbsp; The meeting kicks off
at 6.30pm 
&lt;p&gt;
If you plan to attend just register on the&amp;nbsp;SUGUK site and leave your name on
this list 
&lt;br&gt;
&lt;a href="http://suguk.org/forums/thread/1490.aspx"&gt;http://suguk.org/forums/thread/1490.aspx&lt;/a&gt; 
&lt;p&gt;
cheers,&lt;br&gt;
Colin
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.flexnetconsult.co.uk/colinbyrne/aggbug.ashx?id=7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56" /&gt;</description>
      <comments>http://blogs.flexnetconsult.co.uk/colinbyrne/CommentView,guid,7f6e8c0d-c641-4d1f-aa4b-e78e893fcf56.aspx</comments>
      <category>PowerShell</category>
      <category>SharePoint</category>
    </item>
  </channel>
</rss>