public override void Execute() { base.Execute(); MNM.TroubleshootingParameters parameters = new MNM.TroubleshootingParameters(); parameters.TargetResourceId = this.TargetResourceId; parameters.StorageId = this.StorageId; parameters.StoragePath = this.StoragePath; PSTroubleshootingResult troubleshoot = new PSTroubleshootingResult(); if (string.Equals(this.ParameterSetName, "SetByLocation", StringComparison.OrdinalIgnoreCase)) { var networkWatcher = this.GetNetworkWatcherByLocation(this.Location); if (networkWatcher == null) { throw new ArgumentException("There is no network watcher in location {0}", this.Location); } this.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(networkWatcher.Id); this.NetworkWatcherName = networkWatcher.Name; troubleshoot = GetTroubleshooting(this.ResourceGroupName, this.NetworkWatcherName, parameters); } else if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase)) { troubleshoot = GetTroubleshooting(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters); } else { troubleshoot = GetTroubleshooting(this.ResourceGroupName, this.NetworkWatcherName, parameters); } WriteObject(troubleshoot); }
public PSTroubleshootingResult GetTroubleshooting(string resourceGroupName, string name, MNM.TroubleshootingParameters parameters, string expandResource = null) { MNM.TroubleshootingResult troubleshoot = this.NetworkWatcherClient.GetTroubleshooting(resourceGroupName, name, parameters); PSTroubleshootingResult psTroubleshoot = NetworkResourceManagerProfile.Mapper.Map <PSTroubleshootingResult>(troubleshoot); return(psTroubleshoot); }