Server Fault Asked by ddimitrov on February 13, 2021
I am facing a peculiar setup, where I need to use local administrator on a windows machine. The instructions are as follows:
cmd
or Powershell shortcutI’d like to be able to skip step 1, and ideally perform the auth on the command line (avoiding the UAC).
My ideal flow would be:
Based on some searching, I’ve tried runas /netonly
, but it is not the same.
I bet any malware wants to just open up a console ant type privileged commands. That's why this is not (directly) possible.
You can, however, just ask for credentials through Get-Credential
and use the object later in the script to authenticate things.
For example, like this:
Get-Credential -Message "Credential for access to <whatever>" -User .administrator
It will look like this:
PowerShell Credential Request
Credential for access to <whatever>
Password for user .administrator:
Then you can use the object to do stuff:
Get-WmiObject -Class Win32_BIOS -Computer LOCALHOST -Credential $cred
Correct answer by bjoster on February 13, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP