我有一个应用程序需要一个本地帐户才能进行配置。我创建了内部的模块我有2个文件夹:Puppet PowerShell执行
files
manifests
下表现init文件我有下面的代码:
class xyz {
exec { ' app_config':
command => ' C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -file c:\provisioning\modules\xyz\files\config1.ps1 '
}
}
下的文件夹中有是2个文件:
config1.ps1
app_execute.bat
在config1.ps1
我创建一个本地用户:
$user = $env:COMPUTERNAME/Testing
$Credentials = New-Object -TypeName System.Management.Automation.PScredential -ArgumentList $user, ("[email protected]", | ConvertTo-SecureString -AsPlainText -Force)
Start-Process C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -Credential $Credentials -ArgumentList " Start-Process C:\Windows\System32\cmd.exe -File c:\provisioning\c:\provisioning\modules\xyz\files\app_execute.bat "
在app_execute.bat
c:\puppet\app.bat -f c:\puppet\responsefile.rsp
的日志文件显示PowerShell的文件config1.ps1
得到成功执行,但应用程序离子记录文件没有被生成,但是当手动执行config1.ps1
应用程序将被配置。
不确定,在config1.ps1
中,我使用的是Start-Process
,它将使用本地帐户创建单独的进程。
我觉得木偶不等待上面config1.ps1
成功完成。
不知道它为什么没有完全执行,是否有任何条件,因为我们需要在init中只执行一个文件,因为我正在启动2个进程。
一个'exec'资源,启动一个powershell脚本,启动一个PowerShell进程,启动一个CMD进程,该进程运行一个批处理文件(具有无效路径),该文件运行另一个批处理文件,该文件处理某种响应文件。哇。只是... *哇!*我的建议是:扔掉它并重新开始。从头开始。考虑使用['用户资源](https://docs.puppet.com/puppet/4.6/reference/resources_user_group_windows.html)这次创建本地用户。 –
@AnsgarWiechers,非常感谢您的帮助,我会尝试用户资源并进行检查。 – Shivayogi
@AnsgarWiechers,我使用的用户资源选项,但它是抛出错误,我提出了相同的票据http://stackoverflow.com/questions/39653659/puppet-local-account-creation-error – Shivayogi