literalpath error in script ver 3.6.5

I’m new to this incredible toolkit so please bare with me if I’ve missed something or posted in the wrong section. I see a similar fix on github but it appears that I have the latest version.

When I run the latest version of the toolkit with the modified deploy-application.ps1 as described in the admin manual, I receive the following PS error
PS C:\Downloads\Mimecast outlook plugin v> .\Deploy-Application.ps1
C:\Downloads\Mimecast outlook plugin v\Deploy-Application.ps1 : Module [C:\Downloads\Mimecast outlook plugin v\AppDeplo
yToolkit\AppDeployToolkitMain.ps1] failed to load:
A parameter cannot be found that matches parameter name ‘LiteralPath’.

At C:\Downloads\Mimecast outlook plugin v\AppDeployToolkit\AppDeployToolkitMain.ps1:9749 char:23

  • Add-Type -LiteralPath <<<<  $appDeployCustomTypesSourceCode -ReferencedAssemblies $ReferencedAssemblies -IgnoreWa
    

rnings -ErrorAction ‘Stop’
At line:1 char:25

  • .\Deploy-Application.ps1 <<<<
    • CategoryInfo : NotSpecified: (:slight_smile: [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Deploy-Application.ps1

If I run sections of the script to identify the issue I get stuck on
If (Test-Path -LiteralPath ‘variable:HostInvocation’) { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

Running Test-Path -LiteralPath ‘variable:HostInvocation’, result is false

This appears to be the version info of the script

Variables: Script

[string]$deployAppScriptFriendlyName = 'Deploy Application'
[version]$deployAppScriptVersion = [version]'3.6.5'
[string]$deployAppScriptDate = '08/12/2015'

Any help is appreciated!

Thanks,
Jon

What version of PowerShell are you using? I don’t see this problem on my machine and the documentation on Microsoft’s website shows that -LiteralPath is an available parameter.

If you change: Add-Type -LiteralPath
To: Add-Type -Path

Does that run without errors?

The machine has PSver 2. Looking at the cmd add-type requires ver 3. Will try updating PS version and will post back.

I do not see Add-Type -LiteralPath in the deploy-application.ps1

Add-Type command is available in PSv2. I’ve noticed that Microsoft’s documentation pages have removed references to v2 recently for some reason. The Add-Type command is in the main toolkit file. Looking at the stack trace for the error you posted above, that is where the error is coming from. It just gets “Caught” in a “Catch” block in Deploy-Application.ps1:
At C:\Downloads\Mimecast outlook plugin v\AppDeployToolkit\AppDeployToolkitMain.ps1:9749 char:23

Updating to PS ver 3.0 did the trick. Script worked great!

Thanks Muhammad!

No problem. I guess that parameter name did not exist in 2.0. I’ll have to change it back to -Path so it doesn’t break for 2.0 users.

Just as an fyi, I did make the following change and it worked on a PSv2 machine
If you change: Add-Type -LiteralPath
To: Add-Type -Path