none
Powershell script results are different when run in VS2109 than in PS ISE RRS feed

  • Question

  • This script:

    ps.AddScript(“invoke-command -computer k9sxw -scriptblock{Get-ItemPropertyValue -path HKLM:\SOFTWARE\Microsoft\‘Windows NT’\CurrentVersion\ -Name EditionID}”)

    actually returns results from path:

    HKLM:\SOFTWARE\\WOW6432Node\Microsoft\‘Windows NT’\CurrentVersion\ 

    when run in VS2019 Community ver 16.7.6 .Net Framework 4.8.04084 using: Collection <PSObject> results = ps.Invoke();

    However this script returns results from correct registry path when run in Powershell PS ISE version 5.1 build 19041

    I expect results from the specified path - not from some other path.




    • Edited by jbm417 Monday, October 26, 2020 12:42 AM clarify
    Monday, October 26, 2020 12:37 AM

Answers

  • WOW6432Node is the x86 virtualization node. 

    There are actually 2 ISE links in your start menu. If you simply type ISE and select the first one then it is running x64 which doesn't have the virtualization node. On my machine it returns Professional. However if you instead run ISE (x86) you'll see the same behavior as above, it returns Enterprise.

    To resolve this you need to run the x64 version of PS instead of x86. From my understanding the only way to do that is ensure your host app is x64 as well. In the project settings ensure `Prefer 32-bit` is not checked if compiling as Any CPU or explicitly set platform to x64. In either case the assembly reference to the PS assembly will switch to x64 which runs the x64 host. A fuller discussion is on SO.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by jbm417 Tuesday, October 27, 2020 1:07 AM
    Monday, October 26, 2020 1:58 PM
    Moderator

All replies

  • WOW6432Node is the x86 virtualization node. 

    There are actually 2 ISE links in your start menu. If you simply type ISE and select the first one then it is running x64 which doesn't have the virtualization node. On my machine it returns Professional. However if you instead run ISE (x86) you'll see the same behavior as above, it returns Enterprise.

    To resolve this you need to run the x64 version of PS instead of x86. From my understanding the only way to do that is ensure your host app is x64 as well. In the project settings ensure `Prefer 32-bit` is not checked if compiling as Any CPU or explicitly set platform to x64. In either case the assembly reference to the PS assembly will switch to x64 which runs the x64 host. A fuller discussion is on SO.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by jbm417 Tuesday, October 27, 2020 1:07 AM
    Monday, October 26, 2020 1:58 PM
    Moderator
  • Very helpful reply - tells me exactly what I need to know. Thank you Michael
    Tuesday, October 27, 2020 1:08 AM
  • https://developercommunity.visualstudio.com/content/problem/1232332/powershell-script-results-are-different-when-run-i.html
    Sunday, November 1, 2020 10:28 AM