D
D
Digsecman2021-08-06 09:29:41
PowerShell
Digsecman, 2021-08-06 09:29:41

What to add to the script so that it remotely copies the exe to multiple hosts?

Good day!
It is not possible to copy exe via Invoke-Command to many hosts, there is nothing intelligible in Google.
Created a shared folder on the domain controller, placed the exe-shnik there.
Here is the

Set-Item wsman script itself:\localhost\client\trustedhosts * -Force;
$pc= (Get-ADComputer -Filter * -Property *|Select-Object Name).Name;
$dest = '\\WIN-4HCHDV7O78U\fusion'
$path = 'C:\fusion\GLPI_autoinstall.exe'

foreach($pc in $pcs)
Invoke-Command -ScriptBlock {Start-Process PowerShell -wait -verb open -ArgumentList 'Copy-Item -Path \\WIN\c$\fusion\GLPI_autoinstall.exe -Destination \\$pc\$path\'} -ComputerName $pc;
Invoke-Command -ScriptBlock {cmd /c ″C:\fusion\GLPI_autoinstall.exe″} -ComputerName $pc;

What needs to be corrected/removed for the script to work?
Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MaxKozlov, 2021-08-07
@MaxKozlov

Regardless of what's in the script.
If you are copying from the network inside the invoke-command - you get the classic double-hop == access
denied

R
Roman Bezrukov, 2021-08-06
@NortheR73

You have a domain - why don't you use a GPO for this task?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question