Reputation: 975
Consider this simple path validation:
if ((Test-Path $_) -and ($_ -like "*.msi")) {
$true
}
else {
Throw "Specify correct path to installer."
}
When passing a path e.g. "C:\Scripts\installer.msi"
the validation works as expected.
But when executing in same directory as the installer, passing this argument as the path: .\Installer.msi
Validation is still True
but breaks the installer.
How can I fix this?
Upvotes: 0
Views: 169
Reputation: 6404
Assuming that you're using msiexec.exe to run this installer, you have to pass the full path to that msi file in order for it to work.
So you're probably calling msiexec like this:
msiexec /i $_
when really you would have to do this:
msiexec /i "$((Get-Item $_).FullName)"
You might also want to look into the MSI PowerShell module. It makes working with msi files a bit nicer within PowerShell.
Upvotes: 2