scripts
scripts copied to clipboard
Use-NetMailConfig.ps1 doesn't work with PowerShell Core
PowerShell Core doesn't seem to have a machine.config:
$mcfg = [Configuration.ConfigurationManager]::OpenMachineConfiguration()
$may = if(Test-Path $mcfg.FilePath){'does'}else{'does not'}
"PowerShell v$($PSVersionTable.PSVersion) uses $($mcfg.FilePath), which $may exist"
PowerShell v6.2.0 uses C:\Program Files\PowerShell\6\Config\machine.config, which does not exist
Compare to PowerShell 5.1:
PowerShell v5.1.17134.590 uses C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config, which does exist
On Windows, pwsh.exe could call powershell.exe for native access to the machine.config, but that's a pretty kludgy fix, and doesn't address other platforms.
Use-NetMailConfig.ps1 could fail on PS Core, or it could try finding .NET Framework machine.config value (either through powershell.exe or finding and parsing the config XML manually), or it could use it's own config, or some combination of these strategies.