Phiên Hỏi & Đáp hôm nay đến với chúng tôi theo lịch sự của SuperUser - một phân khu của Stack Exchange, một nhóm các trang web Hỏi & Đáp do cộng đồng điều hành.
Câu hỏi
Trình đọc siêu người dùng Vlastimil muốn biết cách xác định hàm PowerShell đòi hỏi độ cao:
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).
Làm thế nào để bạn xác định một chức năng PowerShell đòi hỏi độ cao?
Câu trả lời
Người đóng góp SuperUser Ashton có câu trả lời cho chúng tôi:
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]
Có cái gì để thêm vào lời giải thích? Tắt âm thanh trong các ý kiến. Bạn muốn đọc thêm câu trả lời từ những người dùng Stack Exchange có hiểu biết công nghệ khác? Xem toàn bộ chuỗi thảo luận tại đây.