我正在尝试完成某人的食谱,我需要能够让厨师从这个脚本中获取返回的整数0(有些细节已被删除)有关什么可以在Chef中使用的建议吗?我已经在Chef中添加了Powershell模块,特别是我在询问Chef将解析这些数据的顺序 - 就像在action:item中将这个变量交给......谢谢。
include_recipe "chef_handler
powershell_script do
code <<-EOH
###############
#
# Description:
# Returns 1 if any share or share path allow read/write by the 'Everyone' group (fail)
# Returns 0 if this condition is not found (pass)
Try
{
#get all shares
$shares = e | Select-Object Name,Path
if($shares)
{
Foreach ($share in $shares)
{
#check everyone permissions
$shareAccounts = -Name $share.Name
Foreach ($account in $shareAccounts)
{
If ($account.AName -eq 'Everyone')
{
return 1
}
}
#check
$volumePerm = Get-ACL $share.Path
if ($volume.Access.Where({$Reference -eq 'Everyone'}))
{
return 1
}
}
}
else
return 0
#loop through each share checking for 'Everyone'
# pass the return values send to Chef or something else.
}
{
#build error message
}
Finally
{
#return final message
}
EOH
fail "Instance has failed the OpenShares check" if code == 1
end