On Wed, Jun 10, 2015 at 4:32 PM, Rob Reynolds <r...@puppetlabs.com> wrote:

>
>
> On Wed, Jun 10, 2015 at 12:17 PM, kaustubh chaudhari <kaustu...@gmail.com>
> wrote:
>
>> Hi All,
>>
>> I want to read registry value on windows system and present it as a fact.
>> i tried it in many ways but no luck.
>>
>> I have this powershell script in facts.d directory
>> ==
>> $path = 'HKLM:\Software\SunGard\BigFix'
>> $wave = Get-ItemProperty $path | Select-Object -ExpandProperty bigfix
>> Write-Host zzzPatching_Wave = $wave
>> ==
>>
>> every time i run this errors out.  it directly displays $wave as key and
>> Get-ItemProperty....... as value in dashboard. Not the actual output as
>> value. However if i run this on system through powershell it gives the
>> correct output.
>>
>
FWIW, I think you are running into registry redirection (built in to
Windows). As in you are running Puppet from a 32-bit process on a 64-bit
operating system, so it doesn't see your 64-bit registry value. I wrote a
blog post[1] awhile back talking about some common things you might run
into with Windows. You can also read more about registry redirection and
our 64-bit versions of Puppet on the Windows overview page[2].

[1] https://puppetlabs.com/blog/how-avoid-common-windows-gotchas-puppet
[2]
http://docs.puppetlabs.com/windows/#file-system-redirection-windows-server-2003-or-older-versions-of-puppet



>
>> Tried another way.
>> Created a custom fact.
>> ==
>> Facter.add(:zpatchwave) do
>>   confine :kernelversion => "6.1.7601"
>>   setcode do
>>       powershell =
>> 'C:\Windows\syswow64\WindowsPowerShell\v1.0\powershell.exe'
>>       command = '(Get-ItemProperty -Path "HKLM:Software\SunGard\BigFix"
>> -name "bigfix")."bigfix"'
>>     Facter::Util::Resolution.exec(%Q{#{powershell} -command "#{command}"})
>>  end
>> end
>> ==
>>
>
> You might try it another way, using ruby code.
>
> Facter.add(:myfact) do
>   confine :kernel => :windows
>   setcode do
>     require 'win32/registry'
>
>     value = nil
>     hive = Win32::Registry::HKEY_CLASSES_ROOT
>     hive.open('SOFTWARE\Somewhere\SomeValue',  Win32::Registry::KEY_READ | 
> 0x100) do |reg|
>       value = reg['SomeValue']
>     end
>     value
>   end
> end
>
>
>
>>
>> but this is not executed successfully, it displays as path not found for
>> HKLM in the dashboard.
>>
>> Any help is appreciated. Struggling on this.
>>
>> -Cheerzzz
>> Kaustubh
>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/bf96b0d5-82df-4a45-b1df-dc5b8a5fe717%40googlegroups.com
>> <https://groups.google.com/d/msgid/puppet-users/bf96b0d5-82df-4a45-b1df-dc5b8a5fe717%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Rob Reynolds
> Developer, Puppet Labs
>
> *PuppetConf 2015 <http://2015.puppetconf.com/> is coming to Portland,
> Oregon! Join us October 5-9.*
> *Register now to take advantage of the Early Adopter discount
> <https://www.eventbrite.com/e/puppetconf-2015-october-5-9-tickets-13115894995?discount=EarlyAdopter>
>  *
> *—**save $349!*
>



-- 
Rob Reynolds
Developer, Puppet Labs

*PuppetConf 2015 <http://2015.puppetconf.com/> is coming to Portland,
Oregon! Join us October 5-9.*
*Register now to take advantage of the Early Adopter discount
<https://www.eventbrite.com/e/puppetconf-2015-october-5-9-tickets-13115894995?discount=EarlyAdopter>
*
*—**save $349!*

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAMJiBK5XzZaoGRz-LTAQQzK%3D_UmBgswOiNcUYjF9bRFXVkkMpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to