Entra-check.ps1
|
function Write-Telemetry { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateSet("EntraScriptsToProcess","EntraImportFunction","EntraTest")] [string] $EventName ) #$EventName = "EntraTest" Write-Verbose "Sending telemetry event: $EventName" # Get the module version $module = Get-Module -Name Entra -ListAvailable #$moduleVersion = if ($module) { $module.Version } else { "unknown" } $moduleVersion = if ($module) { $module.Version } else { "unknown-0.3" } $moduleName = if ($module) { $module.name } else { "unknown-entra" } $jsonData = @{ "api_key" = "c0cd5aa997bde6dd291d06729c7548a7" "events" = @{ #"user_id" = "$($env:HOMEPATH)" "user_id" = $([BitConverter]::ToString([System.Security.Cryptography.SHA256]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($env:HOMEPATH))).Replace('-', '').ToLower()) #"device_id" = "$($env:ComputerName)" "device_id" = $([BitConverter]::ToString([System.Security.Cryptography.SHA256]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($env:ComputerName))).Replace('-', '').ToLower()) "event_type"= $EventName "app_version" = $moduleVersion "platform" = "PowerShell $($PSVersionTable.PSVersion)" "os_name" = (Get-CimInstance Win32_OperatingSystem).Caption "language" = (Get-Culture).Name "ip" = '$remote' "device_brand" = $moduleName } } # Convert the data to JSON format $jsonBody = $jsonData | ConvertTo-Json # Define the URL $url = "https://api.eu.amplitude.com/2/httpapi" # Send the POST request try { Invoke-RestMethod -Uri $url -Method Post -ContentType "application/json" -Body $jsonBody | Out-Null } catch { Write-Verbose $_ } } Write-Telemetry -EventName "EntraScriptsToProcess" #Write-Telemetry -EventName "EntraTest" |