You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have several commands in PowerShell that require to be ran as Administrator.
Describe the solution you'd like
A button or prompt to run as admin
Describe alternatives you've considered
I tried putting a command I got from ChatGPT in the inject PowerShell code that elevates the script but that didn't seem to work. Although the UAC prompt showed up which was promising but the code never ran. besides I don't want all code to be elevated if I can avoid it only code that needs elevation.
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File "$PSCommandPath"" -Verb RunAs
Additional context
I did look around for this solution or question but couldn't find any, apologies if this has been asked before
Any and all help is appreciated, love this plugin. Saved me lots of work and time already
The text was updated successfully, but these errors were encountered:
It failed before because the temporary script file $PSCommandPath gets deleted immediately after the code block script finishes, so before the elevated powershell can call it. Use Start-Sleep 10 to keep it running for some time, while the new terminal launches and calls the same file.
Thank you very much for your reply, I ended up using the new Sudo command in Windows 11 24H2. That way I can also elevate only parts that require admin privileges which is best practice anyway. For anyone wondering i am using this.
the wt launches in a new window and then you can interact with the terminal, if you want the terminal in the obsidian code block remove the wt depends what you want to do with the script.
Is your feature request related to a problem? Please describe.
I have several commands in PowerShell that require to be ran as Administrator.
Describe the solution you'd like
A button or prompt to run as admin
Describe alternatives you've considered
I tried putting a command I got from ChatGPT in the inject PowerShell code that elevates the script but that didn't seem to work. Although the UAC prompt showed up which was promising but the code never ran. besides I don't want all code to be elevated if I can avoid it only code that needs elevation.
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File
"$PSCommandPath
"" -Verb RunAsAdditional context
I did look around for this solution or question but couldn't find any, apologies if this has been asked before
Any and all help is appreciated, love this plugin. Saved me lots of work and time already
The text was updated successfully, but these errors were encountered: