40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PowerShell
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PowerShell
		
	
	
		
			Executable File
		
	
	
	
	
| # 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
 | |
| $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
 | 
