extra character output from facter
Hi,
First of all i'm sorry if i missed a similar topic, tried searching but couldnt find it.
I have a facter file that outputs extra characters. If I were to run the query individually i get my desired output, but if i include puppet formats it has extra characters garbage;
My code is as per below, to query via wmi a server's domain role;
Facter.add(:w2k8_systemrole) do
confine :kernel => :windows
setcode do
value = "unknown"
value = Facter::Core::Execution.exec('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy remotesigned -Command "& {(Get-WmiObject win32_computersystem).DomainRole}"')
if value != "*"
value = value
else
value = "DomainRole is not defined for the system."
end
end
end
instead of "2" i get ƒ^cƒ-ƒ"?2. Please help, thanks.
Regards, Kuro
I have no idea, what your command's supposed to do, but it returns a string, which you may value.sub(/x$/, '') https://ruby-doc.org/core/String.html#method-i-sub where `x` is your extra character (at the end of the string [dollar-sign]). This is more of a quick'n'dirty work-around, though.