I have a custom PowerShell script that accept some parameters as input.
However, one of the parameters is of a type that is defined in an external assembly. That means that when I run the script from a command line with PowerShell.exe, the assembly is not loaded and the script fails.
Here is relevant parts of the script:
[CmdLetBinding()]
param(
[Parameter(Mandatory=$true, Position=0)]
[Microsoft.SharePoint.PowerShell.SPWebPipeBind]$Web
)
# The SharePoint snapin will load 'Microsoft.SharePoint.PowerShell'
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
Write-Host "Let's dance"
And here how I fire the script (actually from a post-deployment event of a SharePoint project):
"%WINDIR%\SysNative\WindowsPowerShell\v1.0\powershell.exe" -file "c:\pathto\fixeditablefields.ps1" "http://myapp"
Is there a way to tell PowerShell.exe to load an assembly before running the script?
[Edit] As I'm working with SharePoint, I'm sticked to PowerShell V2