Dagens Spørsmål & Svar-sesjon kommer til oss med høflighet av SuperUser-en underavdeling av Stack Exchange, en fellesskapsdrevet gruppering av Q & A-nettsteder.
Spørsmålet
SuperUser-leser Vlastimil ønsker å vite hvordan du definerer en PowerShell-funksjon som krever høyde:
Since I cannot find any alternatives to Linux’s sudo elevation command, I have the following question. How do I define a PowerShell function that requires elevation, as in activating a UAC prompt on my Windows 8.1 Pro, 64-bit system? For example, say I run the following function:
To be completely clear, if I run PowerShell as “user”, then run the aforementioned function system-check, I want the function to elevate in order to be able to execute the command (I want the UAC prompt to appear).
Hvordan definerer du en PowerShell-funksjon som krever høyde?
Svaret
SuperUser-bidragsyter Ashton har svaret for oss:
To run a specific command from an elevated window:
A function to return $True or $False if the current window is running with elevated permissions:
In PowerShell v4.0, the above can be simplified by using a #Requires statement:
Source: Run with Elevated Permissions [SS64.com]
Har du noe å legge til forklaringen? Lyder av i kommentarene. Vil du lese flere svar fra andre tech-savvy Stack Exchange-brukere? Sjekk ut hele diskusjonstråden her.