-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create TurnOnWinDiagDataPrepConfig.ps1
- Loading branch information
1 parent
442b930
commit 3c3718a
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
Intune_Scripts/WindowsUpdateForBusinessReports/TurnOnWinDiagDataPrepConfig.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
<# | ||
.SYNOPSIS | ||
Script to enable features that require Windows diagnostic data in processor configuration. | ||
.DESCRIPTION | ||
This script will enable the features that require Windows diagnostic data in processor configuration. | ||
This will toggle on the setting under Tenant Administration ==> Connectors and tokens ==> Windows data ==> Windows data | ||
.NOTES | ||
Author: Ashish Arya | ||
Date: 25 July 2023 | ||
#> | ||
|
||
|
||
Function Get-AuthToken { | ||
|
||
<# | ||
.SYNOPSIS | ||
This function uses the Azure AD app details which in turn will help to get the access token to interact with Microsoft Graph API. | ||
.DESCRIPTION | ||
This function uses the Azure AD app details which in turn will help to get the access token to interact with Microsoft Graph API. | ||
As a prerequisite for executing this script, you will require the MSAL.PS powershell module for authenticating to the API. | ||
Here you need to add the below environment variables (as per your Azure AD app credentials) on your local machine. | ||
a) $Env:Azure_CLIENT_ID | ||
b) $Env:Azure_TENANT_ID | ||
c) $Env:Azure_CLIENT_SECRET | ||
.EXAMPLE | ||
Get-AuthToken | ||
.NOTES | ||
Author: Ashish Arya | ||
Date: 19 Jan 2023 | ||
#> | ||
|
||
# Checking if the MSAL.PS Powershell module is installed or not. If not then it will be installed. | ||
Write-Host "Checking for MSAL.PS module..." | ||
$MSALPSModule = Get-Module -Name MSAL.PS -ListAvailable | ||
|
||
if ($null -eq $MSALPSModule) { | ||
Write-Host "MSAL.PS PowerShell module is not installed." -f Red | ||
$Confirm = Read-Host "Press Y for installing the module or N for cancelling the installion" | ||
|
||
if ($Confirm -eq "Y") { | ||
Install-Module -name 'MSAL.PS' -Scope CurrentUser -Force | ||
} | ||
else { | ||
Write-Host "You have cancelled the installation and the script cannot continue.." -f Red | ||
write-host | ||
exit | ||
} | ||
} | ||
|
||
# Azure AD app details | ||
$authparams = @{ | ||
ClientId = $Env:Azure_CLIENT_ID | ||
TenantId = $Env:Azure_TENANT_ID | ||
ClientSecret = ($Env:Azure_CLIENT_SECRET | ConvertTo-SecureString -AsPlainText -Force) | ||
} | ||
|
||
$auth = Get-MsalToken @authParams | ||
|
||
$authorizationHeader = @{ | ||
Authorization = $auth.CreateAuthorizationHeader() | ||
} | ||
|
||
return $authorizationHeader | ||
} | ||
|
||
$AuthToken = Get-AuthToken | ||
|
||
$uri = "https://graph.microsoft.com/beta/deviceManagement/dataProcessorServiceForWindowsFeaturesOnboarding" | ||
|
||
$Json = @" | ||
{ | ||
"@odata.type": "#microsoft.graph.dataProcessorServiceForWindowsFeaturesOnboarding", | ||
"areDataProcessorServiceForWindowsFeaturesEnabled": "true" | ||
} | ||
"@ | ||
|
||
Invoke-RestMethod -Uri $uri -Headers $authToken -Method 'Patch' -Body $Json -ContentType "application/json" | ||
|