
WindowsFeature 리소스 및 NET-Framework-45-Core 기능을 통해 PowerShell DSC를 사용하여 Windows Server 2012 R2에 .NET Framework 4.5를 설치할 수 있습니다. 내 질문은 PowerShell DSC를 사용하여 .NET 4.5.2가 설치되었는지 어떻게 확인합니까?입니다.
답변1
이것이 여전히 OP에 필요한지 확실하지 않지만 최근에 똑같은 문제가 있었고 2012 R2 서버에서 패키지 리소스만 사용하려고 할 때 설치 프로그램 자체에 많은 문제가 있음을 발견했습니다. 전체 패키지가 매우 일반적인 오류로 인해 압축 해제에 계속 실패하면서 스크립트 리소스를 작성하고 웹 설치 프로그램을 사용해야 했습니다.
어쨌든, 제가 최종적으로 작업한 스크립트 리소스는 다음과 같습니다.
Configuration Net452Install
{
node "localhost"
{
LocalConfigurationManager
{
RebootNodeIfNeeded = $true
}
Script Install_Net_4.5.2
{
SetScript = {
$SourceURI = "https://download.microsoft.com/download/B/4/1/B4119C11-0423-477B-80EE-7A474314B347/NDP452-KB2901954-Web.exe"
$FileName = $SourceURI.Split('/')[-1]
$BinPath = Join-Path $env:SystemRoot -ChildPath "Temp\$FileName"
if (!(Test-Path $BinPath))
{
Invoke-Webrequest -Uri $SourceURI -OutFile $BinPath
}
write-verbose "Installing .Net 4.5.2 from $BinPath"
write-verbose "Executing $binpath /q /norestart"
Sleep 5
Start-Process -FilePath $BinPath -ArgumentList "/q /norestart" -Wait -NoNewWindow
Sleep 5
Write-Verbose "Setting DSCMachineStatus to reboot server after DSC run is completed"
$global:DSCMachineStatus = 1
}
TestScript = {
[int]$NetBuildVersion = 379893
if (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' | %{$_ -match 'Release'})
{
[int]$CurrentRelease = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').Release
if ($CurrentRelease -lt $NetBuildVersion)
{
Write-Verbose "Current .Net build version is less than 4.5.2 ($CurrentRelease)"
return $false
}
else
{
Write-Verbose "Current .Net build version is the same as or higher than 4.5.2 ($CurrentRelease)"
return $true
}
}
else
{
Write-Verbose ".Net build version not recognised"
return $false
}
}
GetScript = {
if (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' | %{$_ -match 'Release'})
{
$NetBuildVersion = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').Release
return $NetBuildVersion
}
else
{
Write-Verbose ".Net build version not recognised"
return ".Net 4.5.2 not found"
}
}
}
}
}
Net452Install -OutputPath $env:SystemDrive:\DSCconfig
Set-DscLocalConfigurationManager -ComputerName localhost -Path $env:SystemDrive\DSCconfig -Verbose
Start-DscConfiguration -ComputerName localhost -Path $env:SystemDrive:\DSCconfig -Verbose -Wait -Force
답변2
에 따르면이 Microsoft Technet 기사, 설치할 기능의 이름은 다음 중 하나여야 합니다.Get-Windows 기능명령의 결과. 따라서 .NET 4.5.2가 목록에 표시되지 않으면 DSC를 통해 설치되었는지 확인할 수 없습니다.
이름추가 또는 제거하려는 역할이나 기능의 이름을 나타냅니다. 이는 역할이나 기능의 표시 이름이 아니라 Get-WindowsFeature cmdlet의 Name 속성과 동일합니다.
따라서 DCS(4.5)를 통해 주요 버전을 설치한 다음 4.5.2로 업데이트하는 가장 좋은 솔루션을 찾아야 할 것 같습니다.