From e782fd238512375ae7c8173cab167aa68368b12f Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Fri, 31 May 2019 10:13:50 +0000 Subject: [PATCH] HKLM - do not check on linux machines (#5663) * do not check on linux machines * fix that too --- internal/scripts/smoLibraryImport.ps1 | 30 +++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/internal/scripts/smoLibraryImport.ps1 b/internal/scripts/smoLibraryImport.ps1 index e7f35782715c..19d4269b0f57 100644 --- a/internal/scripts/smoLibraryImport.ps1 +++ b/internal/scripts/smoLibraryImport.ps1 @@ -94,9 +94,11 @@ $scriptBlock = { # New SQL Auth types require newer versions of .NET, check # https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed - if ((Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release -ge 461808 -and $PSVersionTable.PSEdition -ne "Core") { - Write-Verbose -Message "Adding Azure DLLs" - $names += 'Microsoft.IdentityModel.Clients.ActiveDirectory', 'Microsoft.Azure.Services.AppAuthentication' + if ($psVersionTable.Platform -ne 'Unix') { + if ((Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release -ge 461808 -and $PSVersionTable.PSEdition -ne "Core") { + Write-Verbose -Message "Adding Azure DLLs" + $names += 'Microsoft.IdentityModel.Clients.ActiveDirectory', 'Microsoft.Azure.Services.AppAuthentication' + } } foreach ($name in $names) { @@ -128,14 +130,16 @@ if ($script:serialImport) { } # if .net 4.7.2 load new sql auth config -if ((Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release -ge 461808 -and $PSVersionTable.PSEdition -ne "Core") { - Write-Verbose -Message "Loading app.config" - # Load app.config that supports MFA - $configpath = "$script:PSModuleRoot\bin\app.config" - [appdomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configpath) - Add-Type -AssemblyName System.Configuration - # Clear some cache to make sure it loads - [Configuration.ConfigurationManager].GetField("s_initState", "NonPublic, Static").SetValue($null, 0) - [Configuration.ConfigurationManager].GetField("s_configSystem", "NonPublic, Static").SetValue($null, $null) - ([Configuration.ConfigurationManager].Assembly.GetTypes() | Where-Object {$_.FullName -eq "System.Configuration.ClientConfigPaths"})[0].GetField("s_current", "NonPublic, Static").SetValue($null, $null) +if ($psVersionTable.Platform -ne 'Unix') { + if ((Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release -ge 461808 -and $PSVersionTable.PSEdition -ne "Core") { + Write-Verbose -Message "Loading app.config" + # Load app.config that supports MFA + $configpath = "$script:PSModuleRoot\bin\app.config" + [appdomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configpath) + Add-Type -AssemblyName System.Configuration + # Clear some cache to make sure it loads + [Configuration.ConfigurationManager].GetField("s_initState", "NonPublic, Static").SetValue($null, 0) + [Configuration.ConfigurationManager].GetField("s_configSystem", "NonPublic, Static").SetValue($null, $null) + ([Configuration.ConfigurationManager].Assembly.GetTypes() | Where-Object {$_.FullName -eq "System.Configuration.ClientConfigPaths"})[0].GetField("s_current", "NonPublic, Static").SetValue($null, $null) + } } \ No newline at end of file