How to run powershell as admin using a command?

Hi everyone,

I’m trying to unlock my usb drive using powershell but I dont want others to see the password when opening the script so i turned the script into an executable. Sadly i cant execute the command because it doesn’t have access.

Is there a command to give admin power ?

$SecureString = ConvertTo-SecureString "XXX" -AsPlainText -Force
Unlock-BitLocker -MountPoint "E:" -Password $SecureString

Thanks !

You know that that’s not a protection, don’t you? You should never include passwords in a script.

There are ways to tell a process to run with elevated rights. Here you have some examples:

Thanks for your quick reply,
Is there another way to protect the password?

Thank you for the links

Thank you,

Quick question out of the box, when I execute the script I get an output

Is it possible to not get an output?

Do you actually use an internet search by yourself sometimes? :smirk: … it would have taken you seconds to figure that out by yourself.

https://www.google.com/search?q=Powershell+suppress+output&oq=Powershell+suppress+output

And BTW:

Just in case you didn’t get that … that’s what I meant actually. It is not a protection to turn your scripts into executables. It does not take that long to tern those executables back into plain text. :point_up_2:t4: :point_up_2:t4:

I did google it but the solutions i found about suppressing the output didn’t work. And sorry if I didn’t understand your reply about the problem of converting the script into an executable. English is not my first language. Thanks for the help !