-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGet-AdminRights.ps1
53 lines (50 loc) · 1.37 KB
/
Get-AdminRights.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<#
.Synopsis
Short description
This script will be used for downloafing the latest TortoiseGit version from its official site.
.DESCRIPTION
Long description
2021-02-06 Sukri Created.
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
.INPUTS
Inputs to this cmdlet (if any)
.OUTPUTS
Output from this cmdlet (if any)
.NOTES
General notes
Author : Sukri Kadir
Email : [email protected]
.COMPONENT
The component this cmdlet belongs to
.ROLE
The role this cmdlet belongs to
.FUNCTIONALITY
The functionality that best describes this cmdlet
#>
function Get-AdminRights {
Param
(
[ValidateNotNullOrEmpty()]
[String]
$IsAdministrator = $null # initialize the variable to null.
)
Begin {
#get boolean value if script ran with administration right.
$IsAdministrator = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
Process {
#verbose the message.
if ($IsAdministrator -eq $true) {
Write-Warning -Message "It is currently in administration right." -WarningAction Continue
}
if ($IsAdministrator -ne $true) {
Write-Warning -Message "It is currently NOT in administration right." -WarningAction Continue
}
}
End {
return $IsAdministrator
}
}