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 $_.ps
path} | 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") do
confine :osfamily => "Windows"
  setcode do
    
Facter::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 } } "')
end
end
----------

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 [email protected].
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.

Reply via email to