This is what I want to do:
How do I do this in a recipe?
Here is some semi-pseudo code:
unless "ls Cert:\LocalMachine\My\ | ?{$_.Subject -like '*#{cert_name}*'}"
cookbook_file cert_temp_path do
source cert_name
end
windows_certificate "c:/test/mycert.pfx" do
pfx_password 'MyPass!'
end
end
How do I execute that line of PS code? Can I call the powershell_script resource directly somehow?
This is what I needed: Chef NOT_IF and ONLY_IF validation issue in Windows recipes
I needed the guard_interpreter setting.
Adding this to any resource calls that work with the pfx solve my issue:
guard_interpreter :powershell_script
not_if "My powershell code"