added pre and post checks for installations
This commit is contained in:
@@ -1,6 +1,39 @@
|
||||
# Purpose: Install the GPO that specifies the WEF collector
|
||||
Write-Host "Importing the GPO to enable Powershell Module, ScriptBlock and Transcript logging..."
|
||||
Import-GPO -BackupGpoName 'Powershell Logging' -Path "c:\vagrant\resources\GPO\powershell_logging" -TargetName 'Powershell Logging' -CreateIfNeeded
|
||||
New-GPLink -Name 'Powershell Logging' -Target "dc=windomain,dc=local" -Enforced yes
|
||||
New-GPLink -Name 'Powershell Logging' -Target "ou=Domain Controllers,dc=windomain,dc=local" -Enforced yes
|
||||
$OU = "ou=Workstations,dc=windomain,dc=local"
|
||||
$gPLinks = $null
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name 'Powershell Logging'
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
New-GPLink -Name 'Powershell Logging' -Target $OU -Enforced yes
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Powershell Loggin was already linked at $OU. Moving On."
|
||||
}
|
||||
$OU = "ou=Servers,dc=windomain,dc=local"
|
||||
$gPLinks = $null
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
$GPO = Get-GPO -Name 'Powershell Logging'
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
New-GPLink -Name 'Powershell Logging' -Target $OU -Enforced yes
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Powershell Loggin was already linked at $OU. Moving On."
|
||||
}
|
||||
$OU = "ou=Domain Controllers,dc=windomain,dc=local"
|
||||
$gPLinks = $null
|
||||
$gPLinks = Get-ADOrganizationalUnit -Identity $OU -Properties name,distinguishedName, gPLink, gPOptions
|
||||
If ($gPLinks.LinkedGroupPolicyObjects -notcontains $gpo.path)
|
||||
{
|
||||
New-GPLink -Name 'Powershell Logging' -Target $OU -Enforced yes
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Powershell Loggin was already linked at $OU. Moving On."
|
||||
}
|
||||
gpupdate /force
|
||||
|
||||
Reference in New Issue
Block a user