protected override void ProcessRecord() { IVault existingVault = null; var existingProfile = VaultProfileManager.GetProfile(ProfileName); if (existingProfile != null) { try { existingVault = Util.VaultHelper.GetVault(ProfileName); } catch (Exception) { } } if (Remove) { if (existingProfile == null) { return; } if (!Force && existingVault != null && existingVault.TestStorage()) { throw new InvalidOperationException("profile refers to an existing Vault;" + " specify -Force to remove anyway"); } VaultProfileManager.RemoveProfile(ProfileName); } else { if (!Force && existingProfile != null) { throw new InvalidOperationException("existing profile found;" + " specify -Force to overwrite"); } var pp = (IReadOnlyDictionary <string, object> )ProviderParameters.Convert <string, object>(); var vp = (IReadOnlyDictionary <string, object> )VaultParameters.Convert <string, object>(); VaultProfileManager.SetProfile(ProfileName, Provider, pp, vp); } }