Welcome › Forums › General PowerShell Q&A › remote install with csv
- This topic has 9 replies, 3 voices, and was last updated 3 months, 2 weeks ago by
Participant.
-
AuthorPosts
-
-
October 11, 2020 at 11:47 am #262481
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”
PowerShell1234567$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\tempInvoke-Command -ComputerName $computer -ScriptBlock {Start-Process "SentinelAgent_windows_v4_2_4_154.exe"/SITE_TOKEN=** /QUIET /NORESTART}}thanks!
-
This topic was modified 3 months, 2 weeks ago by
kvprasoon. Reason: code formatting
-
This topic was modified 3 months, 2 weeks ago by
-
October 12, 2020 at 4:26 am #262622Hi @wicked74Couple 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.exeAlso, add -Wait flagPowerShell12345678$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.
-
October 12, 2020 at 6:43 am #262652
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..
-
October 12, 2020 at 7:37 am #262667
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.
-
October 12, 2020 at 9:28 am #262682
yep typo in the csv file
moving forward – the file got copied to the server but the exe didnt run
-
October 13, 2020 at 2:25 am #262850
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.
PowerShell1Start-Process -FilePath "C:\Windows\Temp\SentinelAgent_windows_v4_2_4_154.exe" -ArgumentList "/SITE_TOKEN=** /QUIET /NORESTART" -WaitThank you.
-
This reply was modified 3 months, 2 weeks ago by
Kiran.
-
This reply was modified 3 months, 2 weeks ago by
-
October 13, 2020 at 7:51 am #262922
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
-
October 14, 2020 at 9:53 am #263280
sorry for bumping
-
October 14, 2020 at 10:01 am #263286
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.
-
October 14, 2020 at 11:06 am #263310
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?
-
-
AuthorPosts
- The topic ‘remote install with csv’ is closed to new replies.