Skip to content

Commit

Permalink
Merge pull request #348 from gscho/always-return-an-arch
Browse files Browse the repository at this point in the history
Fall back to Get-WmiObject if Get-CimInstance fails
  • Loading branch information
tas50 authored Feb 19, 2021
2 parents 087b882 + e819567 commit 6d64fcd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/mixlib/install/generator/powershell/scripts/helpers.ps1.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ function Get-WebContentOnFullNet {
$wc.Headers.Add("user-agent", "<%= user_agent_string %>")
$proxy.Address = $env:http_proxy
$bypassList = $env:no_proxy


if($bypassList -ne $null){

$bypassList = $bypassList.split(",")
$proxy.BypassList = $byPassList
}

$wc.Proxy = $proxy

if ([string]::IsNullOrEmpty($filepath)) {
Expand Down Expand Up @@ -180,9 +180,16 @@ function Get-WMIQuery {
param ($class)

if(Get-Command -Name Get-CimInstance -ErrorAction SilentlyContinue) {
Get-CimInstance $class
try{
$classObject = Get-CimInstance $class
# If the Get-CimInstance command exists but fails due to security settings, try Get-WmiObject.
}
catch {
$classObject = Get-WmiObject $class
}
}
else {
Get-WmiObject $class
$classObject = Get-WmiObject $class
}
return $classObject
}

0 comments on commit 6d64fcd

Please sign in to comment.