Assert-SqlAccountStandard Validates an Active Directory account against a named compliance policy.
Description
Looks up the account in AD and asserts three policy invariants:
- ObjectClass matches the policy's Type (user, computer, gMSA).
- SamAccountName starts with the policy's Prefix when one is defined.
- DistinguishedName lives under the policy's OU.
Throws on first failure with all violations joined into the exception message. Returns $true on full compliance. Designed to be called as a pre-flight check inside Start-SqlSpnConfiguration; can also be called standalone for ad-hoc validation.
Recipes
Recipe 1
EXAMPLE 1
Assert-SqlAccountStandard -SamAccountName svc_sql_prod -PolicyName Std_Engine
Recipe 2
EXAMPLE 2
Resolve-SqlPolicyFromContext -Scenario FCI -Role Engine | ForEach-Object {
Assert-SqlAccountStandard -SamAccountName 'SQLFCI01