Advertisement
Guest User

Powershell - Online PC herausfinden

a guest
Jun 16th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ALLE ONLINE PC HERAUSFINDEN
  2. #get-ADComputer -Filter "OperatingSystem -like 'Win*'" -credential $adcred -Properties * #| Format-Table Name, OperatingSystem, LastLogonDate -Autosize
  3.  
  4. #FENSTERGRÖßE ANPASSEN
  5. $pshost = get-host
  6. $pswindow = $pshost.ui.rawui
  7. $newsize = $pswindow.buffersize
  8. $newsize.height = 3000
  9. $newsize.width = 94
  10. $pswindow.buffersize = $newsize
  11. $newsize = $pswindow.windowsize
  12. $newsize.height = 60
  13. $newsize.width = 94
  14. $pswindow.windowsize = $newsize
  15.  
  16. #AD ZUGANGSDATEN DEFINIEREN
  17. $ADuser = 'DOMAIN\Administrator'
  18. $ADpass = 'Password'
  19. $encpass = $ADpass | ConvertTo-SecureString -AsPlainText -Force
  20. $adcred = New-Object pscredential($ADuser, $encpass)
  21.  
  22.  
  23. Import-Module active*
  24.  
  25. $rtn = $null
  26. write-host -ForegroundColor white "Aktueller PC Status:"
  27. Get-ADComputer -Filter "OperatingSystem -like 'Win*'" -credential $adcred -Properties * |
  28. ForEach-Object {
  29.   $rtn = Test-Connection -CN $_.dnshostname -Count 1 -BufferSize 16 -Quiet
  30.   IF($rtn -match ‘True’) {
  31.     write-host -ForegroundColor green $_.dnshostname
  32.  
  33.     }
  34.   ELSE {
  35.     Write-host -ForegroundColor red $_.dnshostname
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement