等待" powershell_script"的Backgroung作业中的问题资源

时间:2017-07-07 16:48:28

标签: windows powershell chef wait rdp

我正在尝试在Chef Recipe中运行powershell_script,后者在后台运行一些作业。我需要等到所有后台作业完成后,在1秒钟后重新启动机器。这就是我正在做的事情:

   ruby 'restart_module' do
     code <<-EOH
       system('shutdown.exe -r -f -t 1')        
     EOH
     action :nothing
   end

   powershell_script 'Adding RDS roles' do
     code <<-EOH 
     Start-Job -Name addRolesFeatures -ScriptBlock {
       Add-WindowsFeature -Name RDS-RD-Server
       Add-WindowsFeature -Name RDS-Licensing
       Add-WindowsFeature -Name RSAT-RDS-Licensing-Diagnosis-UI
       Add-WindowsFeature -Name RDS-Licensing-UI
     }
     Wait-Job -Name addRolesFeatures
     EOH
     notifies :run, 'ruby[restart_module]', :immediately
  end

但是,当机器重新启动时,仍然没有安装RDS-RD-Server,剩下的功能是。 在等待后台工作完成时我错过了什么吗?

注意:我不能使用Add-WindowsFeature cmdlet的Restart选项。相反,我正在使用延迟强制重启来告诉我的工作站确切地在重新启动chef-node之前(假设此时没有待处理的作业)。

0 个答案:

没有答案
相关问题