r/PowerShell • u/glitch_inside • Feb 18 '22
Question How do I remotely issue a command for executing the ".exe" file to all the windows domain computers at once?
I want all windows computers connected to the same Domain to want to get the ".exe" file and run it without physically visiting each machine. So I need a central way of distributing the .exe file and sending a command to run it.
How should i do this?
11
u/slatts7 Feb 18 '22
The Finglonger should do the trick.
3
8
u/AlphaTwoOne Feb 18 '22
0
26
Feb 18 '22
if you’re an IT worker who is responsible for software at your company, then take no offense to this but you need to do some more research and immerse yourself in learning about industry solutions to common requests like this.
while you CAN do what you’re asking in powershell with a one liner already answered in this thread, you should just google “managing software in a domain environment” or “configuration management” or “mdm.”
you need some fundamentals.
0
Feb 18 '22
[deleted]
2
1
Feb 18 '22
Honestly I used Microsoft’s Intune MDM to install ever app I need, Change every registry edit I need and run powershell scripts on my whole network, i like it
0
Feb 18 '22
[deleted]
1
Feb 19 '22
I have a series of update rings configured in intune, perhaps that is WU for business i just dont know it by that name, but basicly i have 2 sites update 1st then after some testing everyone else gets updates.
8
2
2
3
3
u/z386 Feb 18 '22
This would work in principal:
$Session = New-PSSession -ComputerName "computer1"
Copy-Item -Path "c:\my.exe" -Destination "c:\my.exe" -ToSession $Session
Invoke-Command -Session $Session { c:\my.exe }3
1
Feb 18 '22
I’m not gonna write the whole script out for you but hope this helps
Make fileshare Put exe on it
Invoke-command { to run on remote machine Ps-drive to mount file share Copy-item to copy the exe to your remote machine from the ps drive Start-process to start the exe Delete the ps drive at the end }
1
u/thesterv Feb 19 '22
Big fan of PDQ myself. Heard they recently bought Smart Deploy so they likely support imaging now. Hoping to introduce it at my new job—currently using Kace, not a fan of the bloat and unintuitive interface.
1
u/syntek_ Feb 20 '22
This is exactly what group policy is for. Otherwise, how do you handle unreachable computers? Laptops that are not on-site or on-VPN? Desktops that are shutdown? Group policy can handle this multiple ways.. You can add a startup script to run your exe, or create a run-once scheduled task. Place the file in a share or even somewhere in \youdomain.local\NETLOGON and reference it there.
0
25
u/bringtheremedy Feb 18 '22
Hi, I think you're better off using a deployment tool like SCCM or PDQ Deploy if available.
If it has to be PowerShell, you could use
Copy-Itemto copy the exe and thenInvoke-Commandto start it on each computer.