forked from darkoperator/Posh-SecMod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosh-SecMod.psm1
More file actions
34 lines (29 loc) · 751 Bytes
/
Posh-SecMod.psm1
File metadata and controls
34 lines (29 loc) · 751 Bytes
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
function Get-LogDateString
{
(get-date).toString(‘yyyyMMddhhmm’)
}
function Confirm-IsAdmin
{
<#
.Synopsis
Checks if current PowerShell Session is running with administrative privelages.
.DESCRIPTION
Checks if current PowerShell Session is running with administrative privelages
.EXAMPLE
Return True or False if curremt PowerShell session is running with adminitratibe privelages.
PS c:\> Confirm-IsAdmin
True
#>
$sign = @"
using System;
using System.Runtime.InteropServices;
public static class priv
{
[DllImport("shell32.dll")]
public static extern bool IsUserAnAdmin();
}
"@
$adminasembly = Add-Type -TypeDefinition $sign -Language CSharp -PassThru
return [priv]::IsUserAnAdmin()
}