Files
windows-ansible/ansible/roles/win_domain_controller/templates/mapped_drive.ps1.j2
T

31 lines
1.1 KiB
Django/Jinja

$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'