-1

I have followed the advice here and here to write a PowerShell script that remotely kills a process:

Get-WmiObject Win32_Process -Filter "Name='myapp.exe'" -ComputerName remotecomputername | Invoke-WmiMethod -Name Terminate 

The above works when I execute it on my machine, but when it's run remotely, targeting my machine by a user setup as per the instructions on the second link, the command fails silently. Any advice on what's wrong / how I can debug this?

majjam
  • 1,286
  • 2
  • 15
  • 32
  • Are you on the same network. Looks like just at glance you need to pass credentials using -credential – ArcSet Oct 18 '17 at 15:02
  • @ArcSet Yes on the same network, and my colleague running it remotely is setup on my computer to be able to execute commands via WMI (second link above). Do I still need to pass credentials in this case? – majjam Oct 18 '17 at 15:11
  • Yes please use the -credential – ArcSet Oct 18 '17 at 15:14
  • Is there a way of using Active Directory to provide authentication so that a user doesn't need to provide a password at the prompt? I had hoped that setting the user up for WMI would avoid that. – majjam Oct 18 '17 at 15:39
  • I believe this may provide a solution to pass credentials: https://stackoverflow.com/questions/6239647/using-powershell-credentials-without-being-prompted-for-a-password/6240319 – majjam Oct 18 '17 at 15:51
  • Is the user a domain admin, or just a local admin on the PC? If they're just local, they need to specify the PC name as the domain when providing credentials. – Maximilian Burszley Oct 18 '17 at 16:15
  • Why the downvote? – majjam Oct 18 '17 at 16:18

1 Answers1

-1

As described here:

Generally speaking, any operation that WMI can perform on the local computer can also be performed on a remote computer where you have local administrator privileges

Once I setup a user with admin privileges to use WMI on my computer they can execute the script remotely without passing credentials.

majjam
  • 1,286
  • 2
  • 15
  • 32