Is there a cmdlet or some other way to find out whether my current PowerShell console runs as administrator, i.e. elevated?
Try this code:
if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "Elevated."
} else {
Write-Host "Not elevated."
}
Attribution: https://www.itprotoday.com/powershell/check-elevation-powershell