Skip to content

Instantly share code, notes, and snippets.

@russellds
Created May 25, 2023 18:59
Show Gist options
  • Save russellds/823f7a0e6dfa3e87c306e7c31a532515 to your computer and use it in GitHub Desktop.
Save russellds/823f7a0e6dfa3e87c306e7c31a532515 to your computer and use it in GitHub Desktop.
param(
[string]$WorkspacePath
)
$InformationPreference = 'Continue'
Write-Information "Workspace Path: $( $WorkspacePath )"
Set-Location -Path $WorkspacePath
$telemetryStrings = @()
$telemetryStrings += @'
@description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).')
param enableDefaultTelemetry bool = true
'@
$telemetryStrings += @'
enableDefaultTelemetry: enableDefaultTelemetry
'@
$telemetryStrings += @'
@sys.description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).')
param enableDefaultTelemetry bool = true
'@
$telemetryStrings += @'
resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}'
location: location
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
}
}
}
'@
$telemetryStrings += @'
resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
}
}
}
'@
$telemetryStrings += @'
resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
}
}
}
'@
$telemetryStrings += @'
var enableReferencedModulesTelemetry = false
'@
$telemetryStrings += @'
enableDefaultTelemetry: enableReferencedModulesTelemetry
'@
$telemetryStrings += @'
| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via a Globally Unique Identifier (GUID). |
'@
$telemetryStrings += @'
enableDefaultTelemetry: '<enableDefaultTelemetry>'
'@
$telemetryStrings += @'
"enableDefaultTelemetry": {
"value": "<enableDefaultTelemetry>"
},
'@
$telemetryStrings += @'
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via a Globally Unique Identifier (GUID). |
'@
$telemetryStrings += @'
"enableDefaultTelemetry": {
"value": "<enableDefaultTelemetry>"
}
'@
$telemetryStrings += @'
// PID
@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).')
param enableDefaultTelemetry bool = true
'@
$telemetryStrings += @'
| `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). |
'@
$telemetryStrings += @'
@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).')
param enableDefaultTelemetry bool = true
'@
$telemetryStrings += @'
| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). |
'@
$files = Get-ChildItem -Path './src/los/sms' -File -Recurse
foreach ($file in $files) {
$fileContent = Get-Content -Path $file.FullName -Raw
$fileContentChanged = $false
if ($fileContent) {
foreach ($telemetryString in $telemetryStrings) {
if ($fileContent.Contains($telemetryString)) {
$fileContent = $fileContent.Replace($telemetryString, '')
$fileContentChanged = $true
}
}
}
if ($fileContentChanged) {
Write-Information "Telemetry Removed From: $( $file.FullName )"
$fileContent = $fileContent.Replace("`r`n`r`n`r`n", "`r`n`r`n")
$fileContent.Replace("`r`n`r`n`r`n", "`r`n`r`n") |
Out-File -FilePath $file.FullName -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment