When calling PowerShell functions as part of an SRM (5.1) recovery plan, you need to perform some additional configurations within PowerShell. This can be achieved using the following procedures.
Step 1 - Set the execution level
1. Launch the 32-bit version of PowerShell
2. Run the command 'Set-ExecutionPolicy RemoteSigned'.
Step 2 - Create and configure a PowerShell profile
1. Run the command 'Test-Path $profile', this will verify if a profile already exists for the user. (assuming that one does not exist go to step 2)
2. Run the command 'New-Item $profile -type file -force', this will force the creation of a new profile file.
3. Run the command 'Notepad $profile', this will open the new file in a Notepad session.
4. Enter the following syntax into the file, then save and close:
Add-PSSnapin -name VMware.VimAutomation.Core
Next time you start a new PowerShell session, it will load in our custom functions from the vCloudDR module and add in the VMware core cmdlets.
Step 3 - Install the custom modules for PowerShell to call
1. Locate the folder path 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules'
2. Create a new folder called 'vCloudDR'. NOTE: This folder name must match the name used for the Import-Module command used in the profile in Step 2.
3. Copy your custom module file into the newly created folder
4. To test that the module has been loaded correctly, restart PowerShell and run the command 'Get-Module -ListAvailable' and verify your custom module is listed.