Cannot convert 'System.String' to the type is returned when attempting to use New-EVIndexSnapshot in a PowerShell script

book

Article ID: 100062397

calendar_today

Updated On:

Description

Error Message

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell : New-EVIndexSnapshot : Cannot convert 'System.String' to the type 
At line:1 char:1
+ C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "C:\Program ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (New-EVIndexSnap...g' to the type :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
'System.Management.Automation.SwitchParameter' required by parameter 
'Confirm'. 
At line:1 char:93
+ ... ver1' -confirm:'False'}
+                    ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-EVIndexSnapshot], Para 
   meterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Symantec.EnterpriseVault.P 
   owerShell.AdminAPI.NewEVIndexSnapshot

Cause

The PowerShell script is not formatted properly to run in a scripted format. 

Resolution

A tick (`) is required to ensure the command is formatted properly due to the $ character in $False.  

Non-working:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {New-EVIndexSnapshot -siteid '12345678306678C448A185D71384F250D1d10000evserver1' -confirm:$False}"

Working: 

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -psconsolefile "C:\Program Files (x86)\Enterprise Vault\EVShell.psc1" -command "& {New-EVIndexSnapshot -siteid '12345678306678C448A185D71384F250D1d10000evserver1' -confirm:`$False}"

In the working command, the $False is changed to `$False

 

Issue/Introduction

The script to run New-EVIndexSnapshot will not execute properly due to the error.