Skip to content

Commit d173911

Browse files
committed
feat: New Get-AdminRights.ps1 function
1 parent bec7604 commit d173911

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<#
2+
.Synopsis
3+
Short description
4+
This script will be used for downloafing the latest TortoiseGit version from its official site.
5+
.DESCRIPTION
6+
Long description
7+
2021-02-06 Sukri Created.
8+
.EXAMPLE
9+
Example of how to use this cmdlet
10+
.EXAMPLE
11+
Another example of how to use this cmdlet
12+
.INPUTS
13+
Inputs to this cmdlet (if any)
14+
.OUTPUTS
15+
Output from this cmdlet (if any)
16+
.NOTES
17+
General notes
18+
Author : Sukri Kadir
19+
20+
.COMPONENT
21+
The component this cmdlet belongs to
22+
.ROLE
23+
The role this cmdlet belongs to
24+
.FUNCTIONALITY
25+
The functionality that best describes this cmdlet
26+
#>
27+
28+
function Get-AdminRights {
29+
Param
30+
(
31+
[ValidateNotNullOrEmpty()]
32+
[String]
33+
$IsAdministrator = $null # initialize the variable to null.
34+
)
35+
36+
Begin {
37+
#get boolean value if script ran with administration right.
38+
$IsAdministrator = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
39+
}
40+
Process {
41+
#verbose the message.
42+
if ($IsAdministrator -eq $true) {
43+
Write-Warning -Message "It is currently in administration right." -WarningAction Continue
44+
}
45+
46+
if ($IsAdministrator -ne $true) {
47+
Write-Warning -Message "It is currently NOT in administration right." -WarningAction Continue
48+
}
49+
}
50+
End {
51+
return $IsAdministrator
52+
}
53+
}

0 commit comments

Comments
 (0)