How to install a program to one or more remote computers
How to install a program to one or more remote computers
# Define the path to the file # $file_path = 'C:\installer.exe' # Create a list of computers to run the installer on # $computers = ('computer1','computer2','computer3') foreach ( $comp in $computers){ # Test the remote computer is reachable before executing # if ( Test-Connection -ComputerName $comp -Count 1 -ErrorAction SilentlyContinue){ # Define the location to save the installer on the remote machine # $file_destination = '\\' $comp '\c$\' # Copy the file to te remote computer # Copy-Item -Path $path -Destination $file_destination -Recurse Invoke-Command -ComputerName $comp -ScriptBlock { # Change the location to where the installer was saved # Set-Location C:\ # Launch the installer # Start-Process .\installer.exe -Wait # Remove the installer # Remove-Item C:\installer.exe -Force } } }