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
Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.