protected override void ProcessRecord() { using (var policy = new LsaPolicy(this.ComputerName, LsaPolicyAccessMask.ViewLocalInformation)) { var policyInfo = new LsaPolicyInformation() { DnsDomain = policy.QueryDnsDomainInformation(), Domain = policy.QueryAccountDomainInformation(), LocalDomain = policy.QueryLocalAccountDomainInformation(), MachineAccountSid = policy.QueryMachineAccountInformation() }; this.WriteObject(policyInfo); } }
public void LsaPolicy_QueryMachineAccountInformation() { try { using (var policy = new LsaPolicy(LsaPolicyAccessMask.ViewLocalInformation)) { var result = policy.QueryMachineAccountInformation(); } } catch (UnauthorizedAccessException e) { // This is expected. throw new AssertInconclusiveException("LSA-related tests require admin rights.", e); } }