I’ve been trying for several hours to get the proper script to run an installation file remotely.
I’m on my machine, location and target of install is $targetmachine.
First, I copy the installation files locally. Works fine.
Second, I setup my session. Works fine.
$session = New-PSSession -ComputerName $targetmachine
Finally, I attempt to perform the installation. The first part simply tests the registry key presence.
The second part (else) is where I’m running into trouble. I cannot understand why the setup.exe file is not firing.
I’ve tried many variations and haven’t been able to have the install start.
$sqlversion = ‘2012-dev-x64’
Invoke-Command -Session $session {param($sqlversion)
if (Test-Path -path 'hklm:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLServer\CurrentVersion\')
{
Write-Host "`n SQL Server is already installed, exiting script." -BackgroundColor "Yellow" -ForegroundColor "Black"
}
Else
{
Write-Host "SQL Server not found, beginning installation"
Write-Host "Installation Start Time:"
$a = Get-Date
"Date: " + $a.ToShortDateString()
"Time: " + $a.ToShortTimeString()
Invoke-Command {Start-Process "c:\_installs\$sqlversion\setup.exe" -ArgumentList "/ConfigurationFile=c:\_installs\$sqlversion\configurationfile.ini"}
}
} -ArgumentList $sqlversion
}
I truly appreciate the assistance.
PS. I’ve tried these also;
Other Attempt
$setup = Invoke-Expression -Command “c:_installs$sqlversion\setup.exe” -ArgumentList '/ConfigurationFile=c:_installs$sqlversion\configurationfile.ini"
Other Attempt
$setup = Start-Process “c:_installs$sqlversion\setup.exe” -ArgumentList “/ConfigurationFile=c:_installs$sqlversion\configurationfile.ini” -Wait
if ($setup.exitcode -eq 0)
{
Write-Host “`nSQL Server Installation Completed at:” -BackgroundColor “Yellow” -ForegroundColor “Black”
$a = Get-Date
"Date: " + $a.ToShortDateString()
"Time: " + $a.ToShortTimeString()