I’m noticing a really odd behavior with not_if statements on Windows and I was curious if anyone else had run into a similar situation. I’m trying to set powershell execution policy to unrestricted with Chef using the following resources:
execute ‘set 64bit powershell execution to unrestricted’ do
command '%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force’
%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe Get-ExecutionPolicy.include?(‘Unrestricted’) }
execute ‘set 32bit powershell execution to unrestricted’ do
command '%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force’
%SystemRoot%\\syswow64\\WindowsPowerShell\\v1.0\\powershell.exe Get-ExecutionPolicy.include?(‘Unrestricted’) }
The trouble is the resources are always skipped. If I run the following from cmd as the Administrator I get back ‘restricted’ as expected:
If I fire up IRB I get a completely different answer:
I noticed that if I echo the architecture in IRB I get 32bit, while I get 64bit back from the command prompt. It seems like I should still back the correct answer since I’m trying to execute against 32bit powershell, but clearly something is wrong here. Any advice?
The information in this message may be confidential. It is intended solely
the addressee(s). If you are not the intended recipient, any disclosure,
copying or distribution of the message, or any action or omission taken by
in reliance on it, is prohibited and may be unlawful. Please immediately
contact the sender if you have received this message in error.