Forum Discussion
Using 'Get-GPInheritance' Command in Powershell 7
mmm.
I am checking the issue and notice that there are a lot of different between running the command on Powershell 5.1 (Infrastructure version) vs Powershell 7
even the object type and the return is different,
Powershell 5.1, Notice that the name is GPOLink, which seems to be an object holding the value
PS C:\Users\Administrator> ((Get-GPInheritance -Target $ou ).InheritedGpoLinks)[0].gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False GpoLink System.Object
Powershell 7.1, Notice that the Value type is String not GPOLink
PS C:\Program Files\PowerShell\7> ((Get-GPInheritance -Target $ou ).InheritedGpoLinks)[0].gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
Even when you run Get-GPInheritance -Target $ou
Powershell 5.1: will return the GPNmae
Powershell 7.1: will return Microsoft.GroupPolicy.GpoLink
I will do more checks on this, this is maybe because the GroupPolicy module was written and tested in PS5.1 but not 7
Interesting. Thanks for looking into this.
- Henrik_Andre_OlsenMar 17, 2023Copper Contributor
Any progress on this? It's been 2 years and this issue still persists in PowerShell 7.
Kind regards
Henrik André Olsen- mmsengAug 18, 2023Copper ContributorI also just came across this. Does anyone even know whether this is intended behavior or a bug?
- Henrik_Andre_OlsenAug 18, 2023Copper Contributor
mmseng
No it's a bug:
https://github.com/PowerShell/PowerShell/issues/18519