I have a problem where ISE is not doing the same like the console (console does it wrong) and it is very easy to reproduce in a domain environment on a Server 2016 Domain Controller or a Server 2016 Memberserver with installed ActiveDirectory module.
c:\temp\main.ps1
Import-Module c:\temp\functions.psm1 -Force
$ObjAdDomain = Get-VarObjAdDomain
$ObjAdDomainPdc = Get-VarStrPDCEmulator
write-host "PDC = $ObjAdDomainPdc"
c:\temp\functions.psm1
function Get-VarObjAdDomain {Get-ADDomain}
function Get-VarStrPDCEmulator {$ObjAdDomain.PDCEmulator}
The expected result is, that Powershell made an output like PDC = server.domain.local
in ISE and in console, but it does only in ISE.
In console the output is only PDC =
and the variable $ObjAdDomainPdc
is empty.
This code was working without any problems at Server 2012 R2 but now with Server 2016 it isn't working anymore, but Set-StrictMode -Version 2.0
has no effect.
I know that I could run the Get-VarStrPDCEmulator
and give the variable $ObjAdDomain
to the function, but this is normally not necessary and I would have to change hundreds of function and generate tons of additionally code because of that (bug?).
Does anybody know what is going on here?