On Wed, Jun 10, 2015 at 12:17 PM, kaustubh chaudhari <[email protected]>
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.
>
> 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 [email protected].
> 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!*
--
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/CAMJiBK54v2g-Gopp%3DVpyveVM%3DUxXsD8pZuqxRwcCE0bHGTo40w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.