This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $exePath = "C:\Program Files (x86)\Steam\steamapps\common\Banana Shooter\Banana Shooter.exe" | |
| for ($i = 0; $i -lt 1000; $i++) { | |
| $proc = Start-Process -FilePath $exePath -PassThru | |
| Start-Sleep -Seconds (Get-Random -Minimum 8 -Maximum 12) | |
| Stop-Process -Id $proc.Id -Force | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Invoke-Command -ComputerName "TARGETCOMPUTER" -ScriptBlock { | |
| $sessions = query user | |
| # Use a more robust regex to grab the ID regardless of the SessionName column being blank | |
| $sessions | Select-String -Pattern '(?<ID>\d+)\s+(?=(Active|Disc))' | ForEach-Object { | |
| logoff $_.Matches.Groups['ID'].Value | |
| } | |
| foreach ($session in $sessions) { | |
| $sessionID = ($session -split ' +')[2] | |
| logoff $sessionID | |
| } |