PowerShell İle İşletim Sistemine Göre AD Bilgisayar Sayılarını Bulma
![Resim](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl4UXt5rp0PmNG37CbPTrY3rdXKZPRrEGftISojaQ2VZRDWq3XAAwS6ggJTRv9bXo-GGSR74aUXEkhIaGmeTXjbY60cG-SBlGso4M0CKo1xYNoRJd31YnimdfJ6BdM1VywBLULemZx3mfJVKsB-hOz6yZBcjH138DAi5J8OCsSGpAbq8HDr49b88MdMA/w383-h400/ScreenHunter_002.bmp)
Aşağıdaki powershell scripti ile yukarıdaki ekran görüntüsünde göründüğü gibi bilgisayar sayıları kolaylıkla elde edilebilir. # Import AD module Import-Module ActiveDirectory # Domain adını bulma $DomainName = (Get-ADDomain).NetBIOSName # Kaç gün öncesine kadar oturum açmış makineleri sorgula $days = 30 $lastLogonDate = (Get-Date).AddDays(-$days).ToFileTime() # AD sorgulama $Computers = @(Get-ADComputer -Properties Name,operatingSystem,lastLogontimeStamp -Filter {(OperatingSystem -like "*Windows*") -AND (lastLogontimeStamp -ge $lastLogonDate)}) foreach($Computer in $Computers) { $Computer.OperatingSystem = $Computer.OperatingSystem -replace '®' -replace '™' -replace '专业版','Professional (Ch)' -replace 'Professionnel','Professional (Fr)' } $Computers | Group-Object operatingSystem | Select Count,Name | Sort Name | Out-GridView