See Detection here
# get the list of user names that are member of the Administrators group
# we can't use Get-LocalGroupMember due to bug https://github.com/PowerShell/PowerShell/issues/2996
# remove empty and non usable lines of the output
$localadminallow = "localadmin"
#get Local Admins
$adminlist = (net localgroup Administrators) | Where-Object { $_ -match '\S' } | Select-Object -Skip 4 | Select-Object -SkipLast 1
#does our lap local admin exist and in Admin Group?
if ($localadminallow -in $adminlist){
# now filter away the domain members you do not want to be listed
$domain = "domain.local"
$Regexes = '^(?!'+$domain+'\\).*$'
$localAdmins = ($adminlist | Select-String -Pattern $Regexes).Line
# now filter away the allow local admins
$localAdmins = $localAdmins | Where-Object { $localadminallow -ne $_ }
#Disable local Admins
$ActiveLocalAdmins = foreach ($admin in $localAdmins)
{
(Get-LocalUser -Name $admin | ? {$_.enabled -eq 'True'}) | Disable-LocalUser
}
}
else
{
Write-Host "$localadminallow Does not exist"
}