-1

I need help in pushing an Atera agent to around 80+ pc's I did that with GPO, the thing is that I finding my self asking people to do a restart to the computer in order to update the gpo, becouse most of the time they don't want to GPUPDATE.

So at the begning I was thinking of using invoke-command and running a command with the installation of the MSI, this didn't worked so well, had to many strange errors, then I used PSEXEC and it worked when I run it on single pc, but when I wanted to run it in a PS script it didn't worke.

Here is the code:

# Set the path to the text file containing the list of computer names
$computerList = "C:\Users\rvm\Desktop\pclist.txt"

# Set the path to the MSI package
$msiPath = "\\fs\Atera\setup.msi"

# Set the username and password for the remote computers
$username = "blah\blah"
$password = "blah"

# Read the computer names from the text file
$computers = Get-Content $computerList

# Loop through each computer in the list
foreach ($computer in $computers) {
    # Run the psexec command for the current computer
    $psexecCommand = "psexec \\$computer -u $username -p $password -h cmd /c `"msiexec.exe /i `"$msiPath`" /qn`""
    Invoke-Expression $psexecCommand
}

Thank you for your help.

WebsGhost
  • 107
  • 1
  • 14

1 Answers1

0

I would use copy-item -tosession and invoke-command { install-package }.

$s = new-pssession pclist.txt
# % -parallel in powershell 7 would be good here
# although ps 7 has a weird bug displaying get-childitem over invoke-command
$s | % { copy setup.msi c:\users\js2010\documents -tosession $_ } 

# parallel installs
invoke-command $s { install-package .\setup.msi }
js2010
  • 23,033
  • 6
  • 64
  • 66