MSEndpointMgr

ConfigMgr 2012 SP1 – Prerequisites installation tool

As a ConfigMgr admin you’ve probably dealt with all the prerequisites that needs to be in place and configured properly before you can go ahead and install for example a Primary site. A couple of months back I released a PowerShell script that would help you to ease the pain a bit, and I’ve now translated that script into a PowerShell GUI (for those that still like to click). I’ve always wondered why Microsoft never included a tool like this. I’ve not measured how much time the tool saves in total, but I estimate it to be a hell of a lot faster (atleast that’s what my tests in a lab environment concluded).
The tool has the same functionality as the PowerShell script, but I’ll go over it once again:

  • Install Windows features for a Central Administration Site
  • Install Windows features for a Primary Site
  • Install Windows features for a Secondary Site
  • Install Windows features for an Application Catalog role
  • Install Windows features for a Distribution Point (New in version 1.1.0)
  • Extend the Active Directory Schema
  • Install WSUS and perform a post-configuration
  • Install Windows ADK 8.0 (online and offline)

I’ve mainly tested the script on Windows Server 2012, but some testing have been done on Windows Server 2008 R2 (with native PowerShell version) as well. I’d be really happy to get input, bugs or improvements that any of you may have. Please drop me an email or write a comment on this post.

Execute the tool

In order to run this tool, download the zip file from the link below. Run the Setup.cmd included in the zip and the tool will start. If you wish to manually create the PowerShell script file, copy the script code from below.
53_2
Download: Install-ConfigMgrPrereqs

#========================================================================
# Created on:   2013-10-05
# Created by:   Nickolaj Andersen
# Version:	1.1.0
# Twitter:	@NickolajA
# Blog:		www.scconfigmgr.com
#========================================================================
#Functions
function Validate-OS {
	if ((Get-WmiObject -Namespace "Root\CIMV2" -Class Win32_OperatingSystem | Select-Object -ExpandProperty ProductType) -eq 3) {
		Load-Form
	}
	else {
		$ShellObject = New-Object -ComObject Wscript.Shell
		$PopupValidate = $ShellObject.Popup("Detected OS is not supported.`nThis program can only run on a Windows Server OS.",0,"Non supported Operating System",0)
	}
}
function Load-Form {
	if ($host.Version -like "2.0") {
		Import-Module ServerManager
	}
	$Form.Controls.Add($LabelHeader)
	$Form.Controls.Add($BlogLink)
	$Form.Controls.Add($ButtonSecondarySite)
	$Form.Controls.Add($ButtonPrimarySite)
	$Form.Controls.Add($ButtonCAS)
	$Form.Controls.Add($ButtonAppCat)
	$Form.Controls.Add($ButtonDP)
	$Form.Controls.Add($ButtonExtendActiveDirectory)
	$Form.Controls.Add($ButtonWSUS)
	$Form.Controls.Add($ButtonADK)
	$Form.Controls.Add($GBSites)
	$Form.Controls.Add($GBSiteSystemRoles)
	$Form.Controls.Add($GBOther)
	$Form.Add_Shown({$Form.Activate()})
	[void] $Form.ShowDialog()
}
function Load-Start {
    $Form.Controls.Clear()
	$ProgressBar.Value = 0
	$TextBoxDC.Enabled = $true
	$Form.Controls.Add($LabelHeader)
	$Form.Controls.Add($BlogLink)
	$Form.Controls.Add($ButtonSecondarySite)
	$Form.Controls.Add($ButtonPrimarySite)
	$Form.Controls.Add($ButtonCAS)
	$Form.Controls.Add($ButtonAppCat)
	$Form.Controls.Add($ButtonDP)
	$Form.Controls.Add($ButtonExtendActiveDirectory)
	$Form.Controls.Add($ButtonWSUS)
	$Form.Controls.Add($ButtonADK)
	$Form.Controls.Add($GBSites)
	$Form.Controls.Add($GBSiteSystemRoles)
	$Form.Controls.Add($GBOther)
	Leave-WaterMarkStart
}
function Load-CAS {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallCAS)
	$OutputBox.ResetText()
	if ($ButtonInstallCAS.Enabled -eq $false) {
		$ButtonInstallCAS.Enabled = $true
	}
}
function Load-Primary {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallPrimarySite)
	$OutputBox.ResetText()
	if ($ButtonInstallPrimarySite.Enabled -eq $false) {
		$ButtonInstallPrimarySite.Enabled = $true
	}
}
function Load-Secondary {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallSecondarySite)
	$OutputBox.ResetText()
	if ($ButtonInstallSecondarySite.Enabled -eq $false) {
		$ButtonInstallSecondarySite.Enabled = $true
	}
}
function Load-AppCat {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallAppCat)
	$OutputBox.ResetText()
	if ($ButtonInstallAppCat.Enabled -eq $false) {
		$ButtonInstallAppCat.Enabled = $true
	}
}
function Load-DP {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallDP)
	$OutputBox.ResetText()
	if ($ButtonInstallDP.Enabled -eq $false) {
		$ButtonInstallDP.Enabled = $true
	}
}
function Load-ExtendActiveDirectory {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonConnectDC)
	$Form.Controls.Add($TextBoxDC)
	$OutputBox.ResetText()
	if ($ButtonExtendAD.Enabled -eq $false) {
		$ButtonExtendAD.Enabled = $true
	}
}
function Load-WSUS {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallWSUS)
	$OutputBox.ResetText()
	if ($ButtonInstallWSUS.Enabled -eq $false) {
		$ButtonInstallWSUS.Enabled = $true
	}
}
function Load-ADK {
	$Form.Controls.Clear()
    $Form.Controls.Add($ButtonBack)
	$Form.Controls.Add($ProgressBar)
	$Form.Controls.Add($OutputBox)
	$Form.Controls.Add($ButtonInstallADK)
	$Form.Controls.Add($RadioButtonOnline)
	$Form.Controls.Add($RadioButtonOffline)
	$Form.Controls.Add($GBADK)
	$RadioButtonOnline.Checked = $true
	$OutputBox.ResetText()
	if ($ButtonInstallADK.Enabled -eq $false) {
		$ButtonInstallADK.Enabled = $true
	}
	if ($RadioButtonOnline.Enabled -eq $false) {
		$RadioButtonOnline.Enabled = $true
	}
	if ($RadioButtonOffline.Enabled -eq $false) {
		$RadioButtonOffline.Enabled = $true
	}
}
function Validate-RebootPending {
	param(
	

[parameter(Mandatory=$true)]

$ComputerName ) $RebootPendingCBS = $null $RebootPendingWUAU = $null $GetOS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber,CSName -ComputerName $ComputerName $ConnectRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]”LocalMachine”,$ComputerName) if ($GetOS.BuildNumber -ge 6001) { $RegistryCBS = $ConnectRegistry.OpenSubKey(“SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\”).GetSubKeyNames() $RebootPendingCBS = $RegistryCBS -contains “RebootPending” } $RegistryWUAU = $ConnectRegistry.OpenSubKey(“SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\”).GetSubKeyNames() $RebootPendingWUAU = $RegistryWUAU -contains “RebootRequired” $RegistryPFRO = $ConnectRegistry.OpenSubKey(“SYSTEM\CurrentControlSet\Control\Session Manager\”) $RegistryValuePFRO = $RegistryPFRO.GetValue(“PendingFileRenameOperations”,$null) if ($RegistryValuePFRO) { $RebootPendingPFRO = $true } if (($RebootPendingCBS) -or ($RebootPendingWUAU) -or ($RebootPendingPFRO)) { return $true } else { return $false } } function Validate-CASInstall { $CASErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 6001) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $CASErrorHandler++ } if ($CASErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2008 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallCAS.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidateCASRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidateCASRebootPending) { $ButtonInstallCAS.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-CAS } } } function Validate-PrimaryInstall { $PrimaryErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 6001) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $PrimaryErrorHandler++ } if ($PrimaryErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2008 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallPrimarySite.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidatePrimaryRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidatePrimaryRebootPending) { $ButtonInstallPrimarySite.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-Primary } } } function Validate-SecondaryInstall { $SecondaryErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 6001) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $SecondaryErrorHandler++ } if ($SecondaryErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2008 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallSecondarySite.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidateSecondaryRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidateSecondaryRebootPending) { $ButtonInstallSecondarySite.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-Secondary } } } function Validate-AppCatInstall { $AppCatErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 6001) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $AppCatErrorHandler++ } if ($AppCatErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2008 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallAppCat.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidateAppCatRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidateAppCatRebootPending) { $ButtonInstallAppCat.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-AppCat } } } function Validate-DPInstall { $DPErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 6001) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $DPErrorHandler++ } if ($DPErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2008 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallDP.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidateDPRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidateDPRebootPending) { $ButtonInstallDP.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-DP } } } function Validate-ExtendActiveDirectory { if ($TextBoxDC.Text -eq $WaterMarkDC) { Write-OutputBox -OutputBoxMessage “Please enter a hostname of a domain controller” -Type “WARNING: ” } else { function Validate-DomainController { param(

[parameter(Mandatory=$true)]

$DCName ) Process { $DCs = ([System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite()).Servers $AvailableDCs = @() ForEach ($DC in $DCs) { $TCPClient = New-Object System.Net.Sockets.TCPClient $Connect = $TCPClient.BeginConnect($DC.Name,389,$null,$null) $Wait = $Connect.AsyncWaitHandle.WaitOne(250,$False) if ($TCPClient.Connected) { $Domain = $DC.Domain $AvailableDCs += $DC.Name.Replace(“.$($Domain)”,””) $CloseTCP = $TCPClient.Close() } } if ($AvailableDCs -match $DCName) { return $true } else { return $false } } } if (Validate-DomainController -DCName $TextBoxDC.Text) { if (-not(Test-Connection -ComputerName $TextBoxDC.Text -Count 1 -ErrorAction SilentlyContinue)) { Write-OutputBox -OutputBoxMessage “Unable to establish a connection to the server” -Type “ERROR: ” } else { Write-OutputBox -OutputBoxMessage “Successfully established a connection to the server” $TextBoxDC.Enabled = $false $Form.Controls.Remove($ButtonConnectDC) $Form.Controls.Add($ButtonInstallExtendAD) } } else { Write-OutputBox -OutputBoxMessage “Specified hostname is not a domain controller” } } } function Validate-WSUS { $WSUSErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 9200) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $WSUSErrorHandler++ } if ($WSUSErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2012 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallWSUS.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidateWSUSRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidateWSUSRebootPending) { $ButtonInstallWSUS.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-WSUS } } } function Validate-ADK { $ADKErrorHandler = 0 if ((([System.Environment]::OSVersion.Version).Build -lt 7600) -or ([System.Environment]::Is64BitOperatingSystem -eq $false)) { $ADKErrorHandler++ } if ($ADKErrorHandler -gt 0) { Write-OutputBox -OutputBoxMessage “Unsupported Operating System detected. Windows Server 2008 R2 64-bit and later is supported” -Type “ERROR: ” $ButtonInstallADK.Enabled = $false } else { $GetComputerName = $env:COMPUTERNAME $ValidateADKRebootPending = Validate-RebootPending -ComputerName $GetComputerName if ($ValidateADKRebootPending) { $ButtonInstallADK.Enabled = $false Write-OutputBox -OutputBoxMessage “A reboot is pending, please restart the system.” -Type “WARNING: ” } else { Install-ADK } } } function Install-CAS { $InstallType = 1 if ($host.Version -like “2.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”BITS”,”BITS-IIS-Ext”,”BITS-Compact-Server”,”RDC”,”WAS-Process-Model”,”WAS-Config-APIs”,”WAS-Net-Environment”,”Web-Server”,”Web-ISAPI-Ext”,”Web-ISAPI-Filter”,”Web-Net-Ext”,”Web-ASP-Net”,”Web-ASP”,”Web-Windows-Auth”,”Web-Basic-Auth”,”Web-URL-Auth”,”Web-IP-Security”,”Web-Scripting-Tools”,”Web-Mgmt-Service”,”Web-Stat-Compression”,”Web-Dyn-Compression”,”Web-Metabase”,”Web-WMI”,”Web-HTTP-Redirect”,”Web-Log-Libraries”,”Web-HTTP-Tracing”) } if ($host.Version -like “3.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”BITS”,”BITS-IIS-Ext”,”BITS-Compact-Server”,”RDC”,”WAS-Process-Model”,”WAS-Config-APIs”,”WAS-Net-Environment”,”Web-Server”,”Web-ISAPI-Ext”,”Web-ISAPI-Filter”,”Web-Net-Ext”,”Web-Net-Ext45″,”Web-ASP-Net”,”Web-ASP-Net45″,”Web-ASP”,”Web-Windows-Auth”,”Web-Basic-Auth”,”Web-URL-Auth”,”Web-IP-Security”,”Web-Scripting-Tools”,”Web-Mgmt-Service”,”Web-Stat-Compression”,”Web-Dyn-Compression”,”Web-Metabase”,”Web-WMI”,”Web-HTTP-Redirect”,”Web-Log-Libraries”,”Web-HTTP-Tracing”,”UpdateServices-RSAT”,”UpdateServices-API”,”UpdateServices-UI”) } $ProgressBar.Maximum = ($WinFeatures | Measure-Object).Count $ProgressPreference = “SilentlyContinue” $WarningPreference = “SilentlyContinue” $ButtonBack.Enabled = $false $ButtonInstallCAS.Enabled = $false $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (-NOT(Get-WindowsFeature -Name $CurrentFeature | Select-Object Name,Installed | Where-Object { $_.Installed -like “true” })) { Write-OutputBox -OutputBoxMessage “Installing role: $($CurrentFeatureDisplayName.DisplayName)” [System.Windows.Forms.Application]::DoEvents() if (([System.Environment]::OSVersion.Version).Build -lt 9200) { Add-WindowsFeature $CurrentFeature | Out-Null } if (([System.Environment]::OSVersion.Version).Build -ge 9200) { Start-Job -Name $CurrentFeature -ScriptBlock { param(

[parameter(Mandatory=$true)]

$CurrentFeature ) Add-WindowsFeature $CurrentFeature } -ArgumentList $CurrentFeature | Out-Null Wait-Job -Name $CurrentFeature Remove-Job -Name $CurrentFeature } } else { Write-OutputBox -OutputBoxMessage “Skipping role (already installed): $($CurrentFeatureDisplayName.DisplayName)” } $ProgressBar.PerformStep() } $ShellObject = New-Object -ComObject Wscript.Shell $PopupContinue = $ShellObject.Popup(“Installation completed. Would you like to download the prerequisite files?`n(A connection to the internet connection is required)”,0,”Prerequisites”,1) if ($PopupContinue -eq 1) { Get-PrereqFiles Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } } else { Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallCAS) $Form.Controls.Add($ButtonFinish) } $InstallType = 0 } function Install-Primary { $InstallType = 2 if ($host.Version -like “2.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”BITS”,”BITS-IIS-Ext”,”BITS-Compact-Server”,”RDC”,”WAS-Process-Model”,”WAS-Config-APIs”,”WAS-Net-Environment”,”Web-Server”,”Web-ISAPI-Ext”,”Web-ISAPI-Filter”,”Web-Net-Ext”,”Web-ASP-Net”,”Web-ASP”,”Web-Windows-Auth”,”Web-Basic-Auth”,”Web-URL-Auth”,”Web-IP-Security”,”Web-Scripting-Tools”,”Web-Mgmt-Service”,”Web-Stat-Compression”,”Web-Dyn-Compression”,”Web-Metabase”,”Web-WMI”,”Web-HTTP-Redirect”,”Web-Log-Libraries”,”Web-HTTP-Tracing”) } if ($host.Version -like “3.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”BITS”,”BITS-IIS-Ext”,”BITS-Compact-Server”,”RDC”,”WAS-Process-Model”,”WAS-Config-APIs”,”WAS-Net-Environment”,”Web-Server”,”Web-ISAPI-Ext”,”Web-ISAPI-Filter”,”Web-Net-Ext”,”Web-Net-Ext45″,”Web-ASP-Net”,”Web-ASP-Net45″,”Web-ASP”,”Web-Windows-Auth”,”Web-Basic-Auth”,”Web-URL-Auth”,”Web-IP-Security”,”Web-Scripting-Tools”,”Web-Mgmt-Service”,”Web-Stat-Compression”,”Web-Dyn-Compression”,”Web-Metabase”,”Web-WMI”,”Web-HTTP-Redirect”,”Web-Log-Libraries”,”Web-HTTP-Tracing”,”UpdateServices-RSAT”,”UpdateServices-API”,”UpdateServices-UI”) } $ProgressBar.Maximum = ($WinFeatures | Measure-Object).Count $ProgressPreference = “SilentlyContinue” $WarningPreference = “SilentlyContinue” $ButtonBack.Enabled = $false $ButtonInstallPrimarySite.Enabled = $false $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (-NOT(Get-WindowsFeature -Name $CurrentFeature | Select-Object Name,Installed | Where-Object { $_.Installed -like “true” })) { Write-OutputBox -OutputBoxMessage “Installing role: $($CurrentFeatureDisplayName.DisplayName)” [System.Windows.Forms.Application]::DoEvents() if (([System.Environment]::OSVersion.Version).Build -lt 9200) { Add-WindowsFeature $CurrentFeature | Out-Null } if (([System.Environment]::OSVersion.Version).Build -ge 9200) { Start-Job -Name $CurrentFeature -ScriptBlock { param(

[parameter(Mandatory=$true)]

$CurrentFeature ) Add-WindowsFeature $CurrentFeature } -ArgumentList $CurrentFeature | Out-Null Wait-Job -Name $CurrentFeature Remove-Job -Name $CurrentFeature } } else { Write-OutputBox -OutputBoxMessage “Skipping role (already installed): $($CurrentFeatureDisplayName.DisplayName)” } $ProgressBar.PerformStep() } $ShellObject = New-Object -ComObject Wscript.Shell $PopupContinue = $ShellObject.Popup(“Installation completed. Would you like to download the prerequisite files?`n(A connection to the internet connection is required)”,0,”Prerequisites”,1) if ($PopupContinue -eq 1) { Get-PrereqFiles Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } } else { Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallPrimarySite) $Form.Controls.Add($ButtonFinish) } $InstallType = 0 } function Install-Secondary { if ($host.Version -like “2.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”BITS”,”BITS-IIS-Ext”,”BITS-Compact-Server”,”RDC”,”WAS-Process-Model”,”WAS-Config-APIs”,”WAS-Net-Environment”,”Web-Server”,”Web-ISAPI-Ext”,”Web-Windows-Auth”,”Web-Basic-Auth”,”Web-URL-Auth”,”Web-IP-Security”,”Web-Scripting-Tools”,”Web-Mgmt-Service”,”Web-Metabase”,”Web-WMI”) } if ($host.Version -like “3.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”BITS”,”BITS-IIS-Ext”,”BITS-Compact-Server”,”RDC”,”WAS-Process-Model”,”WAS-Config-APIs”,”WAS-Net-Environment”,”Web-Server”,”Web-ISAPI-Ext”,”Web-Windows-Auth”,”Web-Basic-Auth”,”Web-URL-Auth”,”Web-IP-Security”,”Web-Scripting-Tools”,”Web-Mgmt-Service”,”Web-Metabase”,”Web-WMI”) } $ProgressBar.Maximum = ($WinFeatures | Measure-Object).Count $ProgressPreference = “SilentlyContinue” $WarningPreference = “SilentlyContinue” $ButtonBack.Enabled = $false $ButtonInstallSecondarySite.Enabled = $false $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (-NOT(Get-WindowsFeature -Name $CurrentFeature | Select-Object Name,Installed | Where-Object { $_.Installed -like “true” })) { Write-OutputBox -OutputBoxMessage “Installing role: $($CurrentFeatureDisplayName.DisplayName)” [System.Windows.Forms.Application]::DoEvents() if (([System.Environment]::OSVersion.Version).Build -lt 9200) { Add-WindowsFeature $CurrentFeature | Out-Null } if (([System.Environment]::OSVersion.Version).Build -ge 9200) { Start-Job -Name $CurrentFeature -ScriptBlock { param(

[parameter(Mandatory=$true)]

$CurrentFeature ) Add-WindowsFeature $CurrentFeature } -ArgumentList $CurrentFeature | Out-Null Wait-Job -Name $CurrentFeature Remove-Job -Name $CurrentFeature } } else { Write-OutputBox -OutputBoxMessage “Skipping role (already installed): $($CurrentFeatureDisplayName.DisplayName)” } $ProgressBar.PerformStep() } Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallSecondarySite) $Form.Controls.Add($ButtonFinish) } function Install-AppCat { if ($host.Version -like “2.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Core”,”NET-HTTP-Activation”,”NET-Non-HTTP-Activ”,”RDC”,”WAS”,”WAS-Process-Model”,”WAS-NET-Environment”,”WAS-Config-APIs”,”Web-Server”,”Web-WebServer”,”Web-Common-Http”,”Web-Static-Content”,”Web-Default-Doc”,”Web-App-Dev”,”Web-ASP-Net”,”Web-Net-Ext”,”Web-ISAPI-Ext”,”Web-ISAPI-Filter”,”Web-Security”,”Web-Windows-Auth”,”Web-Filtering”,”Web-Mgmt-Tools”,”Web-Mgmt-Console”,”Web-Scripting-Tools”,”Web-Mgmt-Compat”,”Web-Metabase”,”Web-Lgcy-Mgmt-Console”,”Web-Lgcy-Scripting”,”Web-WMI”) } if ($host.Version -like “3.0”) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“NET-Framework-Features”,”NET-Framework-Core”,”NET-HTTP-Activation”,”NET-Non-HTTP-Activ”,”NET-WCF-Services45″,”NET-WCF-HTTP-Activation45″,”RDC”,”WAS”,”WAS-Process-Model”,”WAS-NET-Environment”,”WAS-Config-APIs”,”Web-Server”,”Web-WebServer”,”Web-Common-Http”,”Web-Static-Content”,”Web-Default-Doc”,”Web-App-Dev”,”Web-ASP-Net”,”Web-ASP-Net45″,”Web-Net-Ext”,”Web-Net-Ext45″,”Web-ISAPI-Ext”,”Web-ISAPI-Filter”,”Web-Security”,”Web-Windows-Auth”,”Web-Filtering”,”Web-Mgmt-Tools”,”Web-Mgmt-Console”,”Web-Scripting-Tools”,”Web-Mgmt-Compat”,”Web-Metabase”,”Web-Lgcy-Mgmt-Console”,”Web-Lgcy-Scripting”,”Web-WMI”) } $ProgressBar.Maximum = ($WinFeatures | Measure-Object).Count $ProgressPreference = “SilentlyContinue” $WarningPreference = “SilentlyContinue” $ButtonBack.Enabled = $false $ButtonInstallAppCat.Enabled = $false $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (-NOT(Get-WindowsFeature -Name $CurrentFeature | Select-Object Name,Installed | Where-Object { $_.Installed -like “true” })) { Write-OutputBox -OutputBoxMessage “Installing role: $($CurrentFeatureDisplayName.DisplayName)” [System.Windows.Forms.Application]::DoEvents() if (([System.Environment]::OSVersion.Version).Build -lt 9200) { Add-WindowsFeature $CurrentFeature | Out-Null } if (([System.Environment]::OSVersion.Version).Build -ge 9200) { Start-Job -Name $CurrentFeature -ScriptBlock { param(

[parameter(Mandatory=$true)]

$CurrentFeature ) Add-WindowsFeature $CurrentFeature } -ArgumentList $CurrentFeature | Out-Null Wait-Job -Name $CurrentFeature Remove-Job -Name $CurrentFeature } } else { Write-OutputBox -OutputBoxMessage “Skipping role (already installed): $($CurrentFeatureDisplayName.DisplayName)” } $ProgressBar.PerformStep() } Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallAppCat) $Form.Controls.Add($ButtonFinish) } function Install-DP { if ($host.Version.Major -eq 2) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“FS-FileServer”,”RDC”,”Web-WebServer”,”Web-Common-Http”,”Web-Default-Doc”,”Web-Dir-Browsing”,”Web-Http-Errors”,”Web-Static-Content”,”Web-Http-Redirect”,”Web-Health”,”Web-Http-Logging”,”Web-Performance”,”Web-Stat-Compression”,”Web-Security”,”Web-Filtering”,”Web-Windows-Auth”,”Web-App-Dev”,”Web-ISAPI-Ext”,”Web-Mgmt-Tools”,”Web-Mgmt-Console”,”Web-Mgmt-Compat”,”Web-Metabase”,”Web-WMI”,”Web-Scripting-Tools”) } if ($host.Version.Major -eq 3) { Write-OutputBox -OutputBoxMessage “Detected PowerShell version is $($host.Version)” $WinFeatures = @(“FS-FileServer”,”RDC”,”Web-WebServer”,”Web-Common-Http”,”Web-Default-Doc”,”Web-Dir-Browsing”,”Web-Http-Errors”,”Web-Static-Content”,”Web-Http-Redirect”,”Web-Health”,”Web-Http-Logging”,”Web-Performance”,”Web-Stat-Compression”,”Web-Security”,”Web-Filtering”,”Web-Windows-Auth”,”Web-App-Dev”,”Web-ISAPI-Ext”,”Web-Mgmt-Tools”,”Web-Mgmt-Console”,”Web-Mgmt-Compat”,”Web-Metabase”,”Web-WMI”,”Web-Scripting-Tools”) } $ProgressBar.Maximum = ($WinFeatures | Measure-Object).Count $ProgressPreference = “SilentlyContinue” $WarningPreference = “SilentlyContinue” $ButtonBack.Enabled = $false $ButtonInstallDP.Enabled = $false $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (-NOT(Get-WindowsFeature -Name $CurrentFeature | Select-Object Name,Installed | Where-Object { $_.Installed -like “true” })) { Write-OutputBox -OutputBoxMessage “Installing role: $($CurrentFeatureDisplayName.DisplayName)” [System.Windows.Forms.Application]::DoEvents() if (([System.Environment]::OSVersion.Version).Build -lt 9200) { Add-WindowsFeature $CurrentFeature | Out-Null } if (([System.Environment]::OSVersion.Version).Build -ge 9200) { Start-Job -Name $CurrentFeature -ScriptBlock { param(

[parameter(Mandatory=$true)]

$CurrentFeature ) Add-WindowsFeature $CurrentFeature } -ArgumentList $CurrentFeature | Out-Null Wait-Job -Name $CurrentFeature Remove-Job -Name $CurrentFeature } } else { Write-OutputBox -OutputBoxMessage “Skipping role (already installed): $($CurrentFeatureDisplayName.DisplayName)” } $ProgressBar.PerformStep() } Write-OutputBox -OutputBoxMessage “Starting verification that all features where successfully installed” $ErrorVerify = 0 $ProgressBar.Value = 0 $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (Get-WindowsFeature $CurrentFeature | Where-Object { $_.Installed -eq $true}) { Write-OutputBox “Verified installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } else { $ErrorVerify++ Write-OutputBox “Feature not installed: $($CurrentFeatureDisplayName.DisplayName)” $ProgressBar.PerformStep() } } if ($ErrorVerify -eq 0) { Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” } else { Write-OutputBox -OutputBoxMessage “One or more Windows Features was not installed” } $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallDP) $Form.Controls.Add($ButtonFinish) } function Extend-ActiveDirectorySchema { $Form.Controls.Remove($ButtonConnectDC) $Form.Controls.Add($ButtonExtendActiveDirectory) $CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent() $WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($CurrentUser) if (($WindowsPrincipal.IsInRole(“Domain Admins”)) -and ($WindowsPrincipal.IsInRole(“Schema Admins”))) { do { $SetupDLLocation = Read-FolderBrowserDialog -Message “Browse to the ‘<ConfigMgr source files>\SMSSETUP\BIN\X64’ folder.” } until (Test-Path -Path “$($SetupDLLocation)\EXTADSCH.EXE”) $DC = $TextBoxDC.Text $GetPath = Get-ChildItem -Recurse -Filter “EXTADSCH.EXE” -Path “$($SetupDLLocation)” $Path = $GetPath.DirectoryName + “\EXTADSCH.EXE” $Destination = “\\” + $DC + “\C$” Write-OutputBox -OutputBoxMessage “Copying EXTADSCH.EXE to the specified domain controller” Copy-Item $Path $Destination -Force Write-OutputBox -OutputBoxMessage “Starting to extend the Active Directory schema” Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList “C:\EXTADSCH.EXE” -ComputerName $DC | Out-Null Start-Sleep -Seconds 10 $Content = Get-Content -Path “\\$($DC)\C$\extadsch.log” if ($Content -match “Successfully extended the Active Directory schema”) { Write-OutputBox -OutputBoxMessage “Active Directory schema was successfully extended” $Form.Controls.Remove($ButtonInstallExtendAD) $Form.Controls.Add($ButtonFinish) } else { Write-OutputBox -OutputBoxMessage “Active Directory was not extended successfully, refer to C:\ExtADSch.log on the domain controller” -Type “ERROR: ” } } else { Write-OutputBox -OutputBoxMessage “Current logged on user is not a member of the Domain Admins group” -Type “ERROR: ” } } function Install-WSUS { $WinFeatures = @(“UpdateServices”,”UpdateServices-WidDB”,”UpdateServices-Services”,”UpdateServices-RSAT”,”UpdateServices-API”,”UpdateServices-UI”) $ProgressBar.Maximum = 10 $ProgressPreference = “SilentlyContinue” $WarningPreference = “SilentlyContinue” $ButtonBack.Enabled = $false $ButtonInstallWSUS.Enabled = $false $ProgressBar.PerformStep() $WinFeatures | ForEach-Object { $CurrentFeature = $_ $CurrentFeatureDisplayName = Get-WindowsFeature | Select-Object Name,DisplayName | Where-Object { $_.Name -like “$($CurrentFeature)”} if (-NOT(Get-WindowsFeature -Name $CurrentFeature | Select-Object Name,Installed | Where-Object { $_.Installed -like “true” })) { Write-OutputBox -OutputBoxMessage “Installing role: $($CurrentFeatureDisplayName.DisplayName)” Start-Job -Name $CurrentFeature -ScriptBlock { param(

[parameter(Mandatory=$true)]

$CurrentFeature ) Add-WindowsFeature $CurrentFeature } -ArgumentList $CurrentFeature | Out-Null Wait-Job -Name $CurrentFeature Remove-Job -Name $CurrentFeature } else { Write-OutputBox -OutputBoxMessage “Skipping role (already installed): $($CurrentFeatureDisplayName.DisplayName)” } $ProgressBar.PerformStep() } Write-OutputBox -OutputBoxMessage “Successfully installed all required Windows Features” $WSUSContentPath = Read-FolderBrowserDialog -Message “Choose a location where WSUS content will be stored, e.g. C:\WSUS” $ProgressBar.PerformStep() if (!(Test-Path -Path $WSUSContentPath)) { New-Item $WSUSContentPath -ItemType Directory | Out-Null } if (Test-Path -Path “$Env:ProgramFiles\Update Services\Tools\WsusUtil.exe”) { $WSUSUtil = “$Env:ProgramFiles\Update Services\Tools\WsusUtil.exe” $WSUSUtilArgs = “POSTINSTALL CONTENT_DIR=$WSUSContentPath” Write-OutputBox -OutputBoxMessage “Starting WSUS post install configuration” $ProgressBar.PerformStep() Start-Process -FilePath $WSUSUtil -ArgumentList $WSUSUtilArgs -NoNewWindow -Wait -RedirectStandardOutput “C:\temp.txt” | Out-Null Remove-Item “C:\temp.txt” -Force $ProgressBar.PerformStep() Write-OutputBox -OutputBoxMessage “Successfully installed and configured WSUS” $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallWSUS) $Form.Controls.Add($ButtonFinish) } else { $ProgressBar.PerformStep() Write-OutputBox -OutputBoxMessage “Unable to locate $($WSUSUtil)” $ProgressBar.PerformStep() $ButtonBack.Enabled = $true $ButtonInstallWSUS.Enabled = $true } } function Install-ADK { $RadioButtonOnline.Enabled = $false $RadioButtonOffline.Enabled = $false $ButtonInstallADK.Enabled = $false $ButtonBack.Enabled = $false $ADKInstalledFeatures = @() $ComputerName = $env:COMPUTERNAME $UninstallKey = “SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall” $Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’,$ComputerName) $RegistryKey = $Registry.OpenSubKey($UninstallKey) $SubKeys = $RegistryKey.GetSubKeyNames() ForEach ($Key in $SubKeys) { $CurrentKey = $UninstallKey + “\\” + $Key $CurrentSubKey = $Registry.OpenSubKey($CurrentKey) $DisplayName = $CurrentSubKey.GetValue(“DisplayName”) if ($DisplayName -like “Windows PE x86 x64”) { $ADKInstalledFeatures += $DisplayName } elseif ($DisplayName -like “User State Migration Tool”) { $ADKInstalledFeatures += $DisplayName } elseif ($DisplayName -like “Windows Deployment Tools”) { $ADKInstalledFeatures += $DisplayName } } if (($RadioButtonOnline.Checked -eq $true) -AND ($ADKInstalledFeatures.Length -ne 3)) { $ADKOnlineArguments = “/norestart /q /ceip off /features OptionId.WindowsPreinstallationEnvironment OptionId.DeploymentTools OptionId.UserStateMigrationTool” $ADKDownloadFolder = “C:\Downloads” $ADKSetupFile = “adksetup.exe” Get-WebDownloadFile -URL “https://download.microsoft.com/download/9/9/F/99F5E440-5EB5-4952-9935-B99662C3DF70/adk/adksetup.exe” -DownloadFolder $ADKDownloadFolder -FileName $ADKSetupFile Write-OutputBox -OutputBoxMessage “Download completed” [System.Windows.Forms.Application]::DoEvents() Write-OutputBox -OutputBoxMessage “Starting Windows ADK installation” [System.Windows.Forms.Application]::DoEvents() Write-OutputBox -OutputBoxMessage “Downloading Windows ADK components and installing, this will take some time” [System.Windows.Forms.Application]::DoEvents() Start-Process -FilePath “$($ADKDownloadFolder)\$($ADKSetupFile)” -ArgumentList $ADKOnlineArguments while (Get-WmiObject -Class Win32_Process -Filter ‘Name=”adksetup.exe”‘) { [System.Windows.Forms.Application]::DoEvents() Start-Sleep -Milliseconds 500 } Write-OutputBox -OutputBoxMessage “Successfully installed Windows ADK” } elseif (($RadioButtonOffline.Checked -eq $true) -AND ($ADKInstalledFeatures.Length -ne 3)) { $ADKOfflineArguments = “/norestart /q /ceip off /features OptionId.WindowsPreinstallationEnvironment OptionId.DeploymentTools OptionId.UserStateMigrationTool” $ADKSetupFile = “adksetup.exe” do { $SetupLocation = Read-FolderBrowserDialog -Message “Select the folder where adksetup.exe is located” if (-not(Test-Path -Path “$($SetupLocation)\$($ADKSetupFile)”)) { $ADKShellObject = New-Object -ComObject Wscript.Shell $PopupValidate = $ADKShellObject.Popup(“Unable to find $($ADKSetupFile) in the selected folder”,0,”Unable to locate file”,0) } } until (Test-Path -Path “$($SetupLocation)\$($ADKSetupFile)”) Write-OutputBox -OutputBoxMessage “Starting Windows ADK installation, this will take some time” Start-Process -FilePath “$($SetupLocation)\$($ADKSetupFile)” -ArgumentList $ADKOfflineArguments while (Get-WmiObject -Class Win32_Process -Filter ‘Name=”adksetup.exe”‘) { [System.Windows.Forms.Application]::DoEvents() Start-Sleep -Milliseconds 500 } Write-OutputBox -OutputBoxMessage “Successfully installed Windows ADK” } else { if ($ADKInstalledFeatures.Length -eq 3) { Write-OutputBox -OutputBoxMessage “All required Windows ADK features are already installed, skipping install” -Type “INFO: ” } } $ButtonBack.Enabled = $true $Form.Controls.Remove($ButtonInstallADK) $Form.Controls.Add($ButtonFinish) } function Read-FolderBrowserDialog { param(

[parameter(Mandatory=$true)]

[string]$Message ) $ShellApplication = New-Object -ComObject Shell.Application $FolderBrowserDialog = $ShellApplication.BrowseForFolder(0,”$($Message)”,0,17) if ($FolderBrowserDialog) { return $FolderBrowserDialog.Self.Path } else { return “” } } function Clear-OutputBox { $OutputBox.ResetText() } function Get-WebDownloadFile { param( [Parameter(Mandatory=$true)] [String]$URL, [Parameter(Mandatory=$true)] [string]$DownloadFolder, [Parameter(Mandatory=$true)] [string]$FileName ) process { $ProgressBar.Maximum = 100 $ProgressBar.Value = 0 $WebClient = New-Object System.Net.WebClient if (-not(Test-Path -Path $DownloadFolder)) { Write-OutputBox -OutputBoxMessage “Creating download folder: $($DownloadFolder)” [System.Windows.Forms.Application]::DoEvents() New-Item $DownloadFolder -ItemType Directory | Out-Null } $Global:DownloadComplete = $False $EventDataComplete = Register-ObjectEvent $WebClient DownloadFileCompleted -SourceIdentifier WebClient.DownloadFileComplete -Action {$Global:DownloadComplete = $True} $EventDataProgress = Register-ObjectEvent $WebClient DownloadProgressChanged -SourceIdentifier WebClient.DownloadProgressChanged -Action { $Global:DPCEventArgs = $EventArgs } $WebClient.DownloadFileAsync($URL, “$($DownloadFolder)\$($FileName)”) Write-OutputBox -OutputBoxMessage “Downloading ($($FileName) to $($DownloadFolder)” do { $PercentComplete = $Global:DPCEventArgs.ProgressPercentage $DownloadedBytes = $Global:DPCEventArgs.BytesReceived $TotalBytes = $Global:DPCEventArgs.TotalBytesToReceive $ProgressBar.Value = $PercentComplete [System.Windows.Forms.Application]::DoEvents() } until ($Global:DownloadComplete) $WebClient.Dispose() Unregister-Event -SourceIdentifier WebClient.DownloadProgressChanged Unregister-Event -SourceIdentifier WebClient.DownloadFileComplete } } function Get-PrereqFiles { $DownloadDestination = “C:\ConfigMgrPrereqs” if (-not(Test-Path -Path $DownloadDestination)) { New-Item -ItemType Directory -Path $DownloadDestination } do { $SetupDLLocation = Read-FolderBrowserDialog -Message “Browse to the ‘<ConfigMgr source files>\SMSSETUP\BIN\X64’ folder.” } until (Test-Path -Path “$($SetupDLLocation)\setupdl.exe”) Write-OutputBox -OutputBoxMessage “Downloading prerequites from Microsoft” do { Start-Process -FilePath “$($SetupDLLocation)\setupdl.exe” -ArgumentList “$($DownloadDestination)” -Wait } until ((Get-ChildItem -Path $DownloadDestination | Measure-Object).Count -ge 59) Write-OutputBox -OutputBoxMessage “Successfully downloaded all prerequisites” $ButtonBack.Enabled = $true if ($InstallType -eq 1) { $Form.Controls.Remove($ButtonInstallCAS) } if ($InstallType -eq 2) { $Form.Controls.Remove($ButtonInstallPrimarySite) } $Form.Controls.Add($ButtonFinish) } function Write-OutputBox { param(

[parameter(Mandatory=$true)]

[string]$OutputBoxMessage, [ValidateSet(“WARNING: “,”ERROR: “,”INFO: “)] [string]$Type ) Process { if ($OutputBox.Text.Length -eq 0) { $OutputBox.Text = “$($Type)$($OutputBoxMessage)” [System.Windows.Forms.Application]::DoEvents() } else { $OutputBox.AppendText(“`n$($Type)$($OutputBoxMessage)”) [System.Windows.Forms.Application]::DoEvents() } } } function Enter-WaterMark { if ($TextBoxDC.Text -eq $WaterMarkDC) { $TextBoxDC.Text = “” $TextBoxDC.ForeColor = “WindowText” } } function Leave-WaterMark { if ($TextBoxDC.Text -eq “”) { $TextBoxDC.Text = $WaterMarkDC $TextBoxDC.ForeColor = “LightGray” } } function Leave-WaterMarkStart { if ($TextBoxDC.Text.Length -gt 0) { $TextBoxDC.Text = $WaterMarkDC $TextBoxDC.ForeColor = “LightGray” } } #Assemblies [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”) [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) #Variables $InstallType = 0 #Form $Form = New-Object System.Windows.Forms.Form $Form.Size = New-Object System.Drawing.Size(800,500) $Form.MinimumSize = New-Object System.Drawing.Size(800,500) $Form.MaximumSize = New-Object System.Drawing.Size(800,500) $Form.SizeGripStyle = “Hide” $Form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($PSHome + “\powershell.exe”) $Form.Text = “ConfigMgr 2012 SP1 Prerequisites Installation Tool – 1.1.0” #ProgressBar $ProgressBar = New-Object System.Windows.Forms.ProgressBar $ProgressBar.Location = New-Object System.Drawing.Size(10,375) $ProgressBar.Size = New-Object System.Drawing.Size(763,30) $ProgressBar.Step = 1 $ProgressBar.Value = 0 #OutputBox $OutputBox = New-Object System.Windows.Forms.RichTextBox $OutputBox.Location = New-Object System.Drawing.Size(10,10) $OutputBox.Size = New-Object System.Drawing.Size(763,350) $OutputBox.Font = “Courier New” $OutputBox.BackColor = “white” $OutputBox.ReadOnly = $true $OutputBox.MultiLine = $True #Textboxes $TextBoxDC = New-Object System.Windows.Forms.TextBox $TextBoxDC.Location = New-Object System.Drawing.Size(10,425) $TextBoxDC.Size = New-Object System.Drawing.Size(170,20) $TextBoxDC.TabIndex = “0” #Buttons $ButtonCAS = New-Object System.Windows.Forms.Button $ButtonCAS.Location = New-Object System.Drawing.Size(60,130) $ButtonCAS.Size = New-Object System.Drawing.Size(200,80) $ButtonCAS.Text = “Central Administration Site” $ButtonCAS.TabIndex = “1” $ButtonCAS.Add_Click({Load-CAS}) $ButtonPrimarySite = New-Object System.Windows.Forms.Button $ButtonPrimarySite.Location = New-Object System.Drawing.Size(60,230) $ButtonPrimarySite.Size = New-Object System.Drawing.Size(200,80) $ButtonPrimarySite.Text = “Primary Site” $ButtonPrimarySite.TabIndex = “2” $ButtonPrimarySite.Add_Click({Load-Primary}) $ButtonSecondarySite = New-Object System.Windows.Forms.Button $ButtonSecondarySite.Location = New-Object System.Drawing.Size(60,330) $ButtonSecondarySite.Size = New-Object System.Drawing.Size(200,80) $ButtonSecondarySite.Text = “Secondary Site” $ButtonSecondarySite.TabIndex = “3” $ButtonSecondarySite.Add_Click({Load-Secondary}) $ButtonAppCat = New-Object System.Windows.Forms.Button $ButtonAppCat.Location = New-Object System.Drawing.Size(290,130) $ButtonAppCat.Size = New-Object System.Drawing.Size(200,80) $ButtonAppCat.Text = “Application Catalog” $ButtonAppCat.TabIndex = “4” $ButtonAppCat.Add_Click({Load-AppCat}) $ButtonDP = New-Object System.Windows.Forms.Button $ButtonDP.Location = New-Object System.Drawing.Size(290,230) $ButtonDP.Size = New-Object System.Drawing.Size(200,80) $ButtonDP.Text = “Distribution Point” $ButtonDP.TabIndex = “5” $ButtonDP.Add_Click({Load-DP}) $ButtonExtendActiveDirectory = New-Object System.Windows.Forms.Button $ButtonExtendActiveDirectory.Location = New-Object System.Drawing.Size(520,130) $ButtonExtendActiveDirectory.Size = New-Object System.Drawing.Size(200,80) $ButtonExtendActiveDirectory.Text = “Extend Active Directory” $ButtonExtendActiveDirectory.TabIndex = “6” $ButtonExtendActiveDirectory.Add_Click({Load-ExtendActiveDirectory}) $ButtonWSUS = New-Object System.Windows.Forms.Button $ButtonWSUS.Location = New-Object System.Drawing.Size(520,230) $ButtonWSUS.Size = New-Object System.Drawing.Size(200,80) $ButtonWSUS.Text = “Install WSUS” $ButtonWSUS.TabIndex = “7” $ButtonWSUS.Add_Click({Load-WSUS}) $ButtonADK = New-Object System.Windows.Forms.Button $ButtonADK.Location = New-Object System.Drawing.Size(520,330) $ButtonADK.Size = New-Object System.Drawing.Size(200,80) $ButtonADK.Text = “Install ADK” $ButtonADK.TabIndex = “8” $ButtonADK.Add_Click({Load-ADK}) $ButtonInstallCAS = New-Object System.Windows.Forms.Button $ButtonInstallCAS.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallCAS.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallCAS.Text = “Install” $ButtonInstallCAS.TabIndex = “1” $ButtonInstallCAS.Add_Click({Validate-CASInstall}) $ButtonInstallPrimarySite = New-Object System.Windows.Forms.Button $ButtonInstallPrimarySite.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallPrimarySite.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallPrimarySite.Text = “Install” $ButtonInstallPrimarySite.TabIndex = “1” $ButtonInstallPrimarySite.Add_Click({Validate-PrimaryInstall}) $ButtonInstallSecondarySite = New-Object System.Windows.Forms.Button $ButtonInstallSecondarySite.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallSecondarySite.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallSecondarySite.Text = “Install” $ButtonInstallSecondarySite.TabIndex = “1” $ButtonInstallSecondarySite.Add_Click({Validate-SecondaryInstall}) $ButtonInstallAppCat = New-Object System.Windows.Forms.Button $ButtonInstallAppCat.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallAppCat.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallAppCat.Text = “Install” $ButtonInstallAppCat.TabIndex = “1” $ButtonInstallAppCat.Add_Click({Validate-AppCatInstall}) $ButtonInstallDP = New-Object System.Windows.Forms.Button $ButtonInstallDP.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallDP.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallDP.Text = “Install” $ButtonInstallDP.TabIndex = “1” $ButtonInstallDP.Add_Click({Validate-DPInstall}) $ButtonInstallExtendAD = New-Object System.Windows.Forms.Button $ButtonInstallExtendAD.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallExtendAD.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallExtendAD.Text = “Extend” $ButtonInstallExtendAD.TabIndex = “1” $ButtonInstallExtendAD.Add_Click({Extend-ActiveDirectorySchema}) $ButtonConnectDC = New-Object System.Windows.Forms.Button $ButtonConnectDC.Location = New-Object System.Drawing.Size(673,420) $ButtonConnectDC.Size = New-Object System.Drawing.Size(100,30) $ButtonConnectDC.Text = “Connect” $ButtonConnectDC.TabIndex = “1” $ButtonConnectDC.Add_Click({Validate-ExtendActiveDirectory}) $ButtonInstallWSUS = New-Object System.Windows.Forms.Button $ButtonInstallWSUS.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallWSUS.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallWSUS.Text = “Install” $ButtonInstallWSUS.TabIndex = “1” $ButtonInstallWSUS.Add_Click({Validate-WSUS}) $ButtonInstallADK= New-Object System.Windows.Forms.Button $ButtonInstallADK.Location = New-Object System.Drawing.Size(673,420) $ButtonInstallADK.Size = New-Object System.Drawing.Size(100,30) $ButtonInstallADK.Text = “Install” $ButtonInstallADK.TabIndex = “1” $ButtonInstallADK.Add_Click({Validate-ADK}) $ButtonContinue = New-Object System.Windows.Forms.Button $ButtonContinue.Location = New-Object System.Drawing.Size(673,420) $ButtonContinue.Size = New-Object System.Drawing.Size(100,30) $ButtonContinue.Text = “Continue” $ButtonContinue.TabIndex = “1” $ButtonContinue.Add_Click({Get-PrereqFiles}) $ButtonBack = New-Object System.Windows.Forms.Button $ButtonBack.Location = New-Object System.Drawing.Size(563,420) $ButtonBack.Size = New-Object System.Drawing.Size(100,30) $ButtonBack.Text = “Back” $ButtonBack.TabIndex = “2” $ButtonBack.Add_Click({Load-Start}) $ButtonFinish = New-Object System.Windows.Forms.Button $ButtonFinish.Location = New-Object System.Drawing.Size(673,420) $ButtonFinish.Size = New-Object System.Drawing.Size(100,30) $ButtonFinish.Text = “Finish” $ButtonFinish.TabIndex = “1” $ButtonFinish.Add_Click({$Form.Close()}) #WaterMarks $WaterMarkDC = “Enter domain controller hostname” $TextBoxDC.ForeColor = “LightGray” $TextBoxDC.Text = $WaterMarkDC $TextBoxDC.add_Enter({Enter-WaterMark}) $TextBoxDC.add_Leave({Leave-WaterMark}) #Text $LabelHeader = New-Object System.Windows.Forms.Label $LabelHeader.Location = New-Object System.Drawing.Size(180,20) $LabelHeader.Size = New-Object System.Drawing.Size(600,30) $LabelHeader.Text = “Install ConfigMgr 2012 SP1 Prerequisites” $LabelHeader.Font = New-Object System.Drawing.Font(“Verdana”,14,[System.Drawing.FontStyle]::Bold) #Links $OpenLink = {[System.Diagnostics.Process]::Start(“https://msendpointmgr.com”)} $BlogLink = New-Object System.Windows.Forms.LinkLabel $BlogLink.Location = New-Object System.Drawing.Size(330,50) $BlogLink.Size = New-Object System.Drawing.Size(150,25) $BlogLink.Text = “www.scconfigmgr.com” $BlogLink.Add_Click($OpenLink) #RadioButtons $RadioButtonOnline = New-Object System.Windows.Forms.RadioButton $RadioButtonOnline.Location = New-Object System.Drawing.Size(20,427) $RadioButtonOnline.Size = New-Object System.Drawing.Size(60,24) $RadioButtonOnline.Text = “Online” $RadioButtonOffline = New-Object System.Windows.Forms.RadioButton $RadioButtonOffline.Location = New-Object System.Drawing.Size(90,427) $RadioButtonOffline.Size = New-Object System.Drawing.Size(60,24) $RadioButtonOffline.Text = “Offline” #Group boxes $GBSites = New-Object System.Windows.Forms.GroupBox $GBSites.Location = New-Object System.Drawing.Size(50,100) $GBSites.Size = New-Object System.Drawing.Size(220,340) $GBSites.Text = “Sites” $GBSiteSystemRoles = New-Object System.Windows.Forms.GroupBox $GBSiteSystemRoles.Location = New-Object System.Drawing.Size(280,100) $GBSiteSystemRoles.Size = New-Object System.Drawing.Size(220,340) $GBSiteSystemRoles.Text = “Site System Roles” $GBOther = New-Object System.Windows.Forms.GroupBox $GBOther.Location = New-Object System.Drawing.Size(510,100) $GBOther.Size = New-Object System.Drawing.Size(220,340) $GBOther.Text = “Other” $GBADK = New-Object System.Windows.Forms.GroupBox $GBADK.Location = New-Object System.Drawing.Size(10,410) $GBADK.Size = New-Object System.Drawing.Size(190,45) $GBADK.Text = “Installation methods” #Create the form Validate-OS

Nickolaj Andersen

Chief Technical Architect and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences such as Microsoft Ignite, NIC Conference and IT/Dev Connections including nordic user groups.

11 comments

    • I just tried on a Windows Server 2012 R2, where I launched a PowerShell console elevated, configured the execution policy to RemoteSigned and then ran the script. It worked fine!
      Are you doing the same?
      Regards,
      Nickolaj

  • Nickolaj,
    first, thanks for the great job and sharing!
    I used your power shell…
    In GUI tool I would like to use DP prereq.
    For some reason when run setup CMD window opens and closed immediately. No GUI.
    I run it as admin, UAC is disabled…
    What it could be?

  • Small remark,my lab is pretty small due to hardware limitations i have installed a standalone primary site + DC on one server (I know, I know, i shouldn’t…).
    Anyways, this is a problem when I launch you script on my Windows server 2012 and I got a message telling me that my system is not an Server OS…Actually it is, but it is also a DC.
    I had to change your “Validate-Os” function to the following line:
    “Get-WmiObject -Namespace “Root\CIMV2″ -Class Win32_OperatingSystem | Select-Object -ExpandProperty ProductType) -eq 3 -or 2)”
    If this tools is intended to help us to build up faster our labs, perhaps it would be nice to be able to use it on a DC ^^.
    I hope this helps,
    Great work !!

    • Hi Stéphane,
      I wrote it like that with a single purpose, so that when launched on a Domain Controller it would not work. Even in a lab environment it’s not a good idea to run ConfigMgr on the DC. But you know that and was able to get around it 😉
      This tool was designed for admins when they’re setting up new environments in production, and I thought it would be good to try and script my way around unsupported configurations.
      I’m glad that you like it, and I hope it helps get your environment up and running a lot faster!
      Regards,
      Nickolaj

    • Hi Sam,
      Thanks for pointing that out. I’ll create an option for that 🙂
      Basically, yes you could use the Primary Site button for now.
      Regards,
      Nickolaj

      • I’ve added this option now, and I also found a bug that has been fixed. Just need to verify that it’s running on Windows Server 2008 R2 and I’ll release the new version.
        /Nickolaj

Sponsors