I'm a new user to stackoverflow, so thank you in advance for your help! Here is my scenerio:
In our current Windows XP environment we have a custom Gina.dll that prompts a non-admin user that logging in will boot the previous user. This is achievable with "Fast User Switching" in Windows 7, but that leaves multiple instances of applications open, and that causes issues. We are also concerned about the performance hits that multiple users will cause. In my research, I found that a Credential Provider will most likely be needed, but due to time constraints, I don't think we can build one in time.
I've successfully created a powershell script (with the help of stackoverflow!) that will log a previous user off, it looks like this:
$pc = qwinsta | select-string "Disc" | select-string -notmatch "services"
$pc = $pc -replace "[^\d]",""
logoff $pc
The problem with this is that if the username contains a number, such as username1 or user2, this script concatenates the numbers and it then fails. Can you help me edit this small powershell script so that it will choose the session id of the 'Disc" session and logoff??
Further Testing Results:
You can try this:
$pc = qwinsta | select-string "Disc" | select-string -notmatch "services"
if ($pc)
{
$pc = ($pc.tostring() -split ' +')[2]
logoff $pc
}
In this way you can logoff each disconnected session:
$pc = qwinsta | select-string "Disc" | select-string -notmatch "services"
if ($pc)
{
$pc| % {
logoff ($_.tostring() -split ' +')[2]
}
}