我正在尝试使用 PowerShell DSC 安装 HPC Pack 2012 R2 U3 设置。以下代码工作并安装软件:
$HpcPackName = "Microsoft HPC Pack 2012 R2 Server Components"
$HpcPackSourcePath = "C:\Temp\HPC2012R2_Update3_Full\setup.exe"
$sqlServer = "EMEAWINQA15"
$Arguments = "-unattend -headNode"
function InstallUsingProcess
{
[CmdletBinding()]
param()
Write-Verbose "HpcPackSourcePath: $HpcPackSourcePath"
Write-Verbose "Arguments: $Arguments"
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = $HpcPackSourcePath
$startInfo.Arguments = $Arguments
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
$exitcode = 0
$process.Start() | Out-Null
$process.WaitForExit()
if($process)
{
$exitCode = $process.ExitCode
Write-Verbose "Exit code: $exitCode"
}
}
InstallUsingProcess -Verbose
但是,当我使用 Script DSC 配置运行相同的操作时,它会成功,但会很快返回退出代码 10:
Configuration TestHpcInstall
{
Import-DscResource –ModuleName PSDesiredStateConfiguration
Node $AllNodes.Where({$_.Roles -contains 'HpcHeadNode'}).NodeName
{
$HpcPackName = "Microsoft HPC Pack 2012 R2 Server Components"
$HpcPackSourcePath = "C:\Temp\HPC2012R2_Update3_Full\setup.exe"
$sqlServer = "EMEAWINQA15"
$Arguments = "-unattend -headNode"
Script TestInstall
{
GetScript = {
return @{ "Result" = "$true"}
}
TestScript = {
return $false
}
SetScript = {
Write-Verbose "HpcPackSourcePath: $using:HpcPackSourcePath"
Write-Verbose "Arguments: $using:Arguments"
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = $using:HpcPackSourcePath
$startInfo.Arguments = $using:Arguments
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
$exitcode = 0
$process.Start() | Out-Null
$process.WaitForExit()
if($process)
{
$exitCode = $process.ExitCode
Write-Verbose "Exit code: $exitCode"
}
}
}
}
}
TestHpcInstall -ConfigurationData $configData -OutputPath "C:\Temp"
Start-DscConfiguration -ComputerName "EMEAWINQA15" -Path "C:\Temp\" -Verbose -Wait -Force
这与Package
资源使用的代码相同,但失败是因为返回了错误代码 10 而不是 0(这是成功安装包时的情况,如最上面的代码示例)。该设置不会产生任何输出或日志文件。
有任何想法吗?我难住了。