Skip to content

Commit

Permalink
Fix appveyor_rdp_password (#2847)
Browse files Browse the repository at this point in the history
* Temporary tracing and longer wait

* Ensure validation function works

* Another ValidatePassword approach

* ValidatePassword - verbose and delete folder

* test folder

* Update enable-rdp.ps1

* Update enable-rdp.ps1

* Wait Initial Password Change

* Fix syntax error

* More tracing

* Sleep If before clone and revert retry
  • Loading branch information
Ilya Finkelshteyn authored Feb 2, 2019
1 parent 70125fa commit d321ba5
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions scripts/enable-rdp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ function ChangePassword($password) {
$objUser.CommitChanges()
}

function ValidatePassword($password) {
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('machine',$env:computername)
$DS.ValidateCredentials("appveyor", $password)
function SleepIfBeforeClone() {
if (!(Get-ItemProperty 'HKLM:\SOFTWARE\Appveyor\Build Agent\State' -Name GetSources -ErrorAction Ignore).GetSources -eq "true") {
sleep 30
}
}

if((Test-Path variable:islinux) -and $isLinux) {
Expand All @@ -23,18 +23,9 @@ $port = 3389
$password = ''
if($env:appveyor_rdp_password) {
# take from environment variable
$password = $env:appveyor_rdp_password

# change password. Best effort to ensure password change applied.
$count = 0
$valid = $false
do {
for ($i=0; $i -le 30; $i++) {ChangePassword($password); Start-Sleep -Milliseconds 100}
$valid = ValidatePassword($password)
$count++
if(!$valid) {Start-Sleep -Milliseconds 100}
} while(!$valid -and ($count -lt 3))

$password = $env:appveyor_rdp_password
SleepIfBeforeClone
for ($i=0; $i -le 30; $i++) {ChangePassword($password); Start-Sleep -Milliseconds 100}
[Microsoft.Win32.Registry]::SetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", $password)
} else {
# get existing password
Expand Down

0 comments on commit d321ba5

Please sign in to comment.