Use Powershell script inside the chef recipe

Hi All,

I am trying to install an application using PowerShell. It works fine when I run it from powershell.
But when I try to use same script inside powershell_script recource in chef recipe it behaves differently. It is not showing the progress of the installation until the process is completed.

Here is the resource usage:

powershell_script 'install-arcserve-udp' do
guard_interpreter :powershell_script
code <<-EOH

Write-Host 'Installation summary log will be stored under "#{node['arcserve_udp']['summary_file']}"'
$InstallerArguments = '-s -a -q -Https:1 -Products:All -User:"Administrator" -Password:"****" -SummaryPath:"#{node['arcserve_udp']['summary_file']}"'

$process = Start-Process -FilePath "#{node['arcserve_udp']['installer_file']}" -ArgumentList $InstallerArguments -WindowStyle Hidden -PassThru

Write-Host "ArcServe UDP installer is running"

# wait for the process to complete, and meanwhile display some dots to indicate progress:
           Write-Host '.' -NoNewline
           Start-Sleep 10
     } until ($process.HasExited)

action :run

When I run this recipe during bootstrapping new server, it just says

powershell_script[install-arcserve-udp] ran successfully

and comes out of the recource block insantly without displaying anything until the process is completed. Please help :slight_smile:



If I recall correctly, Chef-client won't show you what's happening, at least by default. You could try enabling debug mode (chef-client -L debug) and it'll give you the output of each command, but i'm not sure if it'll either just show you a full output of the script it's going to run and pause until it's done, or step-through each command until completion. It's probably worth a try?

1 Like

@manoharm28 Have you tried using the windows_package resource to install?

Did a bit of nosey googling and looks as though arcserve udp could be a InstallShield Setup.exe. If you can create a Response File or Silent Installation file, then easier to pass the response file path in options.

windows_package "arcserver_udp" do
install_type :installshield
source "#{node['arcserve_udp']['installer_file']}"
options "/i:#{node['arcserve_udp']['response_file']}"
action :install

I referenced this article:

1 Like