<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>The PFE Dude Abides</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/pfedude/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/pfedude/feed.xml</link>
    <description>Notes from a SharePoint PFE</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:30:05 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>PowerShell on SharePoint 2007</title>
      <link>https://docs.microsoft.com/archive/blogs/pfedude/powershell-on-sharepoint-2007</link>
      <pubDate>Tue, 09 May 2017 11:19:46 GMT</pubDate>
      <dc:creator><![CDATA[Stephen Haas]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/pfedude/?p=25</guid>
      <description><![CDATA[On October 10, 2017 (just 21 days before my birthday, in case you'd like to get me a present),...]]></description>
      <content:encoded><![CDATA[On October 10, 2017 (just 21 days before my birthday, in case you'd like to get me a present), SharePoint Server 2007 will reach End-of-Life. 99.999% of you have already migrated off this platform. If, like some of my customers, you've been running into issues trying to migrate your users' content, you may find yourself in need of some guidance in performing various tasks to enable your migration. Such was the case last week, when I was asked to create a script that would automate the check-in process for several thousand documents so that they could be migrated.

If your initial thought is "Gee, I wish I could use PowerShell to accomplish this in SharePoint 2007," you're in luck! As my good friend <a target="_blank" href="https://blogs.technet.microsoft.com/praveenh/">Praveen Hebbar</a> points out in his <a target="_blank" href="https://blogs.technet.microsoft.com/praveenh/2013/01/21/running-powershell-on-moss-2007/">blog post</a>, It's possible to run PowerShell scripts against MOSS 2007. For those that would prefer not to jump to his post, I've replicated it here:
<ul>
<ul>
<ol>
 	<li>If you are running MOSS 2007 on Windows Server 2003, then you have to download and install <a target="_blank" href="https://support.microsoft.com/kb/968930">PowerShell</a>. Windows Server 2008  natively supports PowerShell.</li>
 	<li>Set the  Execution Policy to RemoteSigned. You can check it by running the Get-ExecutionPolicy cmdlet. The default execution policy for PowerShell is “Restricted” (commands only, not scripts).
<div id="codeSnippetWrapper" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;margin: 20px 0px 10px;width: 81.35%;font-family: 'Courier New', courier, monospace;direction: ltr;height: 65px;max-height: 200px;font-size: 8pt;overflow: auto;cursor: text;border: silver 1px solid;padding: 4px">
<div id="codeSnippet" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px">
<pre style="text-align: left;line-height: 12pt;background-color: white;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #008000"># All scripts running locally are allowed</span></pre>
<!--CRLF-->
<pre style="text-align: left;line-height: 12pt;background-color: #f4f4f4;margin: 0em;width: 87.77%;font-family: 'Courier New', courier, monospace;direction: ltr;height: 4px;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px">Set-ExecutionPolicy RemoteSigned</pre>
<!--CRLF-->

</div>
</div>
This means downloaded scripts must be signed by a trusted publisher before they can be run.</li>
 	<li>You need to load the SharePoint assemblies with the following command:
<div id="codeSnippetWrapper" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;margin: 20px 0px 10px;width: 79.14%;font-family: 'Courier New', courier, monospace;direction: ltr;height: 65px;max-height: 200px;font-size: 8pt;overflow: auto;cursor: text;border: silver 1px solid;padding: 4px">
<div id="codeSnippet" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px">
<pre style="text-align: left;line-height: 12pt;background-color: white;margin: 0em;width: 97.01%;font-family: 'Courier New', courier, monospace;direction: ltr;height: 16px;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #008000">#    Load the SharePoint assemblies</span></pre>
<!--CRLF-->
<pre style="text-align: left;line-height: 12pt;background-color: #f4f4f4;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px">[Void][System<span style="color: #ff0000">.</span>Reflection<span style="color: #ff0000">.</span>Assembly]::LoadWithPartialName("Microsoft<span style="color: #ff0000">.</span>SharePoint")</pre>
<!--CRLF-->

</div>
</div></li>
</ol>
</ul>
</ul>
A bunch of PowerShell scripts are available <a target="_blank" href="https://www.powershell.nu/2009/09/08/moss-2007-script-collection">here</a>.

For those of us who haven't used SharePoint 2007 since 2010's release date, this is great news. Using Praveen's guidance, my customer was able to cobble together a script which they anticipated would solve their problem. However, when trying to run the script, they encountered the following error:
<div id="codeSnippetWrapper" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;margin: 20px 0px 10px;width: 81.35%;font-family: 'Courier New', courier, monospace;direction: ltr;font-size: 8pt;overflow: auto;cursor: text;border: silver 1px solid;padding: 4px">
<div id="codeSnippet" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px">
<pre style="background-color: #f4f4f4;text-align: left;line-height: 12pt;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #ff0000">New-Object : Exception calling ".ctor" with "1" argument(s): 
"The Web application at [CENSORED] could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."</span></pre>
</div>
</div>
The reason for this is that older versions of SharePoint (in this case, MOSS 2007) requires PowerShell V2 for running PowerShell cmdlets. As my grandfather used to say, "I'll bet you dollars to donuts" that you're running a newer version of PowerShell. To determine whether this is the case, you can simply use <strong>$PSVersionTable.PSVersion</strong> to determine your version. Once you've been able to ascertain that this is the case, you can simply force PowerShell to run as V2 by using <strong>powershell -version 2</strong>.
<div id="codeSnippetWrapper" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;margin: 20px 0px 10px;width: 81.35%;font-family: 'Courier New', courier, monospace;direction: ltr;font-size: 8pt;overflow: auto;cursor: text;border: silver 1px solid;padding: 4px">
<div id="codeSnippet" style="text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px">
<pre style="text-align: left;line-height: 12pt;background-color: white;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000">PS C:\&gt; $PSVersionTable.PSVersion</span></pre>
<pre style="background-color: #f4f4f4;text-align: left;line-height: 12pt;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000"> </span></pre>
<pre style="background-color: #f4f4f4;text-align: left;line-height: 12pt;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000">Major  Minor  Build  Revision</span></pre>
<pre style="background-color: #f4f4f4;text-align: left;line-height: 12pt;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000">-----  -----  -----  --------</span></pre>
<pre style="background-color: #f4f4f4;text-align: left;line-height: 12pt;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000">4      0      -1     -1</span></pre>
<pre style="background-color: #f4f4f4;text-align: left;line-height: 12pt;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000"> </span></pre>
<pre style="text-align: left;line-height: 12pt;background-color: white;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000">PS C:\&gt; powershell -version 2</span></pre>
<pre style="text-align: left;line-height: 12pt;background-color: white;margin: 0em;width: 100%;font-family: 'Courier New', courier, monospace;direction: ltr;color: black;font-size: 8pt;overflow: visible;border-style: none;padding: 0px"><span style="color: #000000">PS C:\&gt; </span></pre>
</div>
</div>]]></content:encoded>
    </item>
  </channel>
</rss>