protected override void ProcessRecord()
        {
            // We have to invoke this here because we *may not* invoke
            // any Vault access but we do rely on Ext mechanism access.
            Util.PoshHelper.BeforeExtAccess();

            if (ReloadProviders)
            {
                ChallengeDecoderExtManager.Reload();
                ChallengeHandlerExtManager.Reload();
            }
            else if (!string.IsNullOrEmpty(GetChallengeType))
            {
                WriteVerbose("Getting details of Challenge Type Decoder");
                var tInfo = ChallengeDecoderExtManager.GetProviderInfo(GetChallengeType);
                var t     = ChallengeDecoderExtManager.GetProvider(GetChallengeType);
                WriteObject(new {
                    ChallengeType = tInfo.Type,
                    tInfo.Label,
                    tInfo.SupportedType,
                    tInfo.Description,
                });
            }
            else if (ListChallengeTypes)
            {
                WriteVerbose("Listing all Challenge Type Decoders");
                WriteObject(ChallengeDecoderExtManager.GetProviderInfos().Select(_ => _.Name), true);
            }
            else if (!string.IsNullOrEmpty(GetChallengeHandler))
            {
                WriteVerbose("Getting details of Challenge Type Handler");
                var pInfo = ChallengeHandlerExtManager.GetProviderInfo(GetChallengeHandler);
                var p     = ChallengeHandlerExtManager.GetProvider(GetChallengeHandler);
                if (ParametersOnly)
                {
                    WriteVerbose("Showing parameter details only");
                    WriteObject(p.DescribeParameters().Select(_ => new {
                        _.Name,
                        _.Label,
                        _.Type,
                        _.IsRequired,
                        _.IsMultiValued,
                        _.Description,
                    }), true);
                }
                else
                {
                    WriteObject(new {
                        pInfo.Name,
                        pInfo.Label,
                        pInfo.SupportedTypes,
                        pInfo.Description,
                        Parameters = p.DescribeParameters().Select(_ => new {
                            _.Name,
                            _.Label,
                            _.Type,
                            _.IsRequired,
                            _.IsMultiValued,
                            _.Description,
                        }),
                    });
                }
            }
            else if (ListChallengeHandlers)
            {
                WriteVerbose("Listing all Challenge Type Handlers");
                WriteObject(ChallengeHandlerExtManager.GetProviderInfos().Select(_ => _.Name), true);
            }
            else
            {
                WriteVerbose("Getting details of preconfigured Challenge Handler Profile");
                using (var vlt = Util.VaultHelper.GetVault(VaultProfile))
                {
                    vlt.OpenStorage();
                    var v = vlt.LoadVault();

                    if (ListProfiles)
                    {
                        WriteObject(v.ProviderProfiles?.Values, true);
                    }
                    else
                    {
                        var ppi = v.ProviderProfiles?.GetByRef(ProfileRef, throwOnMissing: false);
                        if (ppi == null)
                        {
                            WriteObject(ppi);
                        }
                        else
                        {
                            var asset = vlt.GetAsset(Vault.VaultAssetType.ProviderConfigInfo,
                                                     ppi.Id.ToString());
                            using (var s = vlt.LoadAsset(asset))
                            {
                                WriteObject(JsonHelper.Load <ProviderProfile>(s), false);
                            }
                        }
                    }
                }
            }
        }
        protected override void ProcessRecord()
        {
            using (var vlt = Util.VaultHelper.GetVault(VaultProfile))
            {
                vlt.OpenStorage();
                var v = vlt.LoadVault();

                if (v.ProviderProfiles == null)
                {
                    WriteVerbose("Initializing Provider Profile collection");
                    v.ProviderProfiles = new Vault.Util.EntityDictionary <Vault.Model.ProviderProfileInfo>();
                }

                WriteVerbose($"Searching for existing Provider Profile for reference [{ProfileName}]");
                var ppi = v.ProviderProfiles.GetByRef(ProfileName, throwOnMissing: false);
                if (ppi == null)
                {
                    WriteVerbose("No existing Profile found");
                }
                else
                {
                    WriteVerbose($"Existing Profile found [{ppi.Id}][{ppi.Alias}]");
                }

                if (!string.IsNullOrEmpty(Rename))
                {
                    if (ppi == null)
                    {
                        throw new KeyNotFoundException("no existing profile found that can be renamed");
                    }

                    v.ProviderProfiles.Rename(ProfileName, Rename);
                    ppi.Alias = Rename;
                }
                else if (Remove)
                {
                    WriteVerbose($"Removing named Provider Profile for name [{ProfileName}]");
                    if (ppi == null)
                    {
                        WriteVerbose("No Provider Profile found for given name");
                        return;
                    }
                    else
                    {
                        v.ProviderProfiles.Remove(ppi.Id);
                        WriteVerbose("Provider Profile removed");
                    }
                }
                else
                {
                    if (ppi != null)
                    {
                        if (!Force)
                        {
                            throw new InvalidOperationException("existing profile found;"
                                                                + " specify -Force to overwrite");
                        }

                        WriteVerbose("Removing existing Profile");
                        v.ProviderProfiles.Remove(ppi.Id);
                    }

                    if (ChallengeHandlerExtManager.GetProviderInfo(Handler) == null)
                    {
                        throw new ArgumentException("Unknown or invalid Handler provider name")
                              .With(nameof(Handler), Handler);
                    }

                    WriteVerbose("Adding new Provider Profile Info");
                    ppi = new Vault.Model.ProviderProfileInfo
                    {
                        Id    = Guid.NewGuid(),
                        Alias = ProfileName,
                        Label = Label,
                        Memo  = Memo,
                    };
                    var pp = new ProviderProfile
                    {
                        ProfileParameters = new Dictionary <string, object>
                        {
                            [nameof(ChallengeType)] = ChallengeType,
                        },
                        ProviderType       = ProviderType.CHALLENGE_HANDLER,
                        ProviderName       = Handler,
                        InstanceParameters = (IReadOnlyDictionary <string, object>
                                              )HandlerParameters.Convert <string, object>(),
                    };

                    var asset = vlt.CreateAsset(Vault.VaultAssetType.ProviderConfigInfo, ppi.Id.ToString());
                    using (var s = vlt.SaveAsset(asset))
                    {
                        JsonHelper.Save(s, pp);
                    }
                    v.ProviderProfiles.Add(ppi);
                }

                vlt.SaveVault(v);
            }
        }