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
==
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...@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.
For more options, visit https://groups.google.com/d/optout.
On Wed, Jun 10, 2015 at 12:17 PM, kaustubh chaudhari <kaus...@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.
this(c:\windows\system32 to c:\windows\sysnative)after this it used the correct system native powershell binary.
Atlast done! Once again thanks for your help Rob! Have a nice time ahead!
-Kaustubh