remote install with csv

hello

im new to powershell

im looking for the simplest way to remotely install an exe to computers listed in a csv file

from my local machine

i ran this script with no errors but it didnt do anything either :

all the computers in the csv file are under “name”

$computers = Import-CSV "[Path to csv]"
foreach($computer in $_name){
Copy-Item "C:\sentinel one\SentinelAgent_windows_v4_2_4_154.exe" \\$computer\c$\windows\temp
  Invoke-Command -ComputerName $computer -ScriptBlock {
    Start-Process "SentinelAgent_windows_v4_2_4_154.exe"/SITE_TOKEN=** /QUIET /NORESTART
  }
}

 

thanks!

Hi @wicked74
Couple of changes that you need to do...
If you have a header in the csv file then you can use something like this in the foreach loop...
foreach ($computer in $computers.name)
In the Copy-Item destination path, you need to use escape character before $ (not $computer) since PowerShell variables start with $ itself.
In the Start-Process you should use full file path, not just filename...
C:\Windows\Temp\SentinelAgent_windows_v4_2_4_154.exe
Also, add -Wait flag
$Computers = Import-CSV "[Path to csv]"
foreach($Computer in $Computers.Name)
{
    Copy-Item -Path "C:\sentinel one\SentinelAgent_windows_v4_2_4_154.exe" -Destination "\\$Computer\c`$\Windows\Temp"
    Invoke-Command -ComputerName $Computer -ScriptBlock {
        Start-Process -FilePath "C:\Windows\Temp\SentinelAgent_windows_v4_2_4_154.exe" -ArgumentList "/SITE_TOKEN=** /QUIET /NORESTART" -Wait
    }
}
Thank you.

hey kiran

thank you very much for your reply

i ran the script and didnt noticed any errors however i dont see the file getting copied or the exe getting installed…

 

First, check your csv file, and see the output of $Computers

If you see your servers list, then try with one server, and execute the commands one by one with the direct path and see how it works.

yep typo in the csv file

moving forward - the file got copied to the server but the exe didnt run

 

Did you notice any error?

Try running the command directly on the remote computer and see the outcome. Also, check to replace the site token in the argument list.

Start-Process -FilePath "C:\Windows\Temp\SentinelAgent_windows_v4_2_4_154.exe" -ArgumentList "/SITE_TOKEN=** /QUIET /NORESTART" -Wait

Thank you.

running the command locally only runs the exe a pop up dialog box asking if you want to install the app guess -ArgumentList is ignored

sorry for bumping

Go through the Start-Process help and try to see anything that you are missing…

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process

Thank you.

 

First, have you tested this Start-Process on a local system to ensure it runs and works properly? The documentation recommends a push via CLI,SCCM or GPO. Each of these methods are most likely installing the software as SYSTEM. Have you attempted a local installation with the credentials you are using with Invoke-Command? Unfortunately, the documentation doesn’t appear to have installation logging, but have you looked at event viewer for failures as well?