Research and Development
Stop-Computer
and Restart-Computer
can shutdown and restart a machine, but there are things they cannot do, for example logging off the current user.
Here’s a simple function wrapper that utilizes a standard console application and wraps it into a PowerShell function:
function Invoke-Logoff {
shutdown.exe /L
}