Notification

Icon
Error

Powershell Remote Shutdown with Different Creds - Remotely shutdown or restart a computer with credentials different than your current login

Posted: Tuesday, September 14, 2021 9:43:09 PM(UTC)
Wealthyreltub

Wealthyreltub

Member Original PosterPosts: 1
0
Like
I had an issue where I needed to remotely restart a computer but wasn't currently logged into a Domain Administrator account. I found a quick and simple powershell command and then adapted it into a Custom Action.

I placed it at the bottom of the list of built-in commands with "(PS)" added to the description. I also "turned on the safety" by checking that confirmation checkbox.

Expected behavior is that it will ask for confirmation, then pop up a powershell window, then pop up asking for the password for your given admin user account.

Reboot (PS):
Code:
powershell -noprofile -ExecutionPolicy bypass -command "&{ Restart-Computer -ComputerName {smartname} -Credential DOMAIN\ADMINUSERNAME -Force }


Shutdown (PS):
Code:
powershell -noprofile -ExecutionPolicy bypass -command "&{ Stop-Computer -ComputerName {smartname} -Credential DOMAIN\ADMINUSERNAME -Force }


Replace "DOMAIN\ADMINUSERNAME" with a Domain Admin account and you should be golden. Alternatively, replace it with "(Get-Credential)" to prompt for both the username and password each time.

I'm not digging into how to provide both the username AND password in this as I don't like passwords stored in plaintext and don't feel like figuring out how to store it into a secure string for this little command.

Active Discussions

Lansweeper Linux Agent - login user
by  Dinusha Chandrasinghe   Go to last post Go to first unread
Last post: Today at 11:03:07 AM(UTC)
Lansweeper device with multiple NICs
by  mzipperer  
Go to last post Go to first unread
Last post: Yesterday at 7:42:57 PM(UTC)
Lansweeper Internal Note
by  mdavis2503   Go to last post Go to first unread
Last post: Yesterday at 6:00:07 PM(UTC)
Lansweeper Problem with deploy software
by  Max90  
Go to last post Go to first unread
Last post: Yesterday at 12:09:40 PM(UTC)
Lansweeper Can lsagent be protected from deletion
by  RKCar   Go to last post Go to first unread
Last post: 11/29/2021 8:56:09 PM(UTC)
Lansweeper HTTPS not secure
by  Larry Rhea  
Go to last post Go to first unread
Last post: 11/29/2021 7:50:59 PM(UTC)
Lansweeper Warning about Built-in Admin
by  Larry Rhea   Go to last post Go to first unread
Last post: 11/29/2021 7:45:45 PM(UTC)