Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |||
|
winlogbeat [2025/04/06 10:41] jango |
winlogbeat [2025/04/16 11:34] (aktuell) jango |
||
|---|---|---|---|
| Zeile 109: | Zeile 109: | ||
| =====Windows Deployment===== | =====Windows Deployment===== | ||
| + | Not good | ||
| <code powershell> | <code powershell> | ||
| #$servers = Get-ADComputer -Filter * | Where-Object { $_.Name -like " | #$servers = Get-ADComputer -Filter * | Where-Object { $_.Name -like " | ||
| Zeile 161: | Zeile 162: | ||
| } | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Good | ||
| + | <code powershell> | ||
| + | # | ||
| + | # Last run stopped at vie-srv-admin01 (not finished) | ||
| + | # | ||
| + | |||
| + | <# | ||
| + | $servers = Get-ADComputer -Filter * -Properties * | Where-Object { | ||
| + | $_.Name -like " | ||
| + | -and $_.OperatingSystem -like " | ||
| + | -and $_.DistinguishedName -notlike " | ||
| + | } | Select-Object -ExpandProperty Name | ||
| + | #> | ||
| + | |||
| + | $servers = @( | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | $logfile = " | ||
| + | $online = " | ||
| + | $offline = " | ||
| + | |||
| + | #$servers = @(" | ||
| + | |||
| + | foreach ($server in $servers) { | ||
| + | |||
| + | # If the service is running, stop it so we can overwrite files | ||
| + | | ||
| + | $status = (Get-Service -Name Winlogbeat -ComputerName $server).Status | ||
| + | if($status -like " | ||
| + | Write-Output " | ||
| + | $r = (Get-Service Winlogbeat -ComputerName $server).Stop() | ||
| + | Write-Output " | ||
| + | } else { | ||
| + | Write-Output " | ||
| + | } | ||
| + | | ||
| + | |||
| + | $session = New-PSSession -ComputerName $server | ||
| + | Copy-Item -Path " | ||
| + | |||
| + | try { | ||
| + | |||
| + | Invoke-Command -ComputerName $server -ErrorAction Stop -ScriptBlock { | ||
| + | | ||
| + | Param($srv) | ||
| + | |||
| + | #whoami | ||
| + | |||
| + | # Copy new files | ||
| + | <# | ||
| + | Write-Output " | ||
| + | $source = " | ||
| + | $destination = " | ||
| + | $xcopyArgs = " | ||
| + | | ||
| + | $output = cmd /c "xcopy `" | ||
| + | # | ||
| + | | ||
| + | Write-Output " | ||
| + | #> | ||
| + | |||
| + | $scriptPath = " | ||
| + | |||
| + | if (Test-Path $scriptPath) { | ||
| + | |||
| + | # Execute install script | ||
| + | powershell.exe -ExecutionPolicy Bypass -File $scriptPath | ||
| + | # Start service | ||
| + | Start-Service winlogbeat | ||
| + | # Set startup type to automatic | ||
| + | Set-Service winlogbeat -StartUpType Auto | ||
| + | # Check status | ||
| + | Write-Output " | ||
| + | |||
| + | } else { | ||
| + | |||
| + | Write-Output " | ||
| + | |||
| + | } | ||
| + | | ||
| + | |||
| + | $status = (Get-Service winlogbeat).Status | ||
| + | Write-Output " | ||
| + | |||
| + | # | ||
| + | |||
| + | } -ArgumentList $server | ||
| + | |||
| + | #$stat >> $online | ||
| + | |||
| + | | ||
| + | } catch { | ||
| + | | ||
| + | $connection = Test-Connection -ComputerName $server -Count 1 -Quiet | ||
| + | |||
| + | # Wenn der Server nicht erreichbar ist, schreibe es ins Log | ||
| + | if (-not $connection) { | ||
| + | Write-Output " | ||
| + | } else { | ||
| + | Write-Output " | ||
| + | } | ||
| + | |||
| + | } | ||
| + | | ||
| } | } | ||
| </ | </ | ||