From 43139557af7291579feb582c5778b61aba35020b Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 20 Sep 2022 00:54:55 +0900 Subject: [PATCH] pwsh install script admin & version check --- bin/install.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 bin/install.ps1 diff --git a/bin/install.ps1 b/bin/install.ps1 new file mode 100644 index 0000000..d249c85 --- /dev/null +++ b/bin/install.ps1 @@ -0,0 +1,19 @@ +#!/usr/bin/pwsh + +# check administration role +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$bool_admin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +if (!$bool_admin) { + Write-Warning -Message "require Admin privilage + please run as Administrator" + exit 1 +} + +# check pwsh version +# ≧ 7 +if ($PSVersionTable.PSVersion.Major -lt 7) { + Write-Warning -Message "pwsh version must be greater than 7 + please install powershell 7 (Core) + you can install via winget" + exit 1 +} \ No newline at end of file