logo banner

Metalogix Content Matrix Console - SharePoint Edition has the ability to generate PowerShell scripts, which can then be used to migrate your SharePoint content through the PowerShell command window. SharePoint Edition can use a job list or batch file to create a PowerShell script, and this script can then be run from the PowerShell console. This means that anything users can do through the SharePoint Edition's User Interface (UI) can also be done though PowerShell, adding all of PowerShell's capabilities to a migration.

When the SharePoint Edition is installed a Metalogix Content Matrix Console - SharePoint Edition PowerShell Console is installed under the same Start menu folder location. When this PowerShell console is used it will already have the three Metalogix PowerShell plug-ins installed as well as the three snap-ins installed. It can be accessed from the Start menu at: Metalogix > Content Matrix Console > SharePoint Edition > Content Matrix Console - SharePoint Edition PowerShell Console (as seen below).

Note: If this option is not used to open PowerShell, please see the Configuring PowerShell page, to set up and configure the Metalogix PowerShell plug-ins and snap-ins.

Using PowerShell

In order to create a PowerShell (PS) script for the SharePoint Edition a job list (or batch file) must first exist in the Job List section of the SharePoint Edition client application.

  1. In the main UI, go down to the Job List section and select a job (or jobs) that you want to run in PowerShell.

  2. Click the Generate PowerShell Script button in the Job List's tool bar, or right-click on one of the items and select Generate PowerShell Script from the context menu. This will open a drop down menu that allows users to select between two user based PowerShell script generation options. These option are:

    • For Current User and Machine - This option will generate a PowerShell script based on the currently logged in User Account. Any PowerShell scripts that are generated through this option can only be run by the logged in user (on the machine they were generated on). This is the most likely scenario.

    • For Local Machine - This option will generate a PowerShell script that can be used by any User account on the machine they are created on.

    • For Certificate - This option will generate a PowerShell script that can be used by any User account on any machine that has the certificate that is specified when the script is created. When users try to save the PowerShell script using this method they will be prompted to select a security certificate that exist on that machine. The selected certificate will be required on any system that attempts to run the script at a later date.

    Once the PS script generation type is selected, Content Matrix Console will generate a PS script for the select Job, which will be written out to a Microsoft Notepad file. If multiple jobs are selected they will all be written out, into the same file.

  3. A Notepad file will open containing the PowerShell script for any selected job(s). This file can now be saved as a PowerShell script file. To do this click File > Save As... and select any desired save location for the PowerShell script.Give the file any name you want, but change the file type to .PS1.

    In the PowerShell (PS) script itself you may notice five sections (see the image below). They are:

    1. Section 1 - This first section at the top (starting with an "if" statement) runs a check in the PowerShell console to make sure that the Metalogix snappins have been added. If they are not found then it will add them to that instance of the PS console.

    2. Load Configuration settings - This section will find and load all of the Content Matrix client application configuration settings into the PowerShell script. These are the client application's environmental settings and not the migration/action settings.

    3. Load source - This section will load all of the data for the source environment connection.

    4. Load target - Similar to the previous section, this will load target environment's connection information.

    5. Run the action - Last is the "Run the action" section. This last section will contain all of the other data for the migration, such as the type of migration (i.e. a site migration, list migration, item migration, etc.) and all of the settings and configurations for the migration/action that is being run. This includes things like settings for versions, content types, permissions, etc.

  4. On your desktop open the Metalogix Content Matrix Console - SharePoint Edition PowerShell Console shortcut, for the PowerShell window with the Metalogix plug-ins and snap-ins already installed.

  5. In the PowerShell window you can set yourself to act from any desired directory. In some cases users will set themselves to the same directory that contains their PowerShell scripts. Now enter the name and extension of the PowerShell Script (at it's specified location), and the script will run.

    In the case that you are running a script from the same directory you would use the format: .\[ScriptName].ps1. So if your PowerShell scrip was named "ResourceScript.ps1" then you would enter: .\ResourceScript.ps1 into the window, and the script would run.

    In the case that the script is in a different directory, you would enter the location of that directory relative to your current location, followed by the script name. For example, if your prompt is at the "C:\" drive and your PowerShell script, named "ResourceScript.ps1" is on the desktop you would enter: C:\Users\[User]\Desktop\ResourceScript.ps1, and the script would run.

    Note: In some cases the Execution Policy may prevent you from executing a PowerShell script. In this case you will likely see the message: [Script].ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details. In this case, running the command: set-executionpolicy RemoteSigned should change the existing script policy to allow you to run these scripts for your location. It is advised that you check with your System Administrators before doing this to ensure that no Company Policies are being broken by this action. If this is an action you need to take, you should only need to run this command once.
  6. The migration will begin, and any warnings and/or errors that are encountered in running the script will be displayed in the PowerShell window.

For more information on Content Matrix Console - SharePoint Edition's PowerShell cmdlets please see the SharePoint Edition PowerShell Command-Let List page for details.