windows – Change local PowerShell user


Purpose: to perform a change of the local user (logout and login) on certain events (local time).

Computers outside the domain. OS – Windows 7 Pro.

Throw in the documentation, everything that I found for the domain structure. (Or is there no difference?)

Maybe I have chosen the wrong tool? Should I use YP? (C #?)


You can logout from powershell, of course, simply by using the logoff command. But interactive login as noted by @ n01d is not possible from powershell.

However, if you just need access from powershell as a specific user, you can always implement this, for example, like this:

$crd = New-Object System.Management.Automation.PSCredential "имя_пользователя", (ConvertTo-SecureString -String 'пароль' -AsPlainText -Force)
$new_session  = New-PSSession -ComputerName $computerName -Credential $crd -ConfigurationName Microsoft.PowerShell32
Scroll to Top