I am trying to install one client's software by using PowerShell silent scripting. Below is the script which I have created and its not working and throwing errors like below:
Cannot validate argument on parameter 'ArgumentList'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again
Is the below line correct or any mistake in this Here I am getting issue.
$Args = @("/S", "/L1033", -INSTALL_TYPE=PRESERVE_VERSION, START_MENU=AStartMenuFolder\Software\production\)
Full script:
$INSTALLDIR = "C:\Software\Software.exe"
$Args = @("/S", "/L1033", -INSTALL_TYPE=PRESERVE_VERSION, START_MENU=AStartMenuFolder\Software\production\)
$logfile = "D:\BACKUP\Install_Logfile.txt"
$ErrorActionPreference = 'Stop'
try {
$exitcode = (Start-Process $Installer -ArgumentList $Args -NoNewWindow -Wait -Passthru).ExitCode
if ($exitcode -eq 0) {
[System.Windows.MessageBox]::Show('Installation Completed Successfully')
} else {
[System.Windows.MessageBox]::Show('Installation Failled')
}
} catch {
"$_" | Out-File $logfile -Append
{[System.Windows.MessageBox]::Show('Installation Failled')}
}
Edit:
$Installer = "C:\OTE\OTE.exe"
$params = @("/S", "/L1033", "-INSTALL_TYPE=PRESERVE_VERSION", "-START_MENU=AStartMenuFolder\OTE\production\")
$logfile = "C:\Install_Logfile.txt"
$ErrorActionPreference = 'Stop'
& $Installer @params
if ($LastExitCode -eq 0) {
[Windows.MessageBox]::Show('Installation Completed Successfully')
} else {
"$_" | out-file $logfile -append
[Windows.MessageBox]::Show('Installation Failled')
}
In the above script I am getting the error like below,
Cannot validate argument on parameter 'ArgumentList'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.