-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue in setting the registry for auto logon and resolving the domain user #3760
Conversation
$isSessionActive = IsAnySessionActive | ||
if (-not ($isSessionActive)) | ||
Set-DisableScreenSaverReg | Out-Null | ||
ConfigurePowerOptions -MachineCredential $MachineUserCredential | Out-Null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConfigurePowerOptions -MachineCredential $MachineUserCredential [](start = 4, length = 64)
ConfigurePowerOptions -MachineCredential $MachineUserCredential [](start = 4, length = 64)
ConfigurePowerOptions function doesn't have any param to accept. Please check. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. PS didn't complain #Resolved
…main name for local user accounts
c17dc33
to
cce533c
Compare
} | ||
} | ||
|
||
# Getting rid of old Session check. WTSEnumerateSessions spits out if there are any active sessions are available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are [](start = 100, length = 3)
are [](start = 100, length = 3)
[opt] not needed #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't get this one. comments/stories are good to have ;)
#Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
$computer = $env:COMPUTERNAME | ||
try { | ||
$quserOut = quser.exe /SERVER:$computer 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quser [](start = 20, length = 5)
Please check windows 7 supports it or not.
as https://technet.microsoft.com/en-us/library/cc754583(v=ws.11).aspx says
Applies To: Windows Vista, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows 8 #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support Windows 7 in v2 #Resolved
# For UI testing, we need active local users logged in instead of sessions check | ||
function IsTestUserCurrentlyLoggedIn($TestUserName) | ||
{ | ||
$computer = $env:COMPUTERNAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$computer [](start = 4, length = 9)
This is being used only once. Do we really need it. You can directly pass $env:COMPUTERNAME to quser #WontFix
Remove-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name AutoLogonCount -ErrorAction SilentlyContinue | ||
Remove-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -ErrorAction SilentlyContinue | ||
[MS.VS.TestTools.Config.RegHelper]::SetAutoLogonPassword($TestUserPassword) | ||
if ($quserOut -match "No user exists") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$quserOut -match "No user exists" [](start = 8, length = 33)
will this comparison hold in machine with different locales? please check.
return $false | ||
} | ||
|
||
$users = $quserOut -replace '\s{2,}', ',' | ConvertFrom-CSV -Header 'username', 'sessionname', 'id', 'state', 'idleTime', 'logonTime' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'username', 'sessionname', 'id', 'state', 'idleTime', 'logonTime' [](start = 72, length = 65)
'username', 'sessionname', 'id', 'state', 'idleTime', 'logonTime' [](start = 72, length = 65)
check for machines with different locales #Resolved
foreach ($user in $users) | ||
{ | ||
Write-Verbose "Logged in user: $($user.username) $($user.state)" -Verbose | ||
if(($user.username -ieq $TestUserName) -and ($user.state -ieq 'active')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$user.state -ieq 'active' [](start = 53, length = 25)
$user.state -ieq 'active' [](start = 53, length = 25)
please check for different locales #Resolved
Remove-ItemProperty -Path 'REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -Name DefaultPassword -ErrorAction SilentlyContinue | ||
|
||
[MS.VS.TestTools.Config.RegHelper]::SetAutoLogonPassword($TestUserPassword) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add log message - autologon successfully enabled #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We print that from C# side for success #Resolved
Will this point to wow6432node in 64bit machine? Refers to: Tasks/DeployVisualStudioTestAgent/SetupTestMachineForUITests.ps1:3 in 7bd2674. [](commit_id = 7bd2674, deletion_comment = False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good..
return true; | ||
} | ||
WTSFreeMemory(userPtr); | ||
WTSFreeMemory(domainPtr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WTS FreeMemory calls should be place in finally
Write-Verbose -Message("Trying to delete service {0}" -f $ServiceName) -Verbose | ||
if($service) | ||
{ | ||
$service.StopService() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$service.StopService() [](start = 11, length = 23)
Please check, what happens, if stopping the service throws an error, as we are not handling that?
Write-Verbose -Message("Trying to delete service {0}" -f $ServiceName) -Verbose | ||
if($service) | ||
{ | ||
$service.StopService() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$service.StopService() [](start = 11, length = 23)
Should we use -Force option here ?
{ | ||
$service.StopService() | ||
$deleteServiceCode = $service.Delete() | ||
if($deleteServiceCode -eq 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f($deleteServiceCode -eq 0) [](start = 13, length = 27)
As per https://msdn.microsoft.com/en-us/library/aa389960(VS.85).aspx Delete method returns 0 if the request was accepted and not for error scenario. Please check.
Testing: