Timeout. There is no need to convert your .ps1 into a .exe.
Your have 2 main challenges.
- The double hop authentication problem from workstation (where you are logged on) --> laptop (where the install runs) --> server (where the install source is located)
A non-interactive session.
So let's first verify that we can access the file server from the laptop. Load this script into Powershell_ise and modify the first 4 lines with your values. Run it and verify that all machines can see each other.
$target = "laptop111" # the machine we want to install the software on
$share = "\\someserver\someshare" # the file server where to software is stored
$User = ".\admin" # this should be a domain account that has admin rights on the target PC and read access to the file share.
$PWord = ConvertTo-SecureString -String "admin" -AsPlainText -Force # the account's password
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
$script =
{
"This script is running on {0}" -f $env:COMPUTERNAME
"**** Mapping a drive to the server where all of the install files and script are stored.."
# Note the $using statement. This allows the remotely executed script to reference variables in the main script
new-psdrive -Name 'B' -PSProvider FileSystem -Root $using:share -Credential $using:credential
""
"**** Get a count of files/folders to verify that we can access the drive.."
(get-childitem b:\ ).count
""
"Now run the install script."
# Note that this is being executed in an unattended session. This must be a completely silent install.
# You cannot run a GUI that prompts the user for input. There is no user to see the prompt.
# B:\Install-MicrosoftTeams.ps1 -Source B:\teams\ # point to correct files/folders and uncomment to run the install
""
"**** Remove the drive."
Remove-PSDrive -Name 'B'
}
Invoke-Command -ComputerName $target -credential $Credential -ScriptBlock $script
If that works, then you just need to plug the name of the script that does the install and any parameters it requires.
As the comments note, you are performing an unattended install. There is no user who can "click ok to continue".
Update: you should investigate the script parameters and the parameters passed to any .exe. Since this is unattended, you will want to find something that enables logging so that your script can read the log and display it back to your Powershell session. That should answer the question of "I launched the program but it didn't do anything".