Afin de désactiver le compte Administrateur local par défaut dans Windows, ceci peut être simple en utilisant un script de remédiation Intune.
Script de détection :
$user = (Get-WmiObject -Class Win32_UserAccount -Filter 'LocalAccount = True ' | Where-Object SID -Like 'S-1-5-*-500').Name
$Status= (Get-WmiObject -Class Win32_UserAccount -Filter 'LocalAccount = True ' | Where-Object SID -Like 'S-1-5-*-500').Disabled
if ($Status -eq $false)
{
Write-Host "$user is Enabled"
Exit 1
}
Else {
Write-Host "$user is not Enabled"
Exit 0
}
Script de remédiation :
$user = (Get-WmiObject -Class Win32_UserAccount -Filter 'LocalAccount = True ' | Where-Object SID -Like 'S-1-5-*-500').Name
$Status= (Get-WmiObject -Class Win32_UserAccount -Filter 'LocalAccount = True ' | Where-Object SID -Like 'S-1-5-*-500').Disabled
if ($Status -eq $false)
{
try{
NET USER $user /active:No
Exit 0
}
Catch {
Write-Host "$user is already Disabled"
Write-error $_
Exit 1
}
}
Else {
Write-Host "$user is already Disabled"
Exit 1
}