20
13
Since I can't find any alternative to Linux' sudo
elevation command, I have the following question:
How to define a PowerShell function which requires elevation? I mean UAC prompt.
Say, such function follows:
function system-check {
SFC /ScanNow
}
System:
Windows 8.1 Pro 64-bit
PowerShell:
Major Minor Build Revision ----- ----- ----- -------- 5 0 10586 117
EDIT1:
To be 100% understandable let me rephrase:
- I run PowerShell as user
- I run the aforementioned function
system-check
- I want the function to elevate in order to be able to execute the command; note, that I want the UAC prompt to appear
Note that many built in powershell commands and commands added by Microsoft modules (such as MSOL commands) often require elevation but in no way provide assistance in privilege elevation. They simply fail with cryptic error messages. If you build an elevation prompt into your scripts, you'll be providing more user friendliness than Microsoft themselves. – Todd Wilcox – 2017-08-11T12:22:29.097