Skip to content

Commit

Permalink
HKLM - do not check on linux machines (#5663)
Browse files Browse the repository at this point in the history
* do not check on linux machines

* fix that too
  • Loading branch information
potatoqualitee authored May 31, 2019
1 parent e0bf25d commit e782fd2
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions internal/scripts/smoLibraryImport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit e782fd2

Please sign in to comment.