early-access version 2853

This commit is contained in:
pineappleEA
2022-07-23 03:01:36 +02:00
parent 1f2b5081b5
commit 1f111bb69c
8955 changed files with 418777 additions and 999 deletions

View File

@@ -0,0 +1,107 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
parameters:
- name: vcpkgToolSha
displayName: 'Custom SHA of vcpkg-tool to use rather than bootstrap'
type: string
default: 'use default'
- name: triplet
type: string
default: 'x86-windows'
- name: jobName
type: string
default: 'x86_windows'
- name: poolName
type: string
jobs:
- job: ${{ parameters.jobName }}
pool:
name: ${{ parameters.poolName }}
workspace:
clean: resources
timeoutInMinutes: 2880 # 2 days
variables:
- name: WORKING_ROOT
value: D:\
- name: VCPKG_DOWNLOADS
value: D:\downloads
- name: DiffFile
value: $(Build.ArtifactStagingDirectory)\format.diff
- name: ExtraChecksTriplet
value: x86-windows
- group: vcpkg-asset-caching-credentials
- name: X_VCPKG_ASSET_SOURCES
value: "x-azurl,$(root-url-ea),$(sas-ea),readwrite"
- group: vcpkg-binary-caching-credentials
- name: X_VCPKG_BINARY_SOURCE_STUB
value: "x-azblob,$(root-bin-url-ea),$(sas-bin-ea)"
steps:
- script: .\bootstrap-vcpkg.bat
displayName: 'Bootstrap vcpkg'
condition: eq('use default', '${{ parameters.vcpkgToolSha }}')
- script: .\scripts\azure-pipelines\windows\bootstrap-from-source.cmd ${{ parameters.vcpkgToolSha }}
displayName: "Build vcpkg with CMake"
condition: ne('use default', '${{ parameters.vcpkgToolSha }}')
- script: '.\vcpkg.exe format-manifest --all'
displayName: 'Format Manifests'
condition: eq('${{ parameters.triplet }}', '${{ variables.ExtraChecksTriplet }}')
- task: Powershell@2
displayName: 'Create Diff'
condition: eq('${{ parameters.triplet }}', '${{ variables.ExtraChecksTriplet }}')
inputs:
filePath: scripts/azure-pipelines/Create-PRDiff.ps1
arguments: "-DiffFile '$(DiffFile)'"
pwsh: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Format and Documentation Diff'
condition: and(eq('${{ parameters.triplet }}', '${{ variables.ExtraChecksTriplet }}'), failed())
inputs:
PathtoPublish: '$(DiffFile)'
ArtifactName: 'format.diff'
- task: PowerShell@2
displayName: '*** Test Modified Ports'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/test-modified-ports.ps1'
arguments: '-Triplet ${{ parameters.triplet }} -BuildReason $(Build.Reason) -BinarySourceStub "$(X_VCPKG_BINARY_SOURCE_STUB)" -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)'
pwsh: true
- task: PowerShell@2
displayName: 'Validate version files'
condition: eq('${{ parameters.triplet }}', '${{ variables.ExtraChecksTriplet }}')
inputs:
filePath: 'scripts/azure-pipelines/windows/validate-version-files.ps1'
pwsh: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: failure logs for ${{ parameters.triplet }}'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\failure-logs'
ArtifactName: 'failure logs for ${{ parameters.triplet }}'
condition: ne(variables['FAILURE_LOGS_EMPTY'], 'True')
- task: PowerShell@2
displayName: 'Build a file list for all packages'
condition: always()
inputs:
targetType: inline
script: |
./vcpkg.exe fetch python3
& $(.\vcpkg fetch python3) .\scripts\file_script.py D:\installed\vcpkg\info\
pwsh: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: file lists for ${{ parameters.triplet }}'
condition: always()
inputs:
PathtoPublish: scripts/list_files
ArtifactName: 'file lists for ${{ parameters.triplet }}'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: ne(variables['XML_RESULTS_FILE'], '')
inputs:
testRunTitle: ${{ parameters.triplet }}
testResultsFormat: xUnit
testResultsFiles: $(XML_RESULTS_FILE)
platform: ${{ parameters.triplet }}

View File

@@ -0,0 +1,7 @@
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x86 -host_arch=x86
git clone https://github.com/microsoft/vcpkg-tool vcpkg-tool
git -C vcpkg-tool switch -d %1
rmdir /s /q build.x86.release > nul 2> nul
cmake.exe -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DVCPKG_DEVELOPMENT_WARNINGS=OFF -DVCPKG_WARNINGS_AS_ERRORS=OFF -DVCPKG_BUILD_FUZZING=OFF -DVCPKG_BUILD_TLS12_DOWNLOADER=OFF -B build.x86.release -S vcpkg-tool
ninja.exe -C build.x86.release
move build.x86.release\vcpkg.exe vcpkg.exe

View File

@@ -0,0 +1,271 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
<#
.SYNOPSIS
Creates a Windows virtual machine image, set up for vcpkg's CI.
.DESCRIPTION
create-image.ps1 creates an Azure Windows VM image, set up for vcpkg's CI system.
This script assumes you have installed Azure tools into PowerShell by following the instructions
at https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.6.1
or are running from Azure Cloud Shell.
#>
$Location = 'eastasia'
$Prefix = 'Win-'
$Prefix += (Get-Date -Format 'yyyy-MM-dd')
$VMSize = 'Standard_D8a_v4'
$ProtoVMName = 'PROTOTYPE'
$WindowsServerSku = '2022-datacenter'
$ErrorActionPreference = 'Stop'
$CudnnBaseUrl = 'https://vcpkgimageminting.blob.core.windows.net/assets/cudnn-windows-x86_64-8.3.2.44_cuda11.5-archive.zip'
$ProgressActivity = 'Creating Windows Image'
$TotalProgress = 18
$CurrentProgress = 1
Import-Module "$PSScriptRoot/../create-vmss-helpers.psm1" -DisableNameChecking
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Creating resource group' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$ResourceGroupName = Find-ResourceGroupName $Prefix
$AdminPW = New-Password
New-AzResourceGroup -Name $ResourceGroupName -Location $Location
$AdminPWSecure = ConvertTo-SecureString $AdminPW -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ("AdminUser", $AdminPWSecure)
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Creating virtual network' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$VirtualNetwork = Create-LockedDownNetwork -ResourceGroupName $ResourceGroupName -Location $Location
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Creating prototype VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$NicName = $ResourceGroupName + 'NIC'
$Nic = New-AzNetworkInterface `
-Name $NicName `
-ResourceGroupName $ResourceGroupName `
-Location $Location `
-Subnet $VirtualNetwork.Subnets[0]
$VM = New-AzVMConfig -Name $ProtoVMName -VMSize $VMSize -Priority 'Spot' -MaxPrice -1
$VM = Set-AzVMOperatingSystem `
-VM $VM `
-Windows `
-ComputerName $ProtoVMName `
-Credential $Credential `
-ProvisionVMAgent
$VM = Add-AzVMNetworkInterface -VM $VM -Id $Nic.Id
$VM = Set-AzVMSourceImage `
-VM $VM `
-PublisherName 'MicrosoftWindowsServer' `
-Offer 'WindowsServer' `
-Skus $WindowsServerSku `
-Version latest
$VM = Set-AzVMBootDiagnostic -VM $VM -Disable
New-AzVm `
-ResourceGroupName $ResourceGroupName `
-Location $Location `
-VM $VM
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Running provisioning script deploy-tlssettings.ps1 in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$ProvisionImageResult = Invoke-AzVMRunCommandWithRetries `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath "$PSScriptRoot\deploy-tlssettings.ps1"
Write-Host "deploy-tlssettings.ps1 output: $($ProvisionImageResult.value.Message)"
Write-Host 'Waiting 1 minute for VM to reboot...'
Start-Sleep -Seconds 60
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Running provisioning script deploy-psexec.ps1 in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$DeployPsExecResult = Invoke-AzVMRunCommandWithRetries `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath "$PSScriptRoot\deploy-psexec.ps1"
Write-Host "deploy-psexec.ps1 output: $($DeployPsExecResult.value.Message)"
####################################################################################################
function Invoke-ScriptWithPrefix {
param(
[string]$ScriptName,
[switch]$AddAdminPw,
[string]$CudnnUrl
)
Write-Progress `
-Activity $ProgressActivity `
-Status "Running provisioning script $ScriptName in VM" `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$DropToAdminUserPrefix = Get-Content "$PSScriptRoot\drop-to-admin-user-prefix.ps1" -Encoding utf8NoBOM -Raw
$UtilityPrefixContent = Get-Content "$PSScriptRoot\utility-prefix.ps1" -Encoding utf8NoBOM -Raw
$tempScriptFilename = [System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName() + ".txt"
try {
$script = Get-Content "$PSScriptRoot\$ScriptName" -Encoding utf8NoBOM -Raw
if ($AddAdminPw) {
$script = $script.Replace('# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1', $DropToAdminUserPrefix)
}
if (-Not ([string]::IsNullOrWhiteSpace($CudnnUrl))) {
$script = $script.Replace('# REPLACE WITH $CudnnUrl', "`$CudnnUrl = '$CudnnUrl'")
}
$script = $script.Replace('# REPLACE WITH UTILITY-PREFIX.ps1', $UtilityPrefixContent);
Set-Content -Path $tempScriptFilename -Value $script -Encoding utf8NoBOM
$parameter = $null
if ($AddAdminPw) {
$parameter = @{AdminUserPassword = $AdminPW;}
}
$InvokeResult = Invoke-AzVMRunCommandWithRetries `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath $tempScriptFilename `
-Parameter $parameter
Write-Host "$ScriptName output: $($InvokeResult.value.Message)"
} finally {
Remove-Item $tempScriptFilename -Force
}
}
Invoke-ScriptWithPrefix -ScriptName 'deploy-windows-sdks.ps1' -AddAdminPw
####################################################################################################
Invoke-ScriptWithPrefix -ScriptName 'deploy-visual-studio.ps1' -AddAdminPw
####################################################################################################
Invoke-ScriptWithPrefix -ScriptName 'deploy-mpi.ps1' -AddAdminPw
####################################################################################################
$StorageAccountKeys = Get-AzStorageAccountKey `
-ResourceGroupName 'vcpkg-image-minting' `
-Name 'vcpkgimageminting'
$StorageContext = New-AzStorageContext `
-StorageAccountName 'vcpkgimageminting' `
-StorageAccountKey $StorageAccountKeys[0].Value
$StartTime = [DateTime]::Now
$ExpiryTime = $StartTime.AddDays(1)
$SetupSasToken = New-AzStorageAccountSASToken `
-Service Blob `
-Permission "r" `
-Context $StorageContext `
-StartTime $StartTime `
-ExpiryTime $ExpiryTime `
-ResourceType Object `
-Protocol HttpsOnly
Invoke-ScriptWithPrefix -ScriptName 'deploy-cuda.ps1' -AddAdminPw -CudnnUrl ($CudnnBaseUrl + $SetupSasToken)
####################################################################################################
Invoke-ScriptWithPrefix -ScriptName 'deploy-inteloneapi.ps1' -AddAdminPw
####################################################################################################
Invoke-ScriptWithPrefix -ScriptName 'deploy-pwsh.ps1' -AddAdminPw
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Running provisioning script deploy-settings.txt (as a .ps1) in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$ProvisionImageResult = Invoke-AzVMRunCommandWithRetries `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath "$PSScriptRoot\deploy-settings.txt"
Write-Host "deploy-settings.txt output: $($ProvisionImageResult.value.Message)"
Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Running provisioning script sysprep.ps1 in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
$SysprepResult = Invoke-AzVMRunCommandWithRetries `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
-ScriptPath "$PSScriptRoot\sysprep.ps1"
Write-Host "sysprep.ps1 output: $($SysprepResult.value.Message)"
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Waiting for VM to shut down' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
Wait-Shutdown -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Converting VM to Image' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
Stop-AzVM `
-ResourceGroupName $ResourceGroupName `
-Name $ProtoVMName `
-Force
Set-AzVM `
-ResourceGroupName $ResourceGroupName `
-Name $ProtoVMName `
-Generalized
$VM = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
$ImageConfig = New-AzImageConfig -Location $Location -SourceVirtualMachineId $VM.ID
$ImageName = Find-ImageName -ResourceGroupName 'vcpkg-image-minting' -Prefix $Prefix
New-AzImage -Image $ImageConfig -ImageName $ImageName -ResourceGroupName 'vcpkg-image-minting'
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Deleting unused temporary resources' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
Remove-AzResourceGroup $ResourceGroupName -Force
####################################################################################################
Write-Progress -Activity $ProgressActivity -Completed
Write-Host "Generated Image: $ImageName"
Write-Host 'Finished!'

View File

@@ -0,0 +1,94 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
<#
.SYNOPSIS
Creates a Windows virtual machine scale set, set up for vcpkg's CI.
.DESCRIPTION
create-vmss.ps1 creates an Azure Windows VM scale set, set up for vcpkg's CI
system. See https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/overview
for more information.
This script assumes you have installed Azure tools into PowerShell by following the instructions
at https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.6.1
or are running from Azure Cloud Shell.
.PARAMETER ImageName
The name of the image to deploy into the scale set.
#>
[CmdLetBinding()]
Param(
[parameter(Mandatory=$true)]
[string]$ImageName
)
$Location = 'eastasia'
$Prefix = 'PrWin-'
$Prefix += (Get-Date -Format 'yyyy-MM-dd')
$VMSize = 'Standard_D32a_v4'
$LiveVMPrefix = 'BUILD'
$ErrorActionPreference = 'Stop'
Import-Module "$PSScriptRoot/../create-vmss-helpers.psm1" -DisableNameChecking
$ResourceGroupName = Find-ResourceGroupName $Prefix
$AdminPW = New-Password
$Image = Get-AzImage -ResourceGroupName 'vcpkg-image-minting' -ImageName $ImageName
New-AzResourceGroup -Name $ResourceGroupName -Location $Location
$VirtualNetwork = Create-LockedDownNetwork -ResourceGroupName $ResourceGroupName -Location $Location
$VmssIpConfigName = $ResourceGroupName + 'VmssIpConfig'
$VmssIpConfig = New-AzVmssIpConfig -SubnetId $VirtualNetwork.Subnets[0].Id -Primary -Name $VmssIpConfigName
$VmssName = $ResourceGroupName + 'Vmss'
$Vmss = New-AzVmssConfig `
-Location $Location `
-SkuCapacity 0 `
-SkuName $VMSize `
-SkuTier 'Standard' `
-Overprovision $false `
-UpgradePolicyMode Manual `
-EvictionPolicy Delete `
-Priority Spot `
-MaxPrice -1
$NicName = $ResourceGroupName + 'NIC'
New-AzNetworkInterface `
-Name $NicName `
-ResourceGroupName $ResourceGroupName `
-Location $Location `
-Subnet $VirtualNetwork.Subnets[0]
$Vmss = Add-AzVmssNetworkInterfaceConfiguration `
-VirtualMachineScaleSet $Vmss `
-Primary $true `
-IpConfiguration $VmssIpConfig `
-NetworkSecurityGroupId $VirtualNetwork.Subnets[0].NetworkSecurityGroup.Id `
-Name $NicName
$Vmss = Set-AzVmssOsProfile `
-VirtualMachineScaleSet $Vmss `
-ComputerNamePrefix $LiveVMPrefix `
-AdminUsername 'AdminUser' `
-AdminPassword $AdminPW `
-WindowsConfigurationProvisionVMAgent $true `
-WindowsConfigurationEnableAutomaticUpdate $false
$Vmss = Set-AzVmssStorageProfile `
-VirtualMachineScaleSet $Vmss `
-OsDiskCreateOption 'FromImage' `
-OsDiskCaching ReadOnly `
-DiffDiskSetting Local `
-ImageReferenceId $Image.Id
New-AzVmss `
-ResourceGroupName $ResourceGroupName `
-Name $VmssName `
-VirtualMachineScaleSet $Vmss
Write-Host "Location: $Location"
Write-Host "Resource group name: $ResourceGroupName"
Write-Host 'Finished!'

View File

@@ -0,0 +1,62 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
# REPLACE WITH UTILITY-PREFIX.ps1
# REPLACE WITH $CudnnUrl
$CudnnLocalZipPath = "$PSScriptRoot\cudnn-windows-x86_64-8.3.2.44_cuda11.5-archive.zip"
$CudaUrl = 'https://developer.download.nvidia.com/compute/cuda/11.6.0/network_installers/cuda_11.6.0_windows_network.exe'
$CudaFeatures = 'nvcc_11.6 cuobjdump_11.6 nvprune_11.6 cupti_11.6 memcheck_11.6 nvdisasm_11.6 nvprof_11.6 ' + `
'visual_studio_integration_11.6 visual_profiler_11.6 visual_profiler_11.6 cublas_11.6 cublas_dev_11.6 ' + `
'cudart_11.6 cufft_11.6 cufft_dev_11.6 curand_11.6 curand_dev_11.6 cusolver_11.6 cusolver_dev_11.6 ' + `
'cusparse_11.6 cusparse_dev_11.6 npp_11.6 npp_dev_11.6 nvrtc_11.6 nvrtc_dev_11.6 nvml_dev_11.6 ' + `
'occupancy_calculator_11.6 thrust_11.6 '
$destination = "$env:ProgramFiles\NVIDIA GPU Computing Toolkit\CUDA\v11.6"
try {
Write-Host 'Downloading CUDA...'
[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $CudaUrl
Write-Host 'Installing CUDA...'
$proc = Start-Process -FilePath $installerPath -ArgumentList @('-s ' + $CudaFeatures) -Wait -PassThru
$exitCode = $proc.ExitCode
if ($exitCode -eq 0) {
Write-Host 'Installation successful!'
}
else {
Write-Error "Installation failed! Exited with $exitCode."
throw
}
}
catch {
Write-Error "Failed to install CUDA! $($_.Exception.Message)"
throw
}
try {
if ([string]::IsNullOrWhiteSpace($CudnnUrl)) {
if (-Not (Test-Path $CudnnLocalZipPath)) {
throw "CUDNN zip ($CudnnLocalZipPath) was missing, please download from NVidia and place next to this script."
}
$cudnnZipPath = $CudnnLocalZipPath
} else {
Write-Host 'Downloading CUDNN...'
$cudnnZipPath = Get-TempFilePath -Extension 'zip'
curl.exe -L -o $cudnnZipPath -s -S $CudnnUrl
}
Write-Host "Installing CUDNN to $destination..."
tar.exe -xvf "$cudnnZipPath" --strip 1 --directory "$destination"
Write-Host 'Installation successful!'
}
catch {
Write-Error "Failed to install CUDNN! $($_.Exception.Message)"
throw
}

View File

@@ -0,0 +1,60 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH UTILITY-PREFIX.ps1
<#
.SYNOPSIS
Partitions a new physical disk.
.DESCRIPTION
Takes the disk $DiskNumber, turns it on, then partitions it for use with label
$Label and drive letter $Letter.
.PARAMETER DiskNumber
The number of the disk to set up.
.PARAMETER Letter
The drive letter at which to mount the disk.
.PARAMETER Label
The label to give the disk.
#>
Function New-PhysicalDisk {
Param(
[int]$DiskNumber,
[string]$Letter,
[string]$Label
)
if ($Letter.Length -ne 1) {
throw "Bad drive letter $Letter, expected only one letter. (Did you accidentially add a : ?)"
}
try {
Write-Host "Attempting to online physical disk $DiskNumber"
[string]$diskpartScriptPath = Get-TempFilePath -Extension 'txt'
[string]$diskpartScriptContent =
"SELECT DISK $DiskNumber`r`n" +
"ONLINE DISK`r`n"
Write-Host "Writing diskpart script to $diskpartScriptPath with content:"
Write-Host $diskpartScriptContent
Set-Content -Path $diskpartScriptPath -Value $diskpartScriptContent
Write-Host 'Invoking DISKPART...'
& diskpart.exe /s $diskpartScriptPath
Write-Host "Provisioning physical disk $DiskNumber as drive $Letter"
[string]$diskpartScriptContent =
"SELECT DISK $DiskNumber`r`n" +
"ATTRIBUTES DISK CLEAR READONLY`r`n" +
"CREATE PARTITION PRIMARY`r`n" +
"FORMAT FS=NTFS LABEL=`"$Label`" QUICK`r`n" +
"ASSIGN LETTER=$Letter`r`n"
Write-Host "Writing diskpart script to $diskpartScriptPath with content:"
Write-Host $diskpartScriptContent
Set-Content -Path $diskpartScriptPath -Value $diskpartScriptContent
Write-Host 'Invoking DISKPART...'
& diskpart.exe /s $diskpartScriptPath
}
catch {
Write-Error "Failed to provision physical disk $DiskNumber as drive $Letter! $($_.Exception.Message)"
}
}
New-PhysicalDisk -DiskNumber 1 -Letter 'E' -Label 'install disk'

View File

@@ -0,0 +1,74 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
# REPLACE WITH UTILITY-PREFIX.ps1
# Seems like only the HPC kit is really needed?
#$oneAPIBaseUrl = 'https://registrationcenter-download.intel.com/akdlm/irc_nas/17768/w_BaseKit_p_2021.2.0.2871_offline.exe'
$oneAPIHPCUrl = 'https://registrationcenter-download.intel.com/akdlm/irc_nas/18578/w_HPCKit_p_2022.1.3.145_offline.exe'
# Possible oneAPI Base components:
#intel.oneapi.win.vtune 2021.1.1-68 true Intel® VTune(TM) Profiler
#intel.oneapi.win.tbb.devel 2021.1.1-133 true Intel® oneAPI Threading Building Blocks
#intel.oneapi.win.dnnl 2021.1.1-44 true Intel® oneAPI Deep Neural Network Library
#intel.oneapi.win.mkl.devel 2021.1.1-52 true Intel® oneAPI Math Kernel Library
#intel.oneapi.win.vpl 2021.1.1-76 true Intel® oneAPI Video Processing Library
#intel.oneapi.win.dpcpp_debugger 10.0.0-2213 true Intel® Distribution for GDB*
#intel.oneapi.win.ipp.devel 2021.1.1-47 true Intel® Integrated Performance Primitives
#intel.oneapi.win.ippcp 2021.1.1-53 true Intel® Integrated Performance Primitives Cryptography
#intel.oneapi.win.dpcpp-compiler 2021.1.1-191 true Intel® oneAPI DPC++/C++ Compiler
#intel.oneapi.win.dpcpp-library 2021.1.1-191 true Intel® oneAPI DPC++ Library
#intel.oneapi.win.dpcpp_ct.common 2021.1.1-54 true Intel® DPC++ Compatibility Tool
#intel.oneapi.win.dal.devel 2021.1.1-71 true Intel® oneAPI Data Analytics Library
#intel.oneapi.win.python3 2021.1.1-46 true Intel® Distribution for Python*
#intel.oneapi.win.advisor 2021.1.1-53 true Intel® Advisor
#$oneAPIBaseComponents = 'intel.oneapi.win.dpcpp-compiler:intel.oneapi.win.dpcpp-library:intel.oneapi.win.mkl.devel:intel.oneapi.win.ipp.devel:intel.oneapi.win.ippcp:intel.oneapi.win.dal.devel:intel.oneapi.win.dnnl:intel.oneapi.win.vpl:intel.oneapi.win.tbb.devel'
$oneAPIHPCComponents = 'intel.oneapi.win.cpp-compiler:intel.oneapi.win.ifort-compiler'
<#
.SYNOPSIS
Installs Intel oneAPI compilers and toolsets. Examples for CI can be found here: https://github.com/oneapi-src/oneapi-ci
.DESCRIPTION
InstallInteloneAPI installs the Intel oneAPI Compiler & Toolkit with the components specified as a
:-separated list of strings in $Components.
.PARAMETER Url
The URL of the Intel Toolkit installer.
.PARAMETER Components
A :-separated list of components to install.
#>
Function InstallInteloneAPI {
Param(
[String]$Url,
[String]$Components
)
try {
[string]$installerPath = Get-TempFilePath -Extension 'exe'
[string]$extractionPath = [System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName()
Write-Host 'Downloading Intel oneAPI...to: ' $installerPath
curl.exe -L -o $installerPath -s -S $Url
Write-Host 'Extracting Intel oneAPI...to folder: ' $extractionPath
$proc = Start-Process -FilePath $installerPath -ArgumentList @('-s ', '-x ', '-f ' + $extractionPath , '--log extract.log') -Wait -PassThru
Write-Host 'Install Intel oneAPI...from folder: ' $extractionPath
$proc = Start-Process -FilePath $extractionPath/bootstrapper.exe -ArgumentList @('-s ', '--action install', "--components=$Components" , '--eula=accept', '-p=NEED_VS2017_INTEGRATION=0', '-p=NEED_VS2019_INTEGRATION=0', '-p=NEED_VS2022_INTEGRATION=0', '--log-dir=.') -Wait -PassThru
$exitCode = $proc.ExitCode
if ($exitCode -eq 0) {
Write-Host 'Installation successful!'
}
else {
Write-Error "Installation failed! Exited with $exitCode."
throw
}
}
catch {
Write-Error "Failed to install Intel oneAPI! $($_.Exception.Message)"
throw
}
}
InstallInteloneAPI -Url $oneAPIHPCUrl -Components $oneAPIHPCComponents

View File

@@ -0,0 +1,47 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
# REPLACE WITH UTILITY-PREFIX.ps1
$MpiUrl = 'https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe'
<#
.SYNOPSIS
Installs MPI
.DESCRIPTION
Downloads the MPI installer located at $Url, and installs it with the
correct flags.
.PARAMETER Url
The URL of the installer.
#>
Function InstallMpi {
Param(
[String]$Url
)
try {
Write-Host 'Downloading MPI...'
[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $Url
Write-Host 'Installing MPI...'
$proc = Start-Process -FilePath $installerPath -ArgumentList @('-force', '-unattend') -Wait -PassThru
$exitCode = $proc.ExitCode
if ($exitCode -eq 0) {
Write-Host 'Installation successful!'
}
else {
Write-Error "Installation failed! Exited with $exitCode."
throw
}
}
catch {
Write-Error "Failed to install MPI! $($_.Exception.Message)"
throw
}
}
InstallMpi -Url $MpiUrl

View File

@@ -0,0 +1,8 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$PsExecPath = 'C:\PsExec64.exe'
Write-Host "Downloading psexec to: $PsExecPath"
& curl.exe -L -o $PsExecPath -s -S https://live.sysinternals.com/PsExec64.exe

View File

@@ -0,0 +1,9 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
# REPLACE WITH UTILITY-PREFIX.ps1
$PwshUrl = 'https://github.com/PowerShell/PowerShell/releases/download/v7.2.3/PowerShell-7.2.3-win-x64.msi'
InstallMSI -Url $PwshUrl -Name 'PowerShell Core'

View File

@@ -0,0 +1,21 @@
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Write-Host 'Disabling pagefile...'
wmic computersystem set AutomaticManagedPagefile=False
wmic pagefileset delete
$av = Get-Command Add-MPPreference -ErrorAction SilentlyContinue
if ($null -eq $av) {
Write-Host 'AntiVirus not installed, skipping exclusions.'
} else {
Write-Host 'Configuring AntiVirus exclusions...'
Add-MpPreference -ExclusionPath C:\agent
Add-MPPreference -ExclusionPath D:\
Add-MPPreference -ExclusionPath E:\
Add-MPPreference -ExclusionProcess ninja.exe
Add-MPPreference -ExclusionProcess clang-cl.exe
Add-MPPreference -ExclusionProcess cl.exe
Add-MPPreference -ExclusionProcess link.exe
Add-MPPreference -ExclusionProcess python.exe
}

View File

@@ -0,0 +1,738 @@
#***************************************************************************************************************
# This script supports the TLS 1.2 everywhere project
# It does the following:
# * By default it disables TLS 1.O, TLS 1.1, SSLv2, SSLv3 and Enables TLS1.2
# * The CipherSuite order is set to the SDL approved version.
# * The FIPS MinEncryptionLevel is set to 3.
# * RC4 is disabled
# * A log with a transcript of all actions taken is generated
#***************************************************************************************************************
#************************************************ SCRIPT USAGE ************************************************
# .\TLSSettings.ps1
# -SetCipherOrder : Excellence/Min-Bar, default(Excellence), use B to set Min-Bar. (Min-Bar ordering prefers ciphers with smaller key sizes to improve performance over security)
# -RebootIfRequired : $true/$false, default($true), use $false to disable auto-reboot (Settings won't take effect until a reboot is completed)
# -EnableOlderTlsVersions : $true/$false, default($false), use $true to explicitly Enable TLS1.0, TLS1.1
#***************************************************************************************************************
#***************************TEAM CAN DETERMINE WHAT CIPHER SUITE ORDER IS CHOSEN ******************************
# Option B provides the min-bar configuration (small trade-off: performance over security)
# Syntax: .\TLSSettings.ps1 -SetCipherOrder B
# if no option is supplied, you will get the opportunity for excellence cipher order (small trade-off: security over performance)
# Syntax: .\TLSSettings.ps1
#***************************************************************************************************************
param (
[string]$SetCipherOrder = " ",
[bool]$RebootIfRequired = $true,
[bool]$EnableOlderTlsVersions = $false
)
#******************* FUNCTION THAT ACTUALLY UPDATES KEYS; WILL RETURN REBOOT FLAG IF CHANGES ***********************
Function Set-CryptoSetting {
param (
$regKeyName,
$value,
$valuedata,
$valuetype
)
$restart = $false
# Check for existence of registry key, and create if it does not exist
If (!(Test-Path -Path $regKeyName)) {
New-Item $regKeyName | Out-Null
}
# Get data of registry value, or null if it does not exist
$val = (Get-ItemProperty -Path $regKeyName -Name $value -ErrorAction SilentlyContinue).$value
If ($val -eq $null) {
# Value does not exist - create and set to desired value
New-ItemProperty -Path $regKeyName -Name $value -Value $valuedata -PropertyType $valuetype | Out-Null
$restart = $true
}
Else {
# Value does exist - if not equal to desired value, change it
If ($val -ne $valuedata) {
Set-ItemProperty -Path $regKeyName -Name $value -Value $valuedata
$restart = $true
}
}
$restart
}
#***************************************************************************************************************
#******************* FUNCTION THAT DISABLES RC4 ***********************
Function DisableRC4 {
$restart = $false
$subkeys = Get-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL"
$ciphers = $subkeys.OpenSubKey("Ciphers", $true)
Write-Log -Message "----- Checking the status of RC4 -----" -Logfile $logLocation -Severity Information
$RC4 = $false
if ($ciphers.SubKeyCount -eq 0) {
$k1 = $ciphers.CreateSubKey("RC4 128/128")
$k1.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
$restart = $true
$k2 = $ciphers.CreateSubKey("RC4 64/128")
$k2.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
$k3 = $ciphers.CreateSubKey("RC4 56/128")
$k3.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
$k4 = $ciphers.CreateSubKey("RC4 40/128")
$k4.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
Write-Log -Message "RC4 was disabled " -Logfile $logLocation -Severity Information
$RC4 = $true
}
If ($RC4 -ne $true) {
Write-Log -Message "There was no change for RC4 " -Logfile $logLocation -Severity Information
}
$restart
}
#***************************************************************************************************************
#******************* FUNCTION CHECKS FOR PROBLEMATIC FIPS SETTING AND FIXES IT ***********************
Function Test-RegistryValueForFipsSettings {
$restart = $false
$fipsPath = @(
"HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp",
"HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services",
"HKLM:\System\CurrentControlSet\Control\Terminal Server\DefaultUserConfiguration"
)
$fipsValue = "MinEncryptionLevel"
foreach ($path in $fipsPath) {
Write-Log -Message "Checking to see if $($path)\$fipsValue exists" -Logfile $logLocation -Severity Information
$ErrorActionPreference = "stop"
Try {
$result = Get-ItemProperty -Path $path | Select-Object -ExpandProperty $fipsValue
if ($result -eq 4) {
set-itemproperty -Path $path -Name $fipsValue -value 3
Write-Log -Message "Regkey $($path)\$fipsValue was changed from value $result to a value of 3" -Logfile $logLocation -Severity Information
$restart = $true
}
else {
Write-Log -Message "Regkey $($path)\$fipsValue left at value $result" -Logfile $logLocation -Severity Information
}
}
Catch [System.Management.Automation.ItemNotFoundException] {
Write-Log -Message "Reg path $path was not found" -Logfile $logLocation -Severity Information
}
Catch [System.Management.Automation.PSArgumentException] {
Write-Log -Message "Regkey $($path)\$fipsValue was not found" -Logfile $logLocation -Severity Information
}
Catch {
Write-Log -Message "Error of type $($Error[0].Exception.GetType().FullName) trying to get $($path)\$fipsValue" -Logfile $logLocation -Severity Information
}
Finally {$ErrorActionPreference = "Continue"
}
}
$restart
}
#***************************************************************************************************************
#********************************** FUNCTION THAT CREATE LOG DIRECTORY IF IT DOES NOT EXIST *******************************
function CreateLogDirectory {
$TARGETDIR = "$env:HOMEDRIVE\Logs"
if ( -Not (Test-Path -Path $TARGETDIR ) ) {
New-Item -ItemType directory -Path $TARGETDIR | Out-Null
}
$TARGETDIR = $TARGETDIR + "\" + "TLSSettingsLogFile.csv"
return $TARGETDIR
}
#***************************************************************************************************************
#********************************** FUNCTION THAT LOGS WHAT THE SCRIPT IS DOING *******************************
function Write-Log {
[CmdletBinding()]
param(
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$Message,
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$LogFile,
[Parameter()]
[ValidateNotNullOrEmpty()]
[ValidateSet('Information', 'Warning', 'Error')]
[string]$Severity = 'Information'
)
[pscustomobject]@{
Time = (Get-Date -f g)
Message = $Message
Severity = $Severity
} | ConvertTo-Csv -NoTypeInformation | Select-Object -Skip 1 | Out-File -Append -FilePath $LogFile
}
#********************************TLS CipherSuite Settings *******************************************
# CipherSuites for windows OS < 10
function Get-BaseCipherSuitesOlderWindows()
{
param
(
[Parameter(Mandatory=$true, Position=0)][bool] $isExcellenceOrder
)
$cipherorder = @()
if ($isExcellenceOrder -eq $true)
{
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_P384"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_P256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384_P384"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256_P256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256"
}
else
{
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_P256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_P384"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256_P256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384_P384"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384"
}
# Add additional ciphers when EnableOlderTlsVersions flag is set to true
if ($EnableOlderTlsVersions)
{
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA_P256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_P256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256"
$cipherorder += "TLS_RSA_WITH_AES_256_GCM_SHA384"
$cipherorder += "TLS_RSA_WITH_AES_128_GCM_SHA256"
$cipherorder += "TLS_RSA_WITH_AES_256_CBC_SHA256"
$cipherorder += "TLS_RSA_WITH_AES_128_CBC_SHA256"
$cipherorder += "TLS_RSA_WITH_AES_256_CBC_SHA"
$cipherorder += "TLS_RSA_WITH_AES_128_CBC_SHA"
}
return $cipherorder
}
# Ciphersuites needed for backwards compatibility with Firefox, Chrome
# Server 2012 R2 doesn't support TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
# Both firefox and chrome negotiate ECDHE_RSA_AES_256_CBC_SHA1, Edge negotiates ECDHE_RSA_AES_256_CBC_SHA384
function Get-BrowserCompatCipherSuitesOlderWindows()
{
param
(
[Parameter(Mandatory=$true, Position=0)][bool] $isExcellenceOrder
)
$cipherorder = @()
if ($isExcellenceOrder -eq $true)
{
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384" # (uses SHA-1)
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256" # (uses SHA-1)
}
else
{
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256" # (uses SHA-1)
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384" # (uses SHA-1)
}
return $cipherorder
}
# Ciphersuites for OS versions windows 10 and above
function Get-BaseCipherSuitesWin10Above()
{
param
(
[Parameter(Mandatory=$true, Position=0)][bool] $isExcellenceOrder
)
$cipherorder = @()
if ($isExcellenceOrder -eq $true)
{
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
}
else
{
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"
}
# Add additional ciphers when EnableOlderTlsVersions flag is set to true
if ($EnableOlderTlsVersions)
{
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA_P256"
$cipherorder += "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_P256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256"
$cipherorder += "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256"
$cipherorder += "TLS_RSA_WITH_AES_256_GCM_SHA384"
$cipherorder += "TLS_RSA_WITH_AES_128_GCM_SHA256"
$cipherorder += "TLS_RSA_WITH_AES_256_CBC_SHA256"
$cipherorder += "TLS_RSA_WITH_AES_128_CBC_SHA256"
$cipherorder += "TLS_RSA_WITH_AES_256_CBC_SHA"
$cipherorder += "TLS_RSA_WITH_AES_128_CBC_SHA"
}
return $cipherorder
}
#******************************* TLS Version Settings ****************************************************
function Get-RegKeyPathForTls12()
{
$regKeyPath = @(
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server"
)
return $regKeyPath
}
function Get-RegKeyPathForTls11()
{
$regKeyPath = @(
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server"
)
return $regKeyPath
}
function Get-RegKeypathForTls10()
{
$regKeyPath = @(
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server"
)
return $regKeyPath
}
function Get-RegKeyPathForSsl30()
{
$regKeyPath = @(
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server"
)
return $regKeyPath
}
function Get-RegKeyPathForSsl20()
{
$regKeyPath = @(
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client",
"HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server"
)
return $regKeyPath
}
#Initialize reboot value to false
$reboot = $false
#*****************************Create the logfile if not does not exist***************************************
$logLocation = CreateLogDirectory
#Start writing to the logs
Write-Log -Message "========== Start of logging for a script execution ==========" -Logfile $logLocation -Severity Information
$registryPathGoodGuys = @()
$registryPathBadGuys = @()
# we enable TLS 1.2 and disable SSL 2.0, 3.0 in any case
$registryPathGoodGuys += Get-RegKeyPathForTls12
$registryPathBadGuys += Get-RegKeyPathForSsl20
$registryPathBadGuys += Get-RegKeyPathForSsl30
# add TLS 1.0/1.1 to good/bad depending on user's preference
# default is adding TLS 1.0/1.1 to bad
if ($EnableOlderTlsVersions)
{
$registryPathGoodGuys += Get-RegKeypathForTls10
$registryPathGoodGuys += Get-RegKeyPathForTls11
Write-Log -Message "Enabling TLS1.2, TLS1.1, TLS1.0. Disabling SSL3.0, SSL2.0" -Logfile $logLocation -Severity Information
}
else
{
$registryPathBadGuys += Get-RegKeypathForTls10
$registryPathBadGuys += Get-RegKeyPathForTls11
Write-Log -Message "Enabling TLS1.2. Disabling TLS1.1, TLS1.0, SSL3.0, SSL2.0" -Logfile $logLocation -Severity Information
}
Write-Log -Message "Check which registry keys exist already and which registry keys need to be created." -Logfile $logLocation -Severity Information
#******************* CREATE THE REGISTRY KEYS IF THEY DON'T EXIST********************************
# Check for existence of GoodGuy registry keys, and create if they do not exist
For ($i = 0; $i -lt $registryPathGoodGuys.Length; $i = $i + 1) {
Write-Log -Message "Checking for existing of key: $($registryPathGoodGuys[$i]) " -Logfile $logLocation -Severity Information
If (!(Test-Path -Path $registryPathGoodGuys[$i])) {
New-Item $registryPathGoodGuys[$i] | Out-Null
Write-Log -Message "Creating key: $($registryPathGoodGuys[$i]) " -Logfile $logLocation -Severity Information
}
}
# Check for existence of BadGuy registry keys, and create if they do not exist
For ($i = 0; $i -lt $registryPathBadGuys.Length; $i = $i + 1) {
Write-Log -Message "Checking for existing of key: $($registryPathBadGuys[$i]) " -Logfile $logLocation -Severity Information
If (!(Test-Path -Path $registryPathBadGuys[$i])) {
Write-Log -Message "Creating key: $($registryPathBadGuys[$i]) " -Logfile $logLocation -Severity Information
New-Item $registryPathBadGuys[$i] | Out-Null
}
}
#******************* EXPLICITLY DISABLE SSLV2, SSLV3, TLS10 AND TLS11 ********************************
For ($i = 0; $i -lt $registryPathBadGuys.Length; $i = $i + 1) {
if ($registryPathBadGuys[$i].Contains("Client") -Or $registryPathBadGuys[$i].Contains("Server")) {
Write-Log -Message "Disabling this key: $($registryPathBadGuys[$i]) " -Logfile $logLocation -Severity Information
$result = Set-CryptoSetting $registryPathBadGuys[$i].ToString() Enabled 0 DWord
$result = Set-CryptoSetting $registryPathBadGuys[$i].ToString() DisabledByDefault 1 DWord
$reboot = $reboot -or $result
}
}
#********************************* EXPLICITLY Enable TLS12 ****************************************
For ($i = 0; $i -lt $registryPathGoodGuys.Length; $i = $i + 1) {
if ($registryPathGoodGuys[$i].Contains("Client") -Or $registryPathGoodGuys[$i].Contains("Server")) {
Write-Log -Message "Enabling this key: $($registryPathGoodGuys[$i]) " -Logfile $logLocation -Severity Information
$result = Set-CryptoSetting $registryPathGoodGuys[$i].ToString() Enabled 1 DWord
$result = Set-CryptoSetting $registryPathGoodGuys[$i].ToString() DisabledByDefault 0 DWord
$reboot = $reboot -or $result
}
}
#************************************** Disable RC4 ************************************************
$result = DisableRC4
$reboot = $reboot -or $result
#************************************** Set Cipher Suite Order **************************************
Write-Log -Message "----- starting ciphersuite order calculation -----" -Logfile $logLocation -Severity Information
$configureExcellenceOrder = $true
if ($SetCipherOrder.ToUpper() -eq "B")
{
$configureExcellenceOrder = $false
Write-Host "The min bar cipher suite order was chosen."
Write-Log -Message "The min bar cipher suite order was chosen." -Logfile $logLocation -Severity Information
}
else
{
Write-Host "The opportunity for excellence cipher suite order was chosen."
Write-Log -Message "The opportunity for excellence cipher suite order was chosen." -Logfile $logLocation -Severity Information
}
$cipherlist = @()
if ([Environment]::OSVersion.Version.Major -lt 10)
{
$cipherlist += Get-BaseCipherSuitesOlderWindows -isExcellenceOrder $configureExcellenceOrder
$cipherlist += Get-BrowserCompatCipherSuitesOlderWindows -isExcellenceOrder $configureExcellenceOrder
}
else
{
$cipherlist += Get-BaseCipherSuitesWin10Above -isExcellenceOrder $configureExcellenceOrder
}
$cipherorder = [System.String]::Join(",", $cipherlist)
Write-Host "Appropriate ciphersuite order : $cipherorder"
Write-Log -Message "Appropriate ciphersuite order : $cipherorder" -Logfile $logLocation -Severity Information
$CipherSuiteRegKey = "HKLM:\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00010002"
if (!(Test-Path -Path $CipherSuiteRegKey))
{
New-Item $CipherSuiteRegKey | Out-Null
$reboot = $True
Write-Log -Message "Creating key: $($CipherSuiteRegKey) " -Logfile $logLocation -Severity Information
}
$val = (Get-Item -Path $CipherSuiteRegKey -ErrorAction SilentlyContinue).GetValue("Functions", $null)
Write-Log -Message "Previous cipher suite value: $val " -Logfile $logLocation -Severity Information
Write-Log -Message "New cipher suite value : $cipherorder " -Logfile $logLocation -Severity Information
if ($val -ne $cipherorder)
{
Write-Log -Message "Cipher suite order needs to be updated. " -Logfile $logLocation -Severity Information
Write-Host "The original cipher suite order needs to be updated", `n, $val
Set-ItemProperty -Path $CipherSuiteRegKey -Name Functions -Value $cipherorder
Write-Log -Message "Cipher suite value was updated. " -Logfile $logLocation -Severity Information
$reboot = $True
}
else
{
Write-Log -Message "Cipher suite order does not need to be updated. " -Logfile $logLocation -Severity Information
Write-Log -Message "Cipher suite value was not updated as there was no change. " -Logfile $logLocation -Severity Information
}
#****************************** CHECK THE FIPS SETTING WHICH IMPACTS RDP'S ALLOWED CIPHERS **************************
#Check for FipsSettings
Write-Log -Message "Checking to see if reg keys exist and if MinEncryptionLevel is set to 4" -Logfile $logLocation -Severity Information
$result = Test-RegistryValueForFipsSettings
$reboot = $reboot -or $result
#************************************** REBOOT **************************************
if ($RebootIfRequired)
{
Write-Log -Message "You set the RebootIfRequired flag to true. If changes are made, the system will reboot " -Logfile $logLocation -Severity Information
# If any settings were changed, reboot
If ($reboot)
{
Write-Log -Message "Rebooting now... " -Logfile $logLocation -Severity Information
Write-Log -Message "Using this command: shutdown.exe /r /t 5 /c ""Crypto settings changed"" /f /d p:2:4 " -Logfile $logLocation -Severity Information
Write-Host "Rebooting now..."
shutdown.exe /r /t 5 /c "Crypto settings changed" /f /d p:2:4
}
Else
{
Write-Host "Nothing get updated."
Write-Log -Message "Nothing get updated. " -Logfile $logLocation -Severity Information
}
}
else
{
Write-Log -Message "You set the RebootIfRequired flag to false. If changes are made, the system will NOT reboot " -Logfile $logLocation -Severity Information
Write-Log -Message "No changes will take effect until a reboot has been completed. " -Logfile $logLocation -Severity Information
Write-Log -Message "Script does not include a reboot by design" -Logfile $logLocation -Severity Information
}
Write-Log -Message "========== End of logging for a script execution ==========" -Logfile $logLocation -Severity Information
# SIG # Begin signature block
# MIIjhgYJKoZIhvcNAQcCoIIjdzCCI3MCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCAHtlEJwNffjnOP
# Sr2t1yq5EfE0ll4GozyZt3UXO9BXKKCCDYEwggX/MIID56ADAgECAhMzAAABh3IX
# chVZQMcJAAAAAAGHMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjAwMzA0MTgzOT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g3zNulscnGBDlD6Q/U6yLQ5dN3gF9UrprgACiQ1gs/DexU7oC
# hjNZxBnH5RTA/7q9TFf2a1rBydHWVnqXuuQQJ0HuskdpXahxR4y1jboDdGwr7F08
# v/gmPeeUik28Je72QZp5m/R0O61/kMQaDpLO9iPH0Z9iMGfqJonFPDeY4VX8Da2n
# cPY7mrv6YAI+ydZ+mUdBp2yjas7+/N8MntcNtAO0HpWFXQTAmb77RrSssfeZphRA
# mBD+gLx5C3q4uSmuOqaQxUaF0y8FeuetHp0bw2sfce6GlMXJwzTpC6HvXnaVtMy0
# pgzd/KPHW7EgSvmRVKmvwiQGiZBoRG/Gcg8=
# SIG # End signature block

View File

@@ -0,0 +1,89 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
# REPLACE WITH UTILITY-PREFIX.ps1
$VisualStudioBootstrapperUrl = 'https://aka.ms/vs/17/release/vs_enterprise.exe'
$Workloads = @(
'Microsoft.VisualStudio.Workload.NativeDesktop',
'Microsoft.VisualStudio.Workload.Universal',
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.VC.Tools.ARM',
'Microsoft.VisualStudio.Component.VC.Tools.ARM64',
'Microsoft.VisualStudio.Component.VC.ATL',
'Microsoft.VisualStudio.Component.VC.ATLMFC',
'Microsoft.VisualStudio.Component.VC.ATL.ARM',
'Microsoft.VisualStudio.Component.VC.ATL.ARM64',
'Microsoft.VisualStudio.Component.VC.MFC.ARM',
'Microsoft.VisualStudio.Component.VC.MFC.ARM64',
'Microsoft.VisualStudio.Component.Windows10SDK',
'Microsoft.Net.Component.4.8.SDK',
'Microsoft.Net.Component.4.7.2.TargetingPack',
'Microsoft.Component.NetFX.Native',
'Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset',
'Microsoft.VisualStudio.Component.VC.Llvm.Clang',
'Microsoft.VisualStudio.ComponentGroup.UWP.VC.BuildTools',
'Microsoft.VisualStudio.Component.VC.CMake.Project'
)
<#
.SYNOPSIS
Install Visual Studio.
.DESCRIPTION
InstallVisualStudio takes the $Workloads array, and installs it with the
installer that's pointed at by $BootstrapperUrl.
.PARAMETER Workloads
The set of VS workloads to install.
.PARAMETER BootstrapperUrl
The URL of the Visual Studio installer, i.e. one of vs_*.exe.
.PARAMETER InstallPath
The path to install Visual Studio at.
.PARAMETER Nickname
The nickname to give the installation.
#>
Function InstallVisualStudio {
Param(
[String[]]$Workloads,
[String]$BootstrapperUrl,
[String]$InstallPath = $null,
[String]$Nickname = $null
)
try {
Write-Host 'Downloading Visual Studio...'
[string]$bootstrapperExe = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $bootstrapperExe -s -S $BootstrapperUrl
Write-Host 'Installing Visual Studio...'
$vsArgs = @('/c', $bootstrapperExe, '--quiet', '--norestart', '--wait', '--nocache')
foreach ($workload in $Workloads) {
$vsArgs += '--add'
$vsArgs += $workload
}
if (-not ([String]::IsNullOrWhiteSpace($InstallPath))) {
$vsArgs += '--installpath'
$vsArgs += $InstallPath
}
if (-not ([String]::IsNullOrWhiteSpace($Nickname))) {
$vsArgs += '--nickname'
$vsArgs += $Nickname
}
$proc = Start-Process -FilePath cmd.exe -ArgumentList $vsArgs -Wait -PassThru
PrintMsiExitCodeMessage $proc.ExitCode
}
catch {
Write-Error "Failed to install Visual Studio! $($_.Exception.Message)"
throw
}
}
InstallVisualStudio -Workloads $Workloads -BootstrapperUrl $VisualStudioBootstrapperUrl -Nickname 'Stable'

View File

@@ -0,0 +1,49 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1
# REPLACE WITH UTILITY-PREFIX.ps1
<#
.SYNOPSIS
Installs Windows PSDK/WDK
.DESCRIPTION
Downloads the Windows PSDK/DDK installer located at $Url, and installs it with the
correct flags.
.PARAMETER Url
The URL of the installer.
#>
Function InstallWindowsDK {
Param(
[String]$Url
)
try {
Write-Host "Downloading Windows PSDK or DDK $Url..."
[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $Url
Write-Host 'Installing...'
$proc = Start-Process -FilePath $installerPath -ArgumentList @('/features', '+', '/q') -Wait -PassThru
$exitCode = $proc.ExitCode
if ($exitCode -eq 0) {
Write-Host 'Installation successful!'
}
else {
Write-Error "Installation failed! Exited with $exitCode."
throw
}
}
catch {
Write-Error "Failed to install Windows PSDK or DDK! $($_.Exception.Message)"
throw
}
}
# Windows 10 SDK, version 2004 (10.0.19041.0)
InstallWindowsDK 'https://go.microsoft.com/fwlink/?linkid=2120843'
# Windows 10 WDK, version 2004
InstallWindowsDK 'https://go.microsoft.com/fwlink/?linkid=2128854'

View File

@@ -0,0 +1,35 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
<#
.SYNOPSIS
Prints total and free disk space for each disk on the system
#>
Function Format-Size {
[CmdletBinding()]
Param([long]$Size)
if ($Size -lt 1024) {
$Size = [int]$Size
return "$Size B"
}
$Size = $Size / 1024
if ($Size -lt 1024) {
$Size = [int]$Size
return "$Size KiB"
}
$Size = $Size / 1024
if ($Size -lt 1024) {
$Size = [int]$Size
return "$Size MiB"
}
$Size = [int]($Size / 1024)
return "$Size GiB"
}
Get-CimInstance -ClassName Win32_LogicalDisk | Format-Table -Property @{Label="Disk"; Expression={ $_.DeviceID }},@{Label="Label"; Expression={ $_.VolumeName }},@{Label="Size"; Expression={ Format-Size($_.Size) }},@{Label="Free Space"; Expression={ Format-Size($_.FreeSpace) }}

View File

@@ -0,0 +1,27 @@
param(
[string]$AdminUserPassword = $null
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
if (-Not [string]::IsNullOrEmpty($AdminUserPassword)) {
$PsExecPath = 'C:\PsExec64.exe'
$PsExecArgs = @(
'-u',
'AdminUser',
'-p',
$AdminUserPassword,
'-accepteula',
'-i',
'-h',
'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe',
'-ExecutionPolicy',
'Unrestricted',
'-File',
$PSCommandPath
)
Write-Host "Executing: $PsExecPath $PsExecArgs"
$proc = Start-Process -FilePath $PsExecPath -ArgumentList $PsExecArgs -Wait -PassThru
exit $proc.ExitCode
}

View File

@@ -0,0 +1,18 @@
# This script runs all the scripts we run on Azure machines to deploy prerequisites,
# and assumes it is being run as an admin user.
. "$PSScriptRoot\utility-prefix.ps1"
. "$PSScriptRoot\deploy-tlssettings.ps1" -RebootIfRequired 0
. "$PSScriptRoot\deploy-windows-sdks.ps1"
. "$PSScriptRoot\deploy-visual-studio.ps1"
. "$PSScriptRoot\deploy-mpi.ps1"
. "$PSScriptRoot\deploy-cuda.ps1"
. "$PSScriptRoot\deploy-inteloneapi.ps1"
. "$PSScriptRoot\deploy-pwsh.ps1"
try {
Copy-Item "$PSScriptRoot\deploy-settings.txt" "$PSScriptRoot\deploy-settings.ps1"
. "$PSScriptRoot\deploy-settings.ps1"
} finally {
Remove-Item "$PSScriptRoot\deploy-settings.ps1"
}

View File

@@ -0,0 +1,17 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
<#
.SYNOPSIS
Prepares the virtual machine for imaging.
.DESCRIPTION
Runs the `sysprep` utility to prepare the system for imaging.
See https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/sysprep--system-preparation--overview
for more information.
#>
$ErrorActionPreference = 'Stop'
Write-Host 'Running sysprep'
& C:\Windows\system32\sysprep\sysprep.exe /oobe /generalize /mode:vm /shutdown

View File

@@ -0,0 +1,125 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
<#
.SYNOPSIS
Gets a random file path in the temp directory.
.DESCRIPTION
Get-TempFilePath takes an extension, and returns a path with a random
filename component in the temporary directory with that extension.
.PARAMETER Extension
The extension to use for the path.
#>
Function Get-TempFilePath {
Param(
[String]$Extension
)
if ([String]::IsNullOrWhiteSpace($Extension)) {
throw 'Missing Extension'
}
$tempPath = [System.IO.Path]::GetTempPath()
$tempName = [System.IO.Path]::GetRandomFileName() + '.' + $Extension
return Join-Path $tempPath $tempName
}
<#
.SYNOPSIS
Writes a message to the screen depending on ExitCode.
.DESCRIPTION
Since msiexec can return either 0 or 3010 successfully, in both cases
we write that installation succeeded, and which exit code it exited with.
If msiexec returns anything else, we write an error.
.PARAMETER ExitCode
The exit code that msiexec returned.
#>
Function PrintMsiExitCodeMessage {
Param(
$ExitCode
)
# 3010 is probably ERROR_SUCCESS_REBOOT_REQUIRED
if ($ExitCode -eq 0 -or $ExitCode -eq 3010) {
Write-Host "Installation successful! Exited with $ExitCode."
}
else {
Write-Error "Installation failed! Exited with $ExitCode."
throw
}
}
<#
.SYNOPSIS
Install a .msi file.
.DESCRIPTION
InstallMSI takes a url where an .msi lives, and installs that .msi to the system.
.PARAMETER Name
The name of the thing to install.
.PARAMETER Url
The URL at which the .msi lives.
#>
Function InstallMSI {
Param(
[String]$Name,
[String]$Url
)
try {
Write-Host "Downloading $Name..."
[string]$msiPath = Get-TempFilePath -Extension 'msi'
curl.exe -L -o $msiPath -s -S $Url
Write-Host "Installing $Name..."
$args = @('/i', $msiPath, '/norestart', '/quiet', '/qn')
$proc = Start-Process -FilePath 'msiexec.exe' -ArgumentList $args -Wait -PassThru
PrintMsiExitCodeMessage $proc.ExitCode
}
catch {
Write-Error "Failed to install $Name! $($_.Exception.Message)"
throw
}
}
<#
.SYNOPSIS
Unpacks a zip file to $Dir.
.DESCRIPTION
InstallZip takes a URL of a zip file, and unpacks the zip file to the directory
$Dir.
.PARAMETER Name
The name of the tool being installed.
.PARAMETER Url
The URL of the zip file to unpack.
.PARAMETER Dir
The directory to unpack the zip file to.
#>
Function InstallZip {
Param(
[String]$Name,
[String]$Url,
[String]$Dir
)
try {
Write-Host "Downloading $Name..."
[string]$zipPath = Get-TempFilePath -Extension 'zip'
curl.exe -L -o $zipPath -s -S $Url
Write-Host "Installing $Name..."
Expand-Archive -Path $zipPath -DestinationPath $Dir -Force
}
catch {
Write-Error "Failed to install $Name! $($_.Exception.Message)"
throw
}
}

View File

@@ -0,0 +1,29 @@
./vcpkg.exe --feature-flags=versions x-ci-verify-versions --verbose |
ForEach-Object -Begin {
$long_error = ''
} -Process {
if ($long_error -ne '' -and $_ -match '^$|^ ') {
# Extend multi-line message
$long_error = -join($long_error, "%0D%0A", $_ -replace '^ ','' `
-replace '(git add) [^ ]*\\ports\\([^ ]*)', '$1 ports/$2' )
} else {
if ($long_error -ne '') {
# Flush multi-line message
$long_error
$long_error = ''
}
if ($_ -match '^Error: ') {
# Start multi-line message
$long_error = $_ -replace '^Error: ', '##vso[task.logissue type=error]' `
-replace '(^##vso[^\]]*)](.*) [^ ]*\\versions\\(.-)\\(.*.json)(.*)', '$1;sourcepath=versions/$3/$4;linenumber=2]$2 version/$3/$4$5'
} else {
# Normal line
$_
}
}
} -End {
if ($long_error -ne '') {
# Flush multi-line message
$long_error
}
}