-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.ps1
31 lines (26 loc) · 1.07 KB
/
test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
param(
[Parameter(Mandatory=$False, Position=0, ValueFromPipeline=$false)]
[System.String]
$Param1="help",
[Parameter(Mandatory=$False, Position=1, ValueFromPipeline=$false)]
[System.String]
$Param2="xx-xx-xx"
)
Write-Host $Param2
if ($Param1 -eq "help") {
Write-Host $Param1
}
# $isAdmin=([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
# if (!$isAdmin) {
# # Start-Process pwsh "-NoLogo -ExecutionPolicy Bypass -Command $PSCommandPath -Param1 $Param1 -Param2 $Param2" -Verb RunAs; # //Run this script as Administrator.
# # exit # //Exit from this non elevated context.
# }
# Write-Host $isAdmin
# function Test-Admin {
# $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
# $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
# }
# # If we are in a non-admin execution. Execute this script as admin
# if ((Test-Admin) -eq $false) {
# exit
# }