Ejemplo n.º 1
0
        public override void Execute()
        {
            base.Execute();
            MNM.QueryTroubleshootingParameters parameters = new MNM.QueryTroubleshootingParameters();
            parameters.TargetResourceId = this.TargetResourceId;

            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 (ParameterSetName.Contains("SetByResource"))
            {
                troubleshoot = GetTroubleshooting(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters);
            }
            else
            {
                troubleshoot = GetTroubleshooting(this.ResourceGroupName, this.NetworkWatcherName, parameters);
            }
            WriteObject(troubleshoot);
        }
        public override void Execute()
        {
            base.Execute();
            MNM.QueryTroubleshootingParameters parameters = new MNM.QueryTroubleshootingParameters();
            parameters.TargetResourceId = this.TargetResourceId;

            PSTroubleshootResult troubleshoot = new PSTroubleshootResult();

            if (ParameterSetName.Contains("SetByResource"))
            {
                troubleshoot = GetTroubleshooting(this.NetworkWatcher.ResourceGroupName, this.NetworkWatcher.Name, parameters);
            }
            else
            {
                troubleshoot = GetTroubleshooting(this.ResourceGroupName, this.NetworkWatcherName, parameters);
            }
            WriteObject(troubleshoot);
        }
        public PSTroubleshootResult GetTroubleshooting(string resourceGroupName, string name, MNM.QueryTroubleshootingParameters parameters)
        {
            MNM.TroubleshootingResult troubleshoot = this.NetworkWatcherClient.GetTroubleshootingResult(resourceGroupName, name, parameters);

            PSTroubleshootResult psTroubleshoot = Mapper.Map <PSTroubleshootResult>(troubleshoot);

            return(psTroubleshoot);
        }