So I’m looking for a way to remote shutdown multiple windows PCs. I did post this initally on tenforums, but I think I will have better luck on this forum.
So far I have:
Stopped windows defender on both PC’s, changed execution policy to unrestricted on both PC’s, checked all services to make sure they are running, followed this guide:
Did have a RPC error until I disabled windows defender, I assume I will need to add ports once I get this working.
The issue I am having now is this:
attempted to add the -Credential prompt, but I am continuing to get the following error (tried with and without):
Stop-Computer : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\Users\Render 1\Documents\stopseanpc.ps1:1 char:1
Either your account isn’t considered a local Administrator on the machine, or something on the machine is denying a shutdown (which is possible).
I’ve had more luck querying Win32_OperatingSystem from the remote computer, and executing the Win32Shutdown method. You can pass a parameter to not only shut down (or restart), but to FORCE the action, which is a bit stronger (in my experience) than what Stop-Computer does.
Sorry - didn’t realize you weren’t familiar with WMI.
Stop-Computer doesn’t do “multiple PCs at once;” internally, it enumerates them and does one at a time. Get-WmiObject and Invoke-WmiMethod do the same thing to any Windows computer (the “Win32” prefix in WMI is a legacy thing; it doesn’t denote a compatibility level).
I don’t have any ability to command Microsoft :). If you want their help, you probably need to open a support ticket. But they’re probably going to tell you pretty much what I have. WMI is worth the time to learn - it’s Microsoft’s official remote management technology for a lot of things (“Windows Management Instrumentation”), and PowerShell was built to leverage WMI pretty heavily.