Skip to content

Commit a98846e

Browse files
committed
Use #Requires -Version 5.1 in PS1 scripts
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent d7d3351 commit a98846e

6 files changed

Lines changed: 12 additions & 54 deletions

File tree

.claude/skills/azure-functions/Find-NuGetConfig.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env pwsh
2+
#Requires -Version 5.1
3+
24
<#
35
.SYNOPSIS
46
Finds nuget.config by searching up the directory hierarchy.

.claude/skills/azure-functions/Set-EnvVars.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env pwsh
2+
#Requires -Version 5.1
3+
24
<#
35
.SYNOPSIS
46
Sets Datadog instrumentation environment variables on an Azure Function App.

.claude/skills/azure-functions/Test-EnvVars.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env pwsh
2+
#Requires -Version 5.1
3+
24
<#
35
.SYNOPSIS
46
Verifies Datadog instrumentation environment variables on an Azure Function App.

tracer/tools/Build-AzureFunctionsNuget.ps1

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Requires -Version 5.1
2+
13
<#
24
.SYNOPSIS
35
Builds the Datadog.AzureFunctions NuGet package for local testing.
@@ -57,24 +59,6 @@ param(
5759
)
5860

5961
$ErrorActionPreference = 'Stop'
60-
61-
# Verify PowerShell version (requires 5.1+ for Expand-Archive and modern cmdlets)
62-
if ($PSVersionTable.PSVersion.Major -lt 5 -or
63-
($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1)) {
64-
Write-Error @"
65-
This script requires PowerShell 5.1 or higher.
66-
Current version: $($PSVersionTable.PSVersion)
67-
68-
Install PowerShell 7+ (recommended for cross-platform support):
69-
- Windows: winget install Microsoft.PowerShell
70-
- macOS: brew install powershell/tap/powershell
71-
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
72-
73-
Or use PowerShell 5.1 (Windows only):
74-
- Included with Windows 10/11 - run with: powershell.exe (not powershell.exe -Version 2)
75-
"@
76-
exit 1
77-
}
7862
$ProgressPreference = 'SilentlyContinue'
7963

8064
# Set dotnet and nuke verbosity based on PowerShell verbose mode

tracer/tools/Deploy-AzureFunction.ps1

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Requires -Version 5.1
2+
13
<#
24
.SYNOPSIS
35
Deploys a .NET Azure Function app and optionally triggers it.
@@ -81,24 +83,6 @@ param(
8183
Set-StrictMode -Version Latest
8284
$ErrorActionPreference = 'Stop'
8385

84-
# Verify PowerShell version (requires 5.1+ for modern cmdlets)
85-
if ($PSVersionTable.PSVersion.Major -lt 5 -or
86-
($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1)) {
87-
Write-Error @"
88-
This script requires PowerShell 5.1 or higher.
89-
Current version: $($PSVersionTable.PSVersion)
90-
91-
Install PowerShell 7+ (recommended for cross-platform support):
92-
- Windows: winget install Microsoft.PowerShell
93-
- macOS: brew install powershell/tap/powershell
94-
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
95-
96-
Or use PowerShell 5.1 (Windows only):
97-
- Included with Windows 10/11 - run with: powershell.exe (not powershell.exe -Version 2)
98-
"@
99-
exit 1
100-
}
101-
10286
# Guard: Verify prerequisites
10387
Write-Verbose "Verifying prerequisites..."
10488

tracer/tools/Get-AzureFunctionLogs.ps1

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Requires -Version 5.1
2+
13
<#
24
.SYNOPSIS
35
Downloads and analyzes Azure Function logs for Datadog tracer diagnostics.
@@ -84,24 +86,6 @@ param(
8486
Set-StrictMode -Version Latest
8587
$ErrorActionPreference = 'Stop'
8688

87-
# Verify PowerShell version (requires 5.1+ for Expand-Archive and modern cmdlets)
88-
if ($PSVersionTable.PSVersion.Major -lt 5 -or
89-
($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1)) {
90-
Write-Error @"
91-
This script requires PowerShell 5.1 or higher.
92-
Current version: $($PSVersionTable.PSVersion)
93-
94-
Install PowerShell 7+ (recommended for cross-platform support):
95-
- Windows: winget install Microsoft.PowerShell
96-
- macOS: brew install powershell/tap/powershell
97-
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
98-
99-
Or use PowerShell 5.1 (Windows only):
100-
- Included with Windows 10/11 - run with: powershell.exe (not powershell.exe -Version 2)
101-
"@
102-
exit 1
103-
}
104-
10589
# Apply -All switch
10690
if ($All) {
10791
$ShowVersion = $true

0 commit comments

Comments
 (0)