Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| скрипты_ad [2024/01/29 10:15] – jp | скрипты_ad [2024/06/25 13:12] (current) – jp | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Скрипты AD ===== | ===== Скрипты AD ===== | ||
| - | Найти все машины с Windows в домене AD, которые включены, | + | **Найти все машины с Windows в домене AD, которые включены, |
| < | < | ||
| Line 11: | Line 11: | ||
| if ((Get-ChildItem $ldPath | where {$_.objectClass -eq " | if ((Get-ChildItem $ldPath | where {$_.objectClass -eq " | ||
| </ | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | **Вывод информации об ОС (полный билд и т.д.) всех компьютеров домена** | ||
| + | |||
| + | Перед запуском скрипта необходимо создать две директории: | ||
| + | |||
| + | <WRAP prewrap> | ||
| + | < | ||
| + | <# | ||
| + | .SYNOPSIS | ||
| + | Get-WindowsOSBuilds.ps1 | ||
| + | |||
| + | .DESCRIPTION | ||
| + | Export Windows OS versions and build numbers to CSV file. | ||
| + | |||
| + | .LINK | ||
| + | alitajran.com/ | ||
| + | |||
| + | .NOTES | ||
| + | Written by: ALI TAJRAN | ||
| + | Website: | ||
| + | LinkedIn: | ||
| + | |||
| + | .CHANGELOG | ||
| + | V1.00, 04/16/2023 - Initial version | ||
| + | #> | ||
| + | |||
| + | # Retrieve a list of all computers in the domain | ||
| + | $computers = Get-ADComputer -Filter { OperatingSystem -Like " | ||
| + | |||
| + | # Set the registry path that will be used to retrieve the Windows build numbers | ||
| + | $regPath = " | ||
| + | |||
| + | # Initialize progress bar | ||
| + | $total = $computers.Count | ||
| + | $completed = 0 | ||
| + | $progress = 0 | ||
| + | Write-Progress -Activity " | ||
| + | |||
| + | # Loop through each computer and retrieve the Windows versions and build numbers (if the computer is online) | ||
| + | $results = foreach ($computer in $computers) { | ||
| + | $computerName = $computer.Name | ||
| + | $online = Test-Connection -ComputerName $computerName -Count 1 -Quiet | ||
| + | if ($online) { | ||
| + | $winRMEnabled = (Test-WSMan -ComputerName $computerName -ErrorAction SilentlyContinue) -ne $null | ||
| + | if ($winRMEnabled) { | ||
| + | $buildNumber = (Invoke-Command -ComputerName $computerName { (Get-ItemProperty -Path $using: | ||
| + | $revisionNumber = (Invoke-Command -ComputerName $computerName { (Get-ItemProperty -Path $using: | ||
| + | $windowsBuildNumber = " | ||
| + | $edition = (Invoke-Command -ComputerName $computerName { (Get-ItemProperty -Path $using: | ||
| + | $version = (Invoke-Command -ComputerName $computerName { (Get-ItemProperty -Path $using: | ||
| + | } | ||
| + | else { | ||
| + | $windowsBuildNumber = " | ||
| + | $edition = " | ||
| + | $version = " | ||
| + | } | ||
| + | [PSCustomObject] @{ | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | else { | ||
| + | [PSCustomObject] @{ | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | $completed++ | ||
| + | $progress = [Math]:: | ||
| + | Write-Progress -Activity " | ||
| + | } | ||
| + | |||
| + | # Sort the results by ComputerName in ascending order and select only the desired columns | ||
| + | $results | Sort-Object ComputerName | Select-Object ComputerName, | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Автор скрипта: | ||
| + | |||
| + | {{tag> | ||