If(-not([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")){Write-Output"This script must be run as an administrator";Exit1}
Catch{Write-Error"Could not get Win32_OperatingSystem CIM instance`n"+$_.Exception.Message;Exit1}
# Exit if the endpoint is not running Windows 10
If(($OS.Caption-notmatch"Windows 10")){Write-Output"This endpoint is not running Windows 10";Exit1}
Else{Write-Output"This endpoint is running Windows 10"}
# Exit if the endpoint is not running a Pro/Enterprise edition of Windows
If(($OS.Caption-notmatch"Pro")-and($OS.Caption-notmatch"Enterprise")){Write-Output"Only Pro/Enterprise versions of Windows can be upgraded";Exit1}
Else{Write-Output"This endpoint is running a Pro/Enterprise version of Windows"}
# Exit if the endpoint is a server edition
Try
{
If($OS.ProductType-gt1){Write-Output"Server operating system will not be upgraded";Exit1}
Else{Write-Output"This endpoint is not a server operating system"}
}
Catch{Write-Error"The operating system type could not be determined`n"+$_.Exception.Message;Exit1}
# Exit if the endpoint does not have at least 4GB of RAM
Try
{
If((Get-CimInstance-ClassNameWin32_PhysicalMemory-ErrorActionStop|Measure-Object-PropertyCapacity-Sum).Sum-lt4GB){Write-Output"This endpoint does not have at least 4GB of RAM";Exit1}
Else{Write-Output"This endpoint has at least 4GB of RAM"}
}
Catch{Write-Error"The amount of RAM could not be determined`n"+$_.Exception.Message;Exit1}
# Exit if the endpoint does not have at least 64GB of storage on the system drive
Try
{
$SystemDrive=$Env:SystemDrive.TrimEnd('\')
If((Get-CimInstance-ClassNameWin32_Volume-Filter"DriveLetter = '$SystemDrive'"-ErrorActionStop).FreeSpace-lt64GB){Write-Output"This endpoint does not have at least 64GB of storage on the system drive";Exit1}