public override void ExecuteCmdlet() { switch (ParameterSetName) { case GetManagedHsmParameterSet: ResourceGroupName = string.IsNullOrWhiteSpace(ResourceGroupName) ? GetResourceGroupName(Name, true) : ResourceGroupName; if (ShouldGetByName(ResourceGroupName, Name)) { WriteObject(FilterByTag(KeyVaultManagementClient.GetManagedHsm( Name, ResourceGroupName, GraphClient), Tag)); } else { WriteObject( TopLevelWildcardFilter( ResourceGroupName, Name, FilterByTag( KeyVaultManagementClient.ListManagedHsms(ResourceGroupName, GraphClient), Tag)), true); } break; case GetDeletedManagedHsmParameterSet: WriteObject(FilterByTag(KeyVaultManagementClient.GetDeletedManagedHsm( Name, Location), Tag)); break; case ListDeletedManagedHsmsParameterSet: WriteObject(FilterByTag( KeyVaultManagementClient.ListDeletedManagedHsms(), Tag), true); break; default: throw new ArgumentException(Resources.BadParameterSetName); } }
public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.InputObject)) { this.ResourceGroupName = this.InputObject.ResourceGroupName; this.Name = this.InputObject.Name; } if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } PSManagedHsm existingResource = null; try { existingResource = KeyVaultManagementClient.GetManagedHsm(this.Name, this.ResourceGroupName); } catch { existingResource = null; } if (existingResource == null) { throw new Exception(string.Format("A managed HSM with name '{0}' in resource group '{1}' does not exist. Please use New-AzManagedHsm to create a managed HSM with these properties.", this.Name, this.ResourceGroupName)); } if (this.ShouldProcess(this.Name, string.Format("Updating managed HSM '{0}' in resource group '{1}'.", this.Name, this.ResourceGroupName))) { var result = KeyVaultManagementClient.UpdateManagedHsm(existingResource, new VaultCreationOrUpdateParameters { Tags = Tag }, null); WriteObject(result); } }
public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.InputObject)) { this.ResourceGroupName = this.InputObject.ResourceGroupName; this.Name = this.InputObject.Name; } if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } PSManagedHsm existingResource = null; try { existingResource = KeyVaultManagementClient.GetManagedHsm(this.Name, this.ResourceGroupName); } catch { existingResource = null; } if (existingResource == null) { throw new Exception(string.Format(Resources.HsmNotFound, this.Name, this.ResourceGroupName)); } if (this.ShouldProcess(this.Name, string.Format(Resources.UpdateHsmShouldProcessMessage, this.Name, this.ResourceGroupName))) { var result = KeyVaultManagementClient.UpdateManagedHsm(existingResource, new VaultCreationOrUpdateParameters { Tags = Tag }, null); WriteObject(result); } }
public override void ExecuteCmdlet() { ResourceGroupName = string.IsNullOrWhiteSpace(ResourceGroupName) ? GetResourceGroupName(Name, true) : ResourceGroupName; if (ShouldGetByName(ResourceGroupName, Name)) { PSManagedHsm mhsm = KeyVaultManagementClient.GetManagedHsm( Name, ResourceGroupName, ActiveDirectoryClient); WriteObject(FilterByTag(mhsm, Tag)); } else { WriteObject( TopLevelWildcardFilter( ResourceGroupName, Name, FilterByTag( KeyVaultManagementClient.ListManagedHsms(ResourceGroupName, ActiveDirectoryClient), Tag)), true); } }
public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.InputObject)) { this.ResourceGroupName = this.InputObject.ResourceGroupName; this.Name = this.InputObject.Name; } if (this.IsParameterBound(c => c.ResourceId)) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = resourceIdentifier.ResourceGroupName; this.Name = resourceIdentifier.ResourceName; } PSManagedHsm existingResource = null; try { existingResource = KeyVaultManagementClient.GetManagedHsm(this.Name, this.ResourceGroupName); } catch { throw new Exception(string.Format(Resources.HsmNotFound, this.Name, this.ResourceGroupName)); } if (this.ShouldProcess(this.Name, string.Format(Resources.UpdateHsmShouldProcessMessage, this.Name, this.ResourceGroupName))) { var result = KeyVaultManagementClient.UpdateManagedHsm(existingResource, new VaultCreationOrUpdateParameters { // false is not accepted EnablePurgeProtection = this.EnablePurgeProtection.IsPresent ? (true as bool?) : null, PublicNetworkAccess = this.PublicNetworkAccess, Tags = this.Tag }, null); WriteObject(result); } }