I am attempting to write a powershell script which installs an .msi package. It takes user's input (client's IP and username) then creates a new PSSession and pulls the file from network drive.
Enter-PSSession -ComputerName $destination -Credential <xxxxxx>
Invoke-Command -ScriptBlock {msiexec /i "\\CLOUD_IP\road-to\msi-location\msi_to_install.msi"}
This is the main problem with the script. Once the script finishes, the installation prompts on my PC, not the client's, but it still stays in session. Until I exit the session either manually or via script.
Everything works as intended when I enter those two lines manually into powershell prompt.
I tried putting a Start-Sleep inbetween the two lines, since it takes a tad bit time for the Enter-PSSession, but that did nothing.
$destination is the user's IP input, which works as -ComputerName aswell, since Get-PSSession shows the IP as the computer name.