# How can we use powershell resource output in chef recipe

**URL:** <https://discourse.chef.io/t/how-can-we-use-powershell-resource-output-in-chef-recipe/11807>\
**Category:** Chef Infra (archive)\
**Created:** [October 24, 2017, 2:09pm UTC](https://discourse.chef.io/t/how-can-we-use-powershell-resource-output-in-chef-recipe/11807 "2017-10-24T14:09:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyanshu](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@priyanshu](https://discourse.chef.io/u/priyanshu)\
**Post date:** [October 24, 2017, 2:09pm UTC](https://discourse.chef.io/t/how-can-we-use-powershell-resource-output-in-chef-recipe/11807/1 "2017-10-24T14:09:22Z")

</div>

instance = node[‘test’][‘instance\_name’]  
$value = 1433

powershell\_script “power” do  
code \<\<-EOH  
$i = ‘false’

$num = 1433

while ($i -eq ‘false’){  
$a = $num  
$i=TNC -ComputerName $env:computername -Port $num -InformationLevel Quiet  
$num -=1;  
}

EOH  
$value = $a  
end

ruby\_block “port\_number” do  
block do  
$value = Chef::Util::FileEdit.new(“C:\script\Summary.txt”)  
#file = File.open(“C:\script\Summary.txt”, “rb”)  
#contents = file.read  
#node.set[‘test’][‘port’] = "#{contents}"  
end  
end

case $value

when 1433
