/// <summary> /// Executes the cmdlet. /// </summary> protected override void OnProcessRecord() { base.OnProcessRecord(); var options = new FilterDeploymentOptions(DeploymentScopeType.ManagementGroup) { ManagementGroupId = !string.IsNullOrEmpty(this.ManagementGroupId) ? this.ManagementGroupId : this.DeploymentObject.ManagementGroupId, DeploymentName = !string.IsNullOrEmpty(this.DeploymentName) ? this.DeploymentName : this.DeploymentObject.DeploymentName }; if (ShouldProcess(options.DeploymentName, VerbsData.Save)) { var template = ResourceManagerSdkClient.GetDeploymentTemplateAtManagementGroup(options.ManagementGroupId, options.DeploymentName); string path = FileUtility.SaveTemplateFile( templateName: options.DeploymentName, contents: template, outputPath: string.IsNullOrEmpty(this.Path) ? System.IO.Path.Combine(CurrentPath(), options.DeploymentName) : this.TryResolvePath(this.Path), overwrite: this.Force, shouldContinue: ShouldContinue); WriteObject(new PSTemplatePath() { Path = path }); } }