Skip to content

Commit

Permalink
Add try/catch for containers without the hostname command (#8710)
Browse files Browse the repository at this point in the history
fixes #8701
  • Loading branch information
potatoqualitee authored Dec 29, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 31576cd commit cb554f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dbatools.psm1
Original file line number Diff line number Diff line change
@@ -94,7 +94,11 @@ if (($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.Platform -and $

# this doesn't exist by default
# https://github.com/PowerShell/PowerShell/issues/1262
$env:COMPUTERNAME = hostname
try {
$env:COMPUTERNAME = hostname
} catch {
$env:COMPUTERNAME = "unknown"
}
}

Write-ImportTime -Text "Setting some OS variables"

0 comments on commit cb554f5

Please sign in to comment.