全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

登錄


全部 新建 登錄

All gists matching topic powershell

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新
wthiel's Avatar

wthiel / Elevated Powershell Example

0 喜歡
0 分支
1 檔案
最後活躍 4 months ago
This script ensures that it runs with administrator privileges before executing the actual code. If no admin rights are available, it restarts itself with elevated privileges.
powershell
1 param([switch]$Elevated)
2
3 function Test-Admin {
4 $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
5 $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
6 }
7
8 if ((Test-Admin) -eq $false) {
9 if ($elevated) {
10 # tried to elevate, did not work, aborting
上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 29ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文