public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (ShouldProcess("BlobDeleteRetentionPolicy", "Disable")) { switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case PropertiesResourceIdParameterSet: ResourceIdentifier blobServicePropertiesResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = blobServicePropertiesResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } BlobServiceProperties serviceProperties = this.StorageClient.BlobServices.GetServiceProperties(this.ResourceGroupName, this.StorageAccountName); serviceProperties.DeleteRetentionPolicy.Enabled = false; serviceProperties.DeleteRetentionPolicy.Days = null; serviceProperties = this.StorageClient.BlobServices.SetServiceProperties(this.ResourceGroupName, this.StorageAccountName, serviceProperties); if (PassThru) { WriteObject(new PSDeleteRetentionPolicy(serviceProperties.DeleteRetentionPolicy)); } } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); // Check input parameter // ShareRetentionDays should only be specified when EnableShareDeleteRetentionPolicy is true if (this.enableShareDeleteRetentionPolicy == null || this.enableShareDeleteRetentionPolicy.Value == false) { if (this.ShareRetentionDays != 0) { throw new ArgumentException("ShareRetentionDays should only be specified when EnableShareDeleteRetentionPolicy is true."); } } else { if (this.ShareRetentionDays == 0) { throw new ArgumentException("ShareRetentionDays must be specified when EnableShareDeleteRetentionPolicy is true."); } } if (ShouldProcess("FileServiceProperties", "Update")) { switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case PropertiesResourceIdParameterSet: ResourceIdentifier blobServicePropertiesResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = blobServicePropertiesResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } DeleteRetentionPolicy deleteRetentionPolicy = null; if (this.enableShareDeleteRetentionPolicy != null) { deleteRetentionPolicy = new DeleteRetentionPolicy(); deleteRetentionPolicy.Enabled = this.enableShareDeleteRetentionPolicy.Value; if (this.enableShareDeleteRetentionPolicy.Value == true) { deleteRetentionPolicy.Days = ShareRetentionDays; } } FileServiceProperties serviceProperties = this.StorageClient.FileServices.SetServiceProperties(this.ResourceGroupName, this.StorageAccountName, new FileServiceProperties(shareDeleteRetentionPolicy: deleteRetentionPolicy)); // Get all File service properties from server for output serviceProperties = this.StorageClient.FileServices.GetServiceProperties(this.ResourceGroupName, this.StorageAccountName); WriteObject(new PSFileServiceProperties(serviceProperties)); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (ShouldProcess("BlobServiceProperties", "Update")) { switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case PropertiesResourceIdParameterSet: ResourceIdentifier blobServicePropertiesResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = blobServicePropertiesResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } BlobServiceProperties serviceProperties = new BlobServiceProperties(); if (DefaultServiceVersion != null) { serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion; } if (enableChangeFeed != null) { serviceProperties.ChangeFeed = new ChangeFeed(); serviceProperties.ChangeFeed.Enabled = enableChangeFeed; if (this.changeFeedRetentionInDays != null) { serviceProperties.ChangeFeed.RetentionInDays = this.changeFeedRetentionInDays; } } else { if (this.changeFeedRetentionInDays != null) { throw new ArgumentException("ChangeFeed RetentionInDays can only be specified when enable Changefeed.", "ChangeFeedRetentionInDays"); } } if (isVersioningEnabled != null) { serviceProperties.IsVersioningEnabled = isVersioningEnabled; } serviceProperties = this.StorageClient.BlobServices.SetServiceProperties(this.ResourceGroupName, this.StorageAccountName, serviceProperties); //Get the full service properties for output serviceProperties = this.StorageClient.BlobServices.GetServiceProperties(this.ResourceGroupName, this.StorageAccountName); WriteObject(new PSBlobServiceProperties(serviceProperties)); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); switch (ParameterSetName) { case AccountObjectSingleParameterSet: case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case ShareResourceIdParameterSet: if (!string.IsNullOrEmpty(this.Name)) { WriteWarning("The -Name parameter will be omit, as -ResourceId already contains share name."); } ResourceIdentifier shareResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = shareResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); this.Name = shareResource.ResourceName; break; default: // For AccountNameParameterSet, AccountNameSingleParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } if (!string.IsNullOrEmpty(this.Name)) { GetShareExpand?expend = null; if (this.GetShareUsage) { expend = GetShareExpand.Stats; } var Share = this.StorageClient.FileShares.Get( this.ResourceGroupName, this.StorageAccountName, this.Name, expend); WriteObject(new PSShare(Share)); } else { IPage <FileShareItem> shares = this.StorageClient.FileShares.List( this.ResourceGroupName, this.StorageAccountName); WriteShareList(shares); while (shares.NextPageLink != null) { shares = this.StorageClient.FileShares.ListNext(shares.NextPageLink); WriteShareList(shares); } } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); switch (ParameterSetName) { case ShareObjectParameterSet: this.ResourceGroupName = InputObject.ResourceGroupName; this.StorageAccountName = InputObject.StorageAccountName; this.Name = InputObject.Name; break; case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case ShareResourceIdParameterSet: ResourceIdentifier shareResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = shareResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); this.Name = shareResource.ResourceName; break; default: break; } if (ShouldProcess(this.Name, "Update Share")) { Dictionary <string, string> MetadataDictionary = CreateMetadataDictionary(Metadata, validate: true); var Share = this.StorageClient.FileShares.Update( this.ResourceGroupName, this.StorageAccountName, this.Name, new FileShare( metadata: MetadataDictionary, shareQuota: shareQuota, rootSquash: this.RootSquash, accessTier: accessTier)); WriteObject(new PSShare(Share)); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (ShouldProcess("BlobServiceProperties", "Update")) { switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case PropertiesResourceIdParameterSet: ResourceIdentifier blobServicePropertiesResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = blobServicePropertiesResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } BlobServiceProperties serviceProperties = null; serviceProperties = this.StorageClient.BlobServices.GetServiceProperties(this.ResourceGroupName, this.StorageAccountName); if (DefaultServiceVersion != null) { serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion; } if (enableChangeFeed != null) { serviceProperties.ChangeFeed = new ChangeFeed(); serviceProperties.ChangeFeed.Enabled = enableChangeFeed; } if (isVersioningEnabled != null) { serviceProperties.IsVersioningEnabled = isVersioningEnabled; } serviceProperties = this.StorageClient.BlobServices.SetServiceProperties(this.ResourceGroupName, this.StorageAccountName, serviceProperties); WriteObject(new PSBlobServiceProperties(serviceProperties)); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (ShouldProcess(this.Name, "Remove Share")) { switch (ParameterSetName) { case ShareObjectParameterSet: this.ResourceGroupName = InputObject.ResourceGroupName; this.StorageAccountName = InputObject.StorageAccountName; this.Name = InputObject.Name; break; case AccountObjectParameterSet: case AccountObjectSnapshotParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case ShareResourceIdParameterSet: ResourceIdentifier shareResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = shareResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); this.Name = shareResource.ResourceName; break; default: break; } if (Force.IsPresent || ShouldContinue(String.Format("Remove Share and all files in it: {0}", this.Name), "")) { this.StorageClient.FileShares.Delete( this.ResourceGroupName, this.StorageAccountName, this.Name, xMsSnapshot: this.SnapshotTime is null ? null : this.SnapshotTime.Value.ToUniversalTime().ToString("o"), include: include.ToLower()); if (PassThru.IsPresent) { WriteObject(true); } } } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case ShareResourceIdParameterSet: ResourceIdentifier shareResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = shareResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); this.Name = shareResource.ResourceName; break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } if (!string.IsNullOrEmpty(this.Name)) { var Share = this.StorageClient.FileShares.Get( this.ResourceGroupName, this.StorageAccountName, this.Name); WriteObject(new PSShare(Share)); } else { var Shares = this.StorageClient.FileShares.List( this.ResourceGroupName, this.StorageAccountName); WriteShareList(Shares); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case PropertiesResourceIdParameterSet: ResourceIdentifier blobServicePropertiesResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = blobServicePropertiesResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } BlobServiceProperties serviceProperties = this.StorageClient.BlobServices.GetServiceProperties(this.ResourceGroupName, this.StorageAccountName); WriteObject(new PSBlobServiceProperties(serviceProperties)); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); switch (ParameterSetName) { case AccountObjectSingleParameterSet: case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case ShareResourceIdParameterSet: if (!string.IsNullOrEmpty(this.Name)) { WriteWarning("The -Name parameter will be omit, as -ResourceId already contains share name."); } ResourceIdentifier shareResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = shareResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); this.Name = shareResource.ResourceName; break; default: // For AccountNameParameterSet, AccountNameSingleParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } if (!string.IsNullOrEmpty(this.Name)) { string expend = null; if (this.GetShareUsage) { expend = ShareGetExpand.Stats; } var Share = this.StorageClient.FileShares.Get( this.ResourceGroupName, this.StorageAccountName, this.Name, expend, xMsSnapshot: this.SnapshotTime is null? null : this.SnapshotTime.Value.ToUniversalTime().ToString("o")); WriteObject(new PSShare(Share)); } else { string listSharesExpand = null; if (this.IncludeDeleted.IsPresent) { listSharesExpand = ShareListExpand.Deleted; } if (this.IncludeSnapshot.IsPresent) { listSharesExpand = string.IsNullOrEmpty(listSharesExpand) ? ShareListExpand.Snapshots : listSharesExpand + "," + ShareListExpand.Snapshots; } IPage <FileShareItem> shares = this.StorageClient.FileShares.List( this.ResourceGroupName, this.StorageAccountName, expand: listSharesExpand); WriteShareList(shares); while (shares.NextPageLink != null) { shares = this.StorageClient.FileShares.ListNext(shares.NextPageLink); WriteShareList(shares); } } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); // Check input parameter // ShareRetentionDays should only be specified when EnableShareDeleteRetentionPolicy is true if (this.enableShareDeleteRetentionPolicy == null || this.enableShareDeleteRetentionPolicy.Value == false) { if (this.ShareRetentionDays != 0) { throw new ArgumentException("ShareRetentionDays should only be specified when EnableShareDeleteRetentionPolicy is true."); } } else { if (this.ShareRetentionDays == 0) { throw new ArgumentException("ShareRetentionDays must be specified when EnableShareDeleteRetentionPolicy is true."); } } if (ShouldProcess("FileServiceProperties", "Update")) { switch (ParameterSetName) { case AccountObjectParameterSet: this.ResourceGroupName = StorageAccount.ResourceGroupName; this.StorageAccountName = StorageAccount.StorageAccountName; break; case PropertiesResourceIdParameterSet: ResourceIdentifier blobServicePropertiesResource = new ResourceIdentifier(ResourceId); this.ResourceGroupName = blobServicePropertiesResource.ResourceGroupName; this.StorageAccountName = PSBlobServiceProperties.GetStorageAccountNameFromResourceId(ResourceId); break; default: // For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly break; } DeleteRetentionPolicy deleteRetentionPolicy = null; if (this.enableShareDeleteRetentionPolicy != null) { deleteRetentionPolicy = new DeleteRetentionPolicy(); deleteRetentionPolicy.Enabled = this.enableShareDeleteRetentionPolicy.Value; if (this.enableShareDeleteRetentionPolicy.Value == true) { deleteRetentionPolicy.Days = ShareRetentionDays; } } ProtocolSettings protocolSettings = null; if (this.SmbProtocolVersion != null || this.SmbAuthenticationMethod != null || this.SmbKerberosTicketEncryption != null || this.SmbChannelEncryption != null || this.enableSmbMultichannel != null) { protocolSettings = new ProtocolSettings(); protocolSettings.Smb = new SmbSetting(); if (this.SmbProtocolVersion != null) { protocolSettings.Smb.Versions = ConnectStringArray(this.SmbProtocolVersion); } if (this.SmbAuthenticationMethod != null) { protocolSettings.Smb.AuthenticationMethods = ConnectStringArray(this.SmbAuthenticationMethod); } if (this.SmbKerberosTicketEncryption != null) { protocolSettings.Smb.KerberosTicketEncryption = ConnectStringArray(this.SmbKerberosTicketEncryption); } if (this.SmbChannelEncryption != null) { protocolSettings.Smb.ChannelEncryption = ConnectStringArray(this.SmbChannelEncryption); } if (this.enableSmbMultichannel != null) { protocolSettings.Smb.Multichannel = new Multichannel(); protocolSettings.Smb.Multichannel.Enabled = this.enableSmbMultichannel; } } FileServiceProperties serviceProperties = this.StorageClient.FileServices.SetServiceProperties(this.ResourceGroupName, this.StorageAccountName, new FileServiceProperties(shareDeleteRetentionPolicy: deleteRetentionPolicy, protocolSettings: protocolSettings)); // Get all File service properties from server for output serviceProperties = this.StorageClient.FileServices.GetServiceProperties(this.ResourceGroupName, this.StorageAccountName); WriteObject(new PSFileServiceProperties(serviceProperties)); } }