|
|
|
@@ -1,12 +1,12 @@
|
|
|
|
|
[CmdletBinding(SupportsShouldProcess)]
|
|
|
|
|
param(
|
|
|
|
|
[string]$Version = '0.6.14',
|
|
|
|
|
[string]$Version = '0.6.16',
|
|
|
|
|
|
|
|
|
|
[ValidatePattern('^https://')]
|
|
|
|
|
[string]$ClientPackageUri = 'https://gitea.lci.ulsa.mx/alexrg/SGU-CredentialProvider/releases/download/v0.6.14/sgu-windows-client-bootstrap-0.6.14.zip',
|
|
|
|
|
[string]$ClientPackageUri = 'https://gitea.lci.ulsa.mx/alexrg/SGU-CredentialProvider/releases/download/v0.6.16/sgu-windows-client-bootstrap-0.6.16.zip',
|
|
|
|
|
|
|
|
|
|
[ValidatePattern('^[0-9A-Fa-f]{64}$')]
|
|
|
|
|
[string]$ClientPackageSha256 = 'A409BC60E90EB13029945FCBBAAC3F17547F98ACE9D58032673F2F9350D17669',
|
|
|
|
|
[string]$ClientPackageSha256 = 'AFC40A87E83A6B27319792F575C384EBB175F42DCF670B7AB620A64C75ED499B',
|
|
|
|
|
|
|
|
|
|
[string]$GpoName = 'SGU - Credential Provider update',
|
|
|
|
|
|
|
|
|
@@ -60,7 +60,8 @@ if ($PSCmdlet.ShouldProcess($GpoName, 'Make the computer startup script synchron
|
|
|
|
|
$scriptName = "Update-SguCredentialProvider-$Version.ps1"
|
|
|
|
|
$gpoScriptsPath = Join-Path $env:WINDIR "SYSVOL\domain\Policies\{$($gpo.Id)}\Machine\Scripts"
|
|
|
|
|
$startupPath = Join-Path $gpoScriptsPath 'Startup'
|
|
|
|
|
$powershellScriptsIniPath = Join-Path $gpoScriptsPath 'psscripts.ini'
|
|
|
|
|
$scriptsIniPath = Join-Path $gpoScriptsPath 'scripts.ini'
|
|
|
|
|
$legacyPowerShellScriptsIniPath = Join-Path $gpoScriptsPath 'psscripts.ini'
|
|
|
|
|
$scriptPath = Join-Path $startupPath $scriptName
|
|
|
|
|
|
|
|
|
|
$startupScript = @"
|
|
|
|
@@ -74,6 +75,13 @@ if (-not `$computerSystem.PartOfDomain -or `$computerSystem.DomainRole -ge 4) {
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Windows remembers the provider used at the last interactive logon. Select
|
|
|
|
|
# the institutional tile at startup while leaving the native password tile
|
|
|
|
|
# registered for manual recovery.
|
|
|
|
|
`$logonUiPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI'
|
|
|
|
|
Set-ItemProperty -Path `$logonUiPath -Name LastLoggedOnProvider `
|
|
|
|
|
-Value '{D789CFD8-5AD4-489F-9B83-7EB5D9D09335}'
|
|
|
|
|
|
|
|
|
|
`$updateRoot = Join-Path `$env:ProgramData "SGU\CredentialProviderUpdates\`$version"
|
|
|
|
|
`$markerPath = Join-Path `$updateRoot 'complete.marker'
|
|
|
|
|
if (Test-Path -LiteralPath `$markerPath -PathType Leaf) {
|
|
|
|
@@ -99,7 +107,9 @@ if (-not (Test-Path -LiteralPath `$installScript -PathType Leaf)) {
|
|
|
|
|
if (Test-Path -LiteralPath `$stagePath -PathType Container) {
|
|
|
|
|
Remove-Item -LiteralPath `$stagePath -Recurse -Force
|
|
|
|
|
}
|
|
|
|
|
Expand-Archive -LiteralPath `$archivePath -DestinationPath `$stagePath -Force
|
|
|
|
|
New-Item -ItemType Directory -Path `$stagePath -Force | Out-Null
|
|
|
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
|
|
|
[IO.Compression.ZipFile]::ExtractToDirectory(`$archivePath, `$stagePath)
|
|
|
|
|
}
|
|
|
|
|
if (-not (Test-Path -LiteralPath `$installScript -PathType Leaf)) {
|
|
|
|
|
throw 'The verified update package did not contain Install-CredentialProvider.ps1.'
|
|
|
|
@@ -115,8 +125,9 @@ if (-not (Test-Path -LiteralPath `$installScript -PathType Leaf)) {
|
|
|
|
|
DomainNetbios = [string]`$settings.DomainNetbios
|
|
|
|
|
TimeoutSeconds = [int]`$settings.TimeoutSeconds
|
|
|
|
|
}
|
|
|
|
|
`$dotnet = Get-Command dotnet -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source -ErrorAction SilentlyContinue
|
|
|
|
|
`$runtimeInstalled = `$dotnet -and (& `$dotnet --list-runtimes | Select-String '^Microsoft\.NETCore\.App 10\.')
|
|
|
|
|
`$dotnet = Join-Path `$env:ProgramFiles 'dotnet\dotnet.exe'
|
|
|
|
|
`$runtimeInstalled = (Test-Path -LiteralPath `$dotnet -PathType Leaf) -and
|
|
|
|
|
(& `$dotnet --list-runtimes | Select-String '^Microsoft\.NETCore\.App 10\.')
|
|
|
|
|
if (-not `$runtimeInstalled) {
|
|
|
|
|
`$runtimeInstaller = Get-ChildItem -LiteralPath (Join-Path `$stagePath 'payload\prerequisites') -Filter '*x64*.exe' -File |
|
|
|
|
|
Select-Object -First 1
|
|
|
|
@@ -134,8 +145,40 @@ if (-not `$runtimeInstalled) {
|
|
|
|
|
if ($PSCmdlet.ShouldProcess($startupPath, "Install '$scriptName' as a computer startup script")) {
|
|
|
|
|
New-Item -ItemType Directory -Path $startupPath -Force | Out-Null
|
|
|
|
|
[IO.File]::WriteAllText($scriptPath, $startupScript, [Text.UTF8Encoding]::new($false))
|
|
|
|
|
$scriptsIni = "[Startup]`r`n0CmdLine=$scriptName`r`n0Parameters=`r`n"
|
|
|
|
|
[IO.File]::WriteAllText($powershellScriptsIniPath, $scriptsIni, [Text.UTF8Encoding]::new($false))
|
|
|
|
|
$scriptUncPath = "\\$domainDnsRoot\SYSVOL\$domainDnsRoot\Policies\{$($gpo.Id)}\Machine\Scripts\Startup\$scriptName"
|
|
|
|
|
$scriptsIni = "[Startup]`r`n0CmdLine=powershell.exe`r`n0Parameters=-NoProfile -NonInteractive -ExecutionPolicy Bypass -File `"$scriptUncPath`"`r`n"
|
|
|
|
|
# The Scripts CSE requires UTF-16LE with a BOM. The explicit process
|
|
|
|
|
# execution policy allows the verified installer to run on Windows clients
|
|
|
|
|
# whose default PowerShell policy is Restricted.
|
|
|
|
|
[IO.File]::WriteAllText($scriptsIniPath, $scriptsIni, [Text.Encoding]::Unicode)
|
|
|
|
|
if (Test-Path -LiteralPath $legacyPowerShellScriptsIniPath -PathType Leaf) {
|
|
|
|
|
Remove-Item -LiteralPath $legacyPowerShellScriptsIniPath -Force
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Writing SYSVOL directly does not register the Scripts CSE in the GPO's
|
|
|
|
|
# Active Directory object. Without it, gpresult lists the GPO but the
|
|
|
|
|
# client never executes its startup script.
|
|
|
|
|
$gpoDn = "CN={$($gpo.Id)},CN=Policies,CN=System,$domainDn"
|
|
|
|
|
$gpoObject = Get-ADObject -Identity $gpoDn -Server $DomainController `
|
|
|
|
|
-Properties gPCMachineExtensionNames,versionNumber
|
|
|
|
|
$scriptExtension = '[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]'
|
|
|
|
|
$extensionNames = [string]$gpoObject.gPCMachineExtensionNames
|
|
|
|
|
if ($extensionNames.IndexOf($scriptExtension, [StringComparison]::OrdinalIgnoreCase) -lt 0) {
|
|
|
|
|
Set-ADObject -Identity $gpoDn -Server $DomainController `
|
|
|
|
|
-Replace @{gPCMachineExtensionNames = "$extensionNames$scriptExtension"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Keep the AD and SYSVOL computer versions synchronized and force clients
|
|
|
|
|
# to process this corrected script registration on their next refresh.
|
|
|
|
|
$gptIniPath = Join-Path (Split-Path (Split-Path $gpoScriptsPath -Parent) -Parent) 'GPT.ini'
|
|
|
|
|
$gptIni = Get-Content -LiteralPath $gptIniPath -Raw
|
|
|
|
|
$gptVersion = [int]([regex]::Match($gptIni, '(?m)^Version=(\d+)\r?$').Groups[1].Value)
|
|
|
|
|
$adVersion = [int]$gpoObject.versionNumber
|
|
|
|
|
$baseVersion = [Math]::Max($gptVersion, $adVersion)
|
|
|
|
|
$nextVersion = ($baseVersion -band -65536) -bor (($baseVersion + 1) -band 65535)
|
|
|
|
|
$updatedGptIni = [regex]::Replace($gptIni, '(?m)^Version=\d+\r?$', "Version=$nextVersion")
|
|
|
|
|
[IO.File]::WriteAllText($gptIniPath, $updatedGptIni, [Text.Encoding]::ASCII)
|
|
|
|
|
Set-ADObject -Identity $gpoDn -Server $DomainController -Replace @{versionNumber = $nextVersion}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[pscustomobject]@{
|
|
|
|
|