Create GPO to map study drive

This commit is contained in:
abrown38 committed 2024-09-13 14:17:00 +01:00
1 parent 621d97fb63
commit c40e256a9f
3 files changed
+55 -2

No files matched your search

@@ -24,7 +24,7 @@
- name: Copy ADMX and ADML files to DCs
win_copy:
src: policy_templates/PolicyDefinitions
dest: "C:\\Windows\\SYSVOL\\sysvol\\{{ win_project }}.loc\\policies\\"
dest: "{{ policy_path }}\\"
force: true
- name: Rebooting DC01 post promotion to domain controller
@@ -162,7 +162,7 @@
vars:
proxy_vm: "{{ os_project }}-{{ win_project }}-proxy"
proxy_address: "{{ hostvars[proxy_vm].ansible_host }}:3128"
ansible.builtin.template:
ansible.windows.win_template:
src: "{{ squid_proxy_script_tmpl }}"
dest: "{{ script_dir }}\\{{ squid_proxy_script }}"
force: true
@@ -174,3 +174,18 @@
when: |
inventory_hostname in groups['meta-name_dc01'] and
project_zone == 'protected'
- name: Mapped Drive GPO Script
tags: mapped_drive_script
block:
- name: Copy Mapped Drive GPO Script
ansible.windows.win_template:
src: "{{ mapped_drive_script_tmpl }}"
dest: "{{ script_dir }}\\{{ mapped_drive_script }}"
force: true
tags: copy_mapped_drive_script
- name: Apply Mapped Drive GPO Script
win_shell: "powershell {{ script_dir }}\\{{ mapped_drive_script }}"
tags: create_mapped_drive_gpo
when: inventory_hostname in groups['meta-name_dc01']
@@ -0,0 +1,30 @@
$gp_name = "Map Study Drive"
New-GPO -Name $gp_name
$gp = Get-GPO -Name $gp_name
$gp_id = $gp.Id
$create_date = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$xml_path = "{{ policy_path }}\{$gp_id}\User\Preferences\Drives"
New-Item -ItemType Directory -Force $xml_path
$data = @"
<?xml version="1.0" encoding="utf-8"?>
<Drives clsid="{8FDDCC1A-0C3C-43cd-A6B4-71A6DF20DA8C}">
<Drive clsid="{935D1B74-9CB8-4e3c-9914-7DD559B7A417}" name="{{ study_data_letter }}:" status="{{ study_data_letter }}:" image="0" changed="$create_date" uid="">
<Properties action="C" thisDrive="NOCHANGE" allDrives="NOCHANGE" userName="" path="{{ study_data_dfs }}" label="{{ study_data_label }}" persistent="1" useLetter="1" letter="{{ study_data_letter }}"/>
</Drive>
</Drives>
"@
$data | Out-File $xml_path\Drives.xml -Encoding utf8 -Force
$DomainInfo = Get-ADDomain
$DomainOU = $DomainInfo.DistinguishedName
$workbenchOU = (Get-ADOrganizationalUnit -Identity "OU=Workbench,$DomainOU").DistinguishedName
New-GPLink -Name $gp_name -Target $workbenchOU
Write-Output "THIS SCRIPT ACTUALLY RAN" | Out-File -FilePath 'C:\eidf\StudyDrive_script.txt'
@@ -1,9 +1,17 @@
policy_path: "C:\\Windows\\SYSVOL\\sysvol\\{{ win_project }}.loc\\Policies"
group_policy_script: OpenStackADBuild.ps1
server_hardening_script: serverhardening.ps1
squid_proxy_script: proxy_gpo.ps1
squid_proxy_script_tmpl: proxy_gpo.ps1.j2
script_dir: C:\eidf
mapped_drive_script: mapped_drive.ps1
mapped_drive_script_tmpl: mapped_drive.ps1.j2
study_data_dfs: \\{{ win_project }}\Study_Data
study_data_label: Study Data
study_data_letter: S
OUs:
- Project Users
- Project Groups