public override void ExecuteCmdlet() { ConfirmAction(Force.IsPresent, Resources.RemoveWarningVolume, Resources.RemoveConfirmationVolume, string.Empty, () => { try { var deviceid = StorSimpleClient.GetDeviceId(DeviceName); if (deviceid == null) { WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); WriteObject(null); return; } string volumeId = string.Empty; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.IdentifyByObject: volumeId = Volume.InstanceId; break; case StorSimpleCmdletParameterSet.IdentifyByName: var volumeInfo = StorSimpleClient.GetVolumeByName(deviceid, VolumeName); if (volumeInfo == null) { WriteVerbose(Resources.NotFoundMessageVirtualDisk); return; } volumeId = volumeInfo.VirtualDiskInfo.InstanceId; break; } if (WaitForComplete.IsPresent) { WriteVerbose("About to run a task to remove your volume!"); var taskstatus = StorSimpleClient.RemoveVolume(deviceid, volumeId); HandleSyncTaskResponse(taskstatus, "delete"); } else { WriteVerbose("About to run a task to remove your volume!"); var taskresponse = StorSimpleClient.RemoveVolumeAsync(deviceid, volumeId); HandleAsyncTaskResponse(taskresponse, "delete"); } } catch (Exception exception) { this.HandleException(exception); } }); }