public override void ExecuteCmdlet() { try { var serviceList = StorSimpleClient.GetAllResources().Cast <ResourceCredentials>().ToList(); if (serviceList == null || serviceList.Count() == 0) { //This is not an error scenario. Hence writing verbose is fine WriteVerbose(Resources.NoResourceFoundInSubscriptionMessage); WriteObject(null); return; } if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyByName) { serviceList = serviceList.Where(x => x.ResourceName.Equals(ResourceName, System.StringComparison.InvariantCultureIgnoreCase)).Cast <ResourceCredentials>().ToList(); if (serviceList.Count() == 0) { throw new ArgumentException(string.Format(Resources.NoResourceFoundWithGivenNameInSubscriptionMessage, ResourceName)); } } this.WriteObject(serviceList, true); WriteVerbose(string.Format(Resources.ResourceGet_StatusMessage, serviceList.Count(), (serviceList.Count() > 1 ? "s" : string.Empty))); } catch (Exception exception) { this.HandleException(exception); } }