asked on
Hi Experts,
This is learning exercise for me..
I am trying work out how to check for local admin rights on a server and result a true or false.
My idea was to check if I can read the Security log, but my attempt at this approach always provides a True, regardless of result of Get-WinEvent.
$eventcheck = Get-WinEvent -FilterHashtable @{logname='security'} -MaxEvents 1
if (!($eventcheck)) {
$Adminrights = $false }
else {
$Adminrights = $true }
return $Adminrights
Any tips much appreciated.
Cheers
String