/// <summary>
        /// Process record.
        /// </summary>
        protected override void ProcessRecord()
        {
            Sid sid;

            switch (ParameterSetName)
            {
            case "sddl":
                sid = new Sid(Sddl);
                break;

            case "name":
                sid = NtSecurity.LookupAccountName(Name);
                break;

            case "service":
                sid = NtSecurity.GetServiceSid(ServiceName);
                break;

            case "il":
                sid = NtSecurity.GetIntegritySid(IntegrityLevel);
                break;

            case "il_raw":
                sid = NtSecurity.GetIntegritySidRaw(IntegrityLevelRaw);
                break;

            case "package":
                sid = TokenUtils.DerivePackageSidFromName(PackageName);
                if (RestrictedPackageName != null)
                {
                    sid = TokenUtils.DeriveRestrictedPackageSidFromSid(sid, RestrictedPackageName);
                }
                break;

            case "known":
                sid = KnownSids.GetKnownSid(KnownSid);
                break;

            case "token":
                using (NtToken token = NtToken.OpenProcessToken())
                {
                    if (PrimaryGroup)
                    {
                        sid = token.PrimaryGroup;
                    }
                    else if (Owner)
                    {
                        sid = token.Owner;
                    }
                    else if (LogonGroup)
                    {
                        sid = token.LogonSid.Sid;
                    }
                    else if (AppContainer)
                    {
                        sid = token.AppContainerSid;
                    }
                    else if (Label)
                    {
                        sid = token.IntegrityLevelSid.Sid;
                    }
                    else
                    {
                        sid = token.User.Sid;
                    }
                }
                break;

            case "cap":
                sid = CapabilityGroup ? NtSecurity.GetCapabilityGroupSid(CapabilityName)
                                    : NtSecurity.GetCapabilitySid(CapabilityName);
                break;

            case "sid":
                sid = new Sid(SecurityAuthority, RelativeIdentifier ?? new uint[0]);
                break;

            case "rawsa":
                sid = new Sid(new SidIdentifierAuthority(SecurityAuthorityByte), RelativeIdentifier);
                break;

            case "logon":
                sid = NtSecurity.GetLogonSessionSid();
                break;

            case "trust":
                sid = NtSecurity.GetTrustLevelSid(TrustType, TrustLevel);
                break;

            case "ace":
                sid = AccessControlEntry.Sid;
                break;

            case "relsid":
                sid = BaseSid.CreateRelative(RelativeIdentifier);
                break;

            case "bytes":
                sid = new Sid(Byte);
                break;

            default:
                throw new ArgumentException("No SID type specified");
            }

            if (AsSddl)
            {
                WriteObject(sid.ToString());
            }
            else if (AsName)
            {
                WriteObject(sid.Name);
            }
            else
            {
                WriteObject(sid);
            }
        }
        /// <summary>
        /// Process record.
        /// </summary>
        protected override void ProcessRecord()
        {
            IEnumerable <Sid> sids;

            switch (ParameterSetName)
            {
            case "sddl":
                sids = Sddl.Select(s => new Sid(s));
                break;

            case "name":
                sids = Name.Select(s => NtSecurity.LookupAccountName(s));
                break;

            case "service":
                sids = ServiceName.Select(s => NtSecurity.GetServiceSid(s));
                break;

            case "il":
                sids = IntegrityLevel.Select(s => NtSecurity.GetIntegritySid(s));
                break;

            case "il_raw":
                sids = IntegrityLevelRaw.Select(s => NtSecurity.GetIntegritySidRaw(s));
                break;

            case "package":
                sids = PackageName.Select(s => TokenUtils.DerivePackageSidFromName(s));
                if (RestrictedPackageName != null)
                {
                    sids = sids.Select(s => TokenUtils.DeriveRestrictedPackageSidFromSid(s, RestrictedPackageName));
                }
                if (AsCapability)
                {
                    sids = sids.Select(s => NtSecurity.PackageSidToCapability(s));
                }
                break;

            case "known":
                sids = KnownSid.Select(s => KnownSids.GetKnownSid(s));
                break;

            case "token":
                using (NtToken token = NtToken.OpenProcessToken())
                {
                    Sid temp = null;
                    if (PrimaryGroup)
                    {
                        temp = token.PrimaryGroup;
                    }
                    else if (Owner)
                    {
                        temp = token.Owner;
                    }
                    else if (LogonGroup)
                    {
                        temp = token.LogonSid.Sid;
                    }
                    else if (AppContainer)
                    {
                        temp = token.AppContainerSid;
                    }
                    else if (Label)
                    {
                        temp = token.IntegrityLevelSid.Sid;
                    }
                    else
                    {
                        temp = token.User.Sid;
                    }
                    sids = new[] { temp };
                }
                break;

            case "cap":
                sids = CapabilityName.Select(s => CapabilityGroup ? NtSecurity.GetCapabilityGroupSid(s)
                        : NtSecurity.GetCapabilitySid(s));
                break;

            case "sid":
                sids = new[] { new Sid(SecurityAuthority, RelativeIdentifier ?? new uint[0]) };
                break;

            case "rawsa":
                sids = new[] { new Sid(new SidIdentifierAuthority(SecurityAuthorityByte), RelativeIdentifier) };
                break;

            case "logon":
                sids = new[] { NtSecurity.GetLogonSessionSid() };
                break;

            case "trust":
                sids = new[] { NtSecurity.GetTrustLevelSid(TrustType, TrustLevel) };
                break;

            case "ace":
                sids = AccessControlEntry.Select(a => a.Sid);
                break;

            case "relsid":
                sids = new[] { Sibling?BaseSid.CreateSibling(RelativeIdentifier) : BaseSid.CreateRelative(RelativeIdentifier) };
                break;

            case "bytes":
                sids = new[] { new Sid(Byte) };
                break;

            default:
                throw new ArgumentException("No SID type specified");
            }

            if (AsSddl)
            {
                WriteObject(sids.Select(s => s.ToString()), true);
            }
            else if (AsName)
            {
                WriteObject(sids.Select(s => s.Name), true);
            }
            else
            {
                WriteObject(sids, true);
            }
        }