Skip to content

Commit 980eff1

Browse files
Enhance environment logging by creating a custom object for static properties
1 parent 8ba5708 commit 980eff1

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

scripts/main.ps1

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,32 @@ process {
106106
Arch = $env:RUNNER_ARCH
107107
Environment = $env:RUNNER_ENVIRONMENT
108108
Temp = $env:RUNNER_TEMP
109-
Perflog = $env:RUNNER_PERFLOG
110-
ToolCache = $env:RUNNER_TOOL_CACHE
111-
TrackingID = $env:RUNNER_TRACKING_ID
109+
Perflog = $env:RUNNER_PERFLOG
110+
ToolCache = $env:RUNNER_TOOL_CACHE
111+
TrackingID = $env:RUNNER_TRACKING_ID
112112
Workspace = $env:RUNNER_WORKSPACE
113113
Processors = [System.Environment]::ProcessorCount
114114
} | Format-List
115+
116+
# Create an empty hashtable to store property name/value pairs.
117+
$props = @{}
118+
119+
# Enumerate each static property on [System.Environment].
120+
[System.Environment] |
121+
Get-Member -Static -MemberType Property |
122+
ForEach-Object {
123+
# Store the value of each static property in the hashtable,
124+
# keyed by the property name.
125+
$props[$_.Name] = [System.Environment]::$($_.Name)
126+
}
127+
128+
# Cast the hashtable to a PSCustomObject so you get a single object
129+
# with all property/value pairs.
130+
$EnvironmentObject = [PSCustomObject]$props
131+
132+
# Display the custom object.
133+
$EnvironmentObject | Format-List
134+
115135
}
116136

117137
Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛'

0 commit comments

Comments
 (0)