Skip to content

Commit

Permalink
Update Other.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 authored Dec 17, 2024
1 parent bec1d9d commit 7bb45c4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Other.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1291,3 +1291,10 @@ else

# Check if a string is a GUID
[System.Guid]::Parse("2c9eefa9-825a-4a27-bd2a-ad575a2b3d71") -is [guid]

# Checking whether the logged-in user is an admin
$CurrentUserName = (Get-Process -Id $PID -IncludeUserName).UserName | Split-Path -Leaf
# $CurrentSessionId = (Get-Process -Id $PID -IncludeUserName).SessionId
# (Get-Process -Name explorer -IncludeUserName | Where-Object -FilterScript {$_.SessionId -eq $CurrentSessionId}).UserName | Select-Object -First 1 | Split-Path -Leaf
$LoginUserName = (Get-CimInstance -ClassName Win32_Process -Filter "name='explorer.exe'" | Invoke-CimMethod -MethodName GetOwner | Select-Object -First 1).User
# (New-Object -TypeName System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)

0 comments on commit 7bb45c4

Please sign in to comment.