// GET: AutoPilotConfigurationJSON public async System.Threading.Tasks.Task <ActionResult> Index() { GraphIntune graphIntune = new GraphIntune(null); var AutopilotProfiles = await graphIntune.GetWindowsAutopilotDeploymentProfiles(); return(View(AutopilotProfiles)); }
public async System.Threading.Tasks.Task <FileResult> DownloadDeviceManagementScript(String Id) { GraphIntune graphIntune = new GraphIntune(null); DeviceManagementScript script = await graphIntune.GetDeviceManagementScriptAsync(Id); return(File(script.ScriptContent, "text/plain", script.FileName)); }
public async Task <ActionResult> Win32AppDetectionScripts() { try { GraphIntune graphIntune = new GraphIntune(null); var apps = await graphIntune.GetWin32MobileAppsAsync(); List <Win32LobApp> win32LobApps = new List <Win32LobApp>(); foreach (Win32LobApp app in apps) { var details = await graphIntune.GetWin32MobileAppAsync(app.Id); if (details.DetectionRules.Any(d => d is Win32LobAppPowerShellScriptDetection)) { win32LobApps.Add(details); } } return(View(win32LobApps)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async System.Threading.Tasks.Task <ViewResult> Win32AppDetectionScripts() { try { GraphIntune graphIntune = new GraphIntune(null); var apps = await graphIntune.GetWin32MobileAppsAsync(); List <Win32LobApp> win32LobApps = new List <Win32LobApp>(); foreach (Win32LobApp app in apps) { var details = await graphIntune.GetWin32MobileAppAsync(app.Id); if (details.DetectionRules.Any(d => d is Win32LobAppPowerShellScriptDetection)) { win32LobApps.Add(details); } } return(View(win32LobApps)); } catch (Exception e) { Flash("Error " + e.Message.ToString()); return(View()); } }
public async System.Threading.Tasks.Task <ActionResult> Detail(String Id) { GraphIntune graphIntune = new GraphIntune(null); var AutopilotProfile = await graphIntune.GetWindowsAutopilotDeploymentProfile(Id); return(View(AutopilotProfile)); }
public async System.Threading.Tasks.Task <FileResult> DownloadDetectionScript(string Id) { GraphIntune graphIntune = new GraphIntune(null); Win32LobApp win32LobApp = await graphIntune.GetWin32MobileAppAsync(Id); Win32LobAppPowerShellScriptDetection script = await graphIntune.GetWin32MobileAppPowerShellDetectionRuleAsync(Id); string fileName = $"{FilenameHelper.ProcessFileName(win32LobApp.DisplayName)}_detect.ps1"; return(File(Convert.FromBase64String(script.ScriptContent), "text/plain", fileName)); }
public async System.Threading.Tasks.Task <ViewResult> DeviceManagementScripts() { try { GraphIntune graphIntune = new GraphIntune(null); var scripts = await graphIntune.GetDeviceManagementScriptsAsync(); return(View(scripts)); } catch (Exception e) { Flash("Error getting DeviceManagementScripts" + e.Message.ToString()); return(View()); } }
public async Task <ActionResult> Detail(String Id) { try { GraphIntune graphIntune = new GraphIntune(null); var AutopilotProfile = await graphIntune.GetWindowsAutopilotDeploymentProfile(Id); return(View(AutopilotProfile)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> DeviceManagementScripts() { try { GraphIntune graphIntune = new GraphIntune(null); var scripts = await graphIntune.GetDeviceManagementScriptsAsync(); return(View(scripts)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> DownloadDeviceManagementScript(String Id) { try { GraphIntune graphIntune = new GraphIntune(null); DeviceManagementScript script = await graphIntune.GetDeviceManagementScriptAsync(Id); return(File(script.ScriptContent, "text/plain", script.FileName)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async System.Threading.Tasks.Task <PartialViewResult> Win32AppPsDetectionScriptContent(string Id) { try { GraphIntune graphIntune = new GraphIntune(null); var script = await graphIntune.GetWin32MobileAppPowerShellDetectionRuleAsync(Id); string powerShellCode = Encoding.UTF8.GetString(Convert.FromBase64String(script.ScriptContent)); return(PartialView("_PowerShellDetectionScriptContent", powerShellCode)); } catch (Exception e) { Flash("Error getting DeviceManagementScripts" + e.Message.ToString()); return(PartialView()); } }
public async System.Threading.Tasks.Task <PartialViewResult> PowerShellScriptContent(string Id) { try { GraphIntune graphIntune = new GraphIntune(null); var scripts = await graphIntune.GetDeviceManagementScriptAsync(Id); string powerShellCode = Encoding.UTF8.GetString(scripts.ScriptContent); return(PartialView("_PowerShellScriptContent", powerShellCode)); } catch (Exception e) { Flash("Error getting DeviceManagementScripts" + e.Message.ToString()); return(PartialView()); } }
public async Task <ActionResult> PowerShellScriptContent(string Id) { try { GraphIntune graphIntune = new GraphIntune(null); var scripts = await graphIntune.GetDeviceManagementScriptAsync(Id); string powerShellCode = Encoding.UTF8.GetString(scripts.ScriptContent); return(PartialView("_PowerShellScriptContent", powerShellCode)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> Win32AppPsDetectionScriptContent(string Id) { try { GraphIntune graphIntune = new GraphIntune(null); var script = await graphIntune.GetWin32MobileAppPowerShellDetectionRuleAsync(Id); string powerShellCode = Encoding.UTF8.GetString(Convert.FromBase64String(script.ScriptContent)); return(PartialView("_PowerShellDetectionScriptContent", powerShellCode)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> ClearAll(bool confirm = false) { try { GraphIntune graphIntune = new GraphIntune(null); if (confirm) { await graphIntune.ClearIntuneTenant(); } return(new HttpStatusCodeResult(204)); } catch (Exception e) { Flash(e.Message); return(RedirectToAction("Index", "Home")); } }
public async Task <ActionResult> DownloadDetectionScript(string Id) { try { GraphIntune graphIntune = new GraphIntune(null); Win32LobApp win32LobApp = await graphIntune.GetWin32MobileAppAsync(Id); Win32LobAppPowerShellScriptDetection script = await graphIntune.GetWin32MobileAppPowerShellDetectionRuleAsync(Id); string fileName = $"{FilenameHelper.ProcessFileName(win32LobApp.DisplayName)}_detect.ps1"; return(File(Convert.FromBase64String(script.ScriptContent), "text/plain", fileName)); } catch (ServiceException e) { Flash(e.Error.Message); return(RedirectToAction("Index", "Home")); } }
public async Task <FileResult> DownloadAutopilotConfigurationJSON(string Id) { GraphIntune graphIntune = new GraphIntune(null); var profile = await graphIntune.GetWindowsAutopilotDeploymentProfile(Id); var org = await GraphHelper.GetOrgDetailsAsync(); AutopilotConfiguration windowsAutopilotDeploymentProfile = new AutopilotConfiguration(profile, org); var enc = Encoding.GetEncoding(1252); byte[] autopilotconfiguraton = enc.GetBytes(JsonConvert.SerializeObject(windowsAutopilotDeploymentProfile, // remove nullvalues from output and pretty format JSON new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented } )); return(File(autopilotconfiguraton, "application/json", "AutoPilotConfigurationFile.json")); }
public async Task <ActionResult> DownloadAsync(string clientId) { GraphIntune graphIntune = new GraphIntune(clientId); SignalRMessage signalRMessage = new SignalRMessage(clientId); try { AdministrativeTemplateExport templateExport = new AdministrativeTemplateExport(graphIntune); var deviceCompliancePolicies = await graphIntune.GetDeviceCompliancePoliciesAsync(); var deviceConfigurations = await graphIntune.GetDeviceConfigurationsAsync(); var managedAppProtection = await graphIntune.GetManagedAppProtectionAsync(); var managedAppConfiguration = await graphIntune.GetManagedDeviceMobileAppConfigurationsAsync(); var windowsAutopilotDeploymentProfiles = await graphIntune.GetWindowsAutopilotDeploymentProfiles(); var deviceManagementScripts = await graphIntune.GetDeviceManagementScriptsAsync(); var deviceEnrollmentConfig = await graphIntune.GetDeviceEnrollmentConfigurationsAsync(); var scopeTags = await graphIntune.GetRoleScopeTagsAsync(); var roleAssignments = await graphIntune.GetRoleAssignmentsAsync(); List <JObject> administrativeTemplates = await templateExport.GetExportableGroupPolicies(); using (MemoryStream ms = new MemoryStream()) { using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true)) { foreach (DeviceEnrollmentConfiguration item in deviceEnrollmentConfig) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); var zipArchiveEntry = archive.CreateEntry("DeviceEnrollmentConfiguration\\" + item.Id + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (JObject item in administrativeTemplates) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName((string)item.SelectToken("displayName")); var zipArchiveEntry = archive.CreateEntry("DeviceConfiguration\\" + fileName + "_" + ((string)item.SelectToken("id")).Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (DeviceConfiguration item in deviceConfigurations) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("DeviceConfiguration\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (DeviceCompliancePolicy item in deviceCompliancePolicies) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("DeviceCompliancePolicy\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (ManagedDeviceMobileAppConfiguration item in managedAppConfiguration) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("ManagedAppPolicy\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (ManagedAppPolicy item in managedAppProtection) { if (item.ODataType.Equals("#microsoft.graph.iosManagedAppProtection") || item.ODataType.Equals("#microsoft.graph.androidManagedAppProtection")) { var assignedApps = await graphIntune.GetManagedAppProtectionAssignmentAsync(item.Id); // Create json object from mam policy JObject appProtectionPolicy = JObject.FromObject(item); JArray appProtectionPolicyAssignedApps = JArray.FromObject(assignedApps); // Add assigned apps to export appProtectionPolicy.Add("assignedApps", appProtectionPolicyAssignedApps); byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(appProtectionPolicy, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("ManagedAppPolicy\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } else if (item.ODataType.Equals("#microsoft.graph.targetedManagedAppConfiguration")) { var assignedApps = await graphIntune.GetTargetedManagedAppConfigurationsAssignedAppsAsync(item.Id); // Create json object from mam policy JObject appProtectionPolicy = JObject.FromObject(item); JArray appProtectionPolicyAssignedApps = JArray.FromObject(assignedApps); // Add assigned apps to export appProtectionPolicy.Add("assignedApps", appProtectionPolicyAssignedApps); byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(appProtectionPolicy, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("ManagedAppPolicy\\" + "ManagedAppConfiguration_" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } else { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("ManagedAppPolicy\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } } foreach (WindowsAutopilotDeploymentProfile item in windowsAutopilotDeploymentProfiles) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("WindowsAutopilotDeploymentProfile\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (DeviceManagementScript item in deviceManagementScripts) { string fixedItem = await graphIntune.GetDeviceManagementScriptRawAsync(item.Id); byte[] temp = Encoding.UTF8.GetBytes(fixedItem); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("DeviceManagementScript\\" + fileName + "_" + item.Id.Substring(0, 8) + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (RoleScopeTag item in scopeTags) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("RoleScopeTags\\" + fileName + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } foreach (DeviceAndAppManagementRoleAssignment item in roleAssignments) { byte[] temp = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(item, Formatting.Indented)); string fileName = FilenameHelper.ProcessFileName(item.DisplayName); var zipArchiveEntry = archive.CreateEntry("RoleAssignments\\" + fileName + ".json", CompressionLevel.Fastest); using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(temp, 0, temp.Length); } } string domainName = await GraphHelper.GetDefaultDomain(clientId); return(File(ms.ToArray(), "application/zip", "IntuneConfig_" + domainName + ".zip")); } } catch (Exception e) { signalRMessage.sendMessage($"Error {e.Message}"); } return(new HttpStatusCodeResult(204)); }