SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.  .Synopsis
  3.  Abfrage der aktiven Computerkonten
  4. #>
  5.  
  6. #requires -version 5.0
  7.  
  8. #requires -module ActiveDirectory
  9.  
  10. param($ADFilter = {}, $CSVPfad="ADGCAbfrage.csv")
  11. $GC = (Get-ADDomainController -Discover -Service GlobalCatalog).Hostname[0]
  12. $DCHost = $GC + ":3268"
  13.  
  14. # Anlegen einer leeren Liste (Array)
  15. $ErgebnisListe = @()
  16.  
  17. Get-ADComputer -Filter $ADFilter -Properties OperatingSystem, LastLogonDate `
  18.  -Server $DCHost | ForEach-Object {
  19.     if ($_.LastLogonDate -ne $null)
  20.     {
  21.         Write-Progress -Activity "AD-Abfrage" -Status "Abfrage von $($_.Name)"
  22.         $ErgebnisListe += [PSCustomObject]@{
  23.             Computer = $_.Name
  24.             LetzteAnmeldung = $_.LastLogonDate
  25.         }
  26.     }
  27. }
  28.  
  29. $ErgebnisListe | Export-CSV -Path $CSVPfad -Delimiter ";" -NoTypeInformation
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top