# Bu script sadece wef icin hazirlanan GPO'lari import etmek icin hazirlanmistir.
# Logsign WEF Server GPO Import

Write-Host "Aşağıda sizlerden GPO'larin import edilecegi distinguishedName bilgisini isteyecektir, konu hakkunda bilginiz yoksa kurulum dokumanini inceleyiniz!"
Write-Host "Ornek: OU=LogsignGPOs,DC=logsign,DC=net"
$OU = Read-Host -Prompt 'distinguishedName'
#$OU = "ou=LogsignGPOs,dc=logsign,dc=net" # bu satiri guncelleyiniz

Write-Host "Siem Syslog ip'sini giriniz!"
$NxlogConf="${PSScriptRoot}\GPOFILES\WEF-SERVER\{90E9818C-A292-4B2D-A548-9BC58C31EF0D}\DomainSysvol\GPO\Machine\Scripts\Startup\nxlog.conf"
$Syslog= Read-Host -Prompt 'Siem Syslog ip'
(Get-Content $NxlogConf) -Replace 'LogsignSIEM', "$Syslog" | Set-Content $NxlogConf


Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Logsign_Wef Server GPO'su import ediliyor ..."
$GPOName = 'Logsign_Wef Server'
Write-Host "Importing $GPOName..."
Import-GPO -BackupGpoName $GPOName -Path "${PSScriptRoot}\GPOFILES\WEF-SERVER" -TargetName $GPOName -CreateIfNeeded
$gpLinks = $null
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
$GPO = Get-GPO -Name $GPOName
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
{
    New-GPLink -Name $GPOName -Target $OU -Enforced yes
}
else
{
    Write-Host "$GPOName $OU 'ya linklendi."
}


# Logsign WEF for Servers GPO Import

Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) WEF for Servers GPO'su LogsignGPOs OU'suna import ediliyor ..."
$GPOName = 'Logsign_Wef For Servers'
Write-Host "Importing $GPOName..."
Import-GPO -BackupGpoName $GPOName -Path "${PSScriptRoot}\GPOFILES\WEF-FOR-SERVER" -TargetName $GPOName -CreateIfNeeded
$gpLinks = $null
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
$GPO = Get-GPO -Name $GPOName
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
{
    New-GPLink -Name $GPOName -Target $OU -Enforced yes
}
else
{
    Write-Host "$GPOName $OU 'ya linklendi."
}


# Logsign_Audits GPO Import

Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Logsign_Audit GPO'su LogsignGPOs OU'suna import ediliyor ..."
$GPOName = 'Logsign_Audits'
Write-Host "Importing $GPOName..."
Import-GPO -BackupGpoName $GPOName -Path "${PSScriptRoot}\GPOFILES\WEF-Audits" -TargetName $GPOName -CreateIfNeeded
$gpLinks = $null
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
$GPO = Get-GPO -Name $GPOName
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
{
    New-GPLink -Name $GPOName -Target $OU -Enforced yes
}
else
{
    Write-Host "$GPOName $OU 'ya linklendi."
}
