Hello all,I have been banging my head against this one for a couple of days. I am trying to use Powershell to comb the Windows registry for installed applications, such as VMware Tools, to create a custom facter. If I run this code from a PS prompt it works, and returns the expected data:PS C:\> Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where-Object {$_.DisplayName -eq "VMware Tools"} | ForEach-Object -process {$_.DisplayVersion }9.4.6.1770165
However, running the same thing through Puppet as a facter yields zero data:----------Facter.add("vmtools_version") doconfine :osfamily => "Windows"setcode doFacter::Util::Resolution.exec('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& {Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where-Object {$_.DisplayName -eq \"VMware Tools\"} | ForEach-Object -process {$_.DisplayVersion } } "')endend----------
The left side shows up in the facters as "vmtools_version", but the right side is always empty. I have tried using the GetItem module instead, and tried various combinations of the "-Command" switch, removed the "For-Each" handler to see if would spit out a huge block of text, and even tried wrapping the whole thing in a "try & catch" to see if any error states are generated, but have never gotten any right side output at all.Does anyone have an idea that might make this work?
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a76b897f-9f1f-4e82-ab18-344ae9a6e2c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, Sep 18, 2014 at 2:11 PM, Brian Morris <nomadic...@gmail.com> wrote:Hello all,I have been banging my head against this one for a couple of days. I am trying to use Powershell to comb the Windows registry for installed applications, such as VMware Tools, to create a custom facter. If I run this code from a PS prompt it works, and returns the expected data:PS C:\> Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where-Object {$_.DisplayName -eq "VMware Tools"} | ForEach-Object -process {$_.DisplayVersion }9.4.6.1770165This is running in a 64bit process.However, running the same thing through Puppet as a facter yields zero data:----------Facter.add("vmtools_version") doconfine :osfamily => "Windows"setcode doFacter::Util::Resolution.exec('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command
"& {Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where-Object {$_.DisplayName -eq \"VMware Tools\"} | ForEach-Object -process {$_.DisplayVersion } } "')endend----------This is in a 32bit process unless you are on the newest 3.7.0 or 3.7.1 x64 builds of Puppet. You are hitting registry redirection. Be sure to checkout Common Gotchas[1] especially for how to turn off registry redirection in a 32 bit process.More detail:When a 32 bit process calls the registry and is subject to redirection, it only sees the Wow6432Node under software. Check out that link above, it explains quite a bit in more detail.--The left side shows up in the facters as "vmtools_version", but the right side is always empty. I have tried using the GetItem module instead, and tried various combinations of the "-Command" switch, removed the "For-Each" handler to see if would spit out a huge block of text, and even tried wrapping the whole thing in a "try & catch" to see if any error states are generated, but have never gotten any right side output at all.Does anyone have an idea that might make this work?
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a76b897f-9f1f-4e82-ab18-344ae9a6e2c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAMJiBK7GNgWponY1y74bpQ5x_YPbRcPeK3%3DmsyBc-W2txDfQaQ%40mail.gmail.com.--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/8m8mt4G_OKU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
Holy cow, Rob... that was great info! All I did was change "System32" to "sysnative", and it worked on the first try. All of that frustration boiled down to one part of one path...Thank you for the link, too. It helps to understand why this happens. Cheers to you!
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAH8X0%2BG8cxLaTG35uKqXBrbhEvHzH1GGZLsVcq7Bso0MSYaKxw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CA%2Bu97ukj-hMvfo0zJvst9%3Dpbk-%2BgJGtAmWXQS8drCGTFnGAPHg%40mail.gmail.com.