Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $computer='localhost'
- $username = gwmi win32_computersystem -comp $computer | select Username
- $userstring = [string]$username
- $usernamejunk,$adilstu_user = $userstring.Split("=",2)
- $usernameonly,$usernamebracket = $adilstu_user.Split("}",2)
- $date = (Get-Date).ToString('HH')
- $FilePath = 'C:\Users\User\Desktop\restartet.txt'
- IF([string]::IsNullOrEmpty($usernameonly)) {
- IF([string]::IsNullOrEmpty((Get-Content $FilePath))) {
- Out-File -FilePath $FilePath -InputObject $date
- Restart-Computer -Force
- }
- else {
- exit
- }
- }
- else {
- write-host "Benutzer ist noch angemeldet"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement