Created
May 6, 2020 09:52
-
-
Save tex2e/e1471b1680d9e54fdde5cb534fd5cd19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "[INFO] ExecutionPolicy:" (Get-ExecutionPolicy) | |
Write-Host "" | |
function prompt { | |
if (Test-IsAdmin) { | |
$inputSign = " [admin]> " | |
} else { | |
$inputSign = " > " | |
} | |
"PS \" + (Get-Item -Path ".").Name + $inputSign | |
} | |
function Test-IsAdmin { | |
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | |
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
Set-Alias gh Get-Help | |
# Notepadを使ってWindows10環境のhostsファイルを管理者権限で開く | |
function CustomHosts { | |
Start-Process notepad C:\Windows\System32\drivers\etc\hosts -verb runas | |
} | |
Set-Alias hosts CustomHosts | |
# PowerShellを管理者権限として実行する | |
function CustomSudo { | |
Start-Process powershell.exe -Verb runas | |
} | |
Set-Alias sudo CustomSudo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment