mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-26 13:37:21 +00:00
This actually maps a drive!!!
This commit is contained in:
1 parent
c9d991940b
commit
925307554f
2 files changed
+15
-18
No files matched your search
@@ -1,25 +1,21 @@
|
||||
$gp_name = "Map Study Drive"
|
||||
|
||||
New-GPO -Name $gp_name
|
||||
New-GPO -Name $gp_name -comment "Registry Keys To Map Study Drive"
|
||||
|
||||
$gp = Get-GPO -Name $gp_name
|
||||
$gp_id = $gp.Id
|
||||
$map_regkey = "HKEY_CURRENT_USER\Network\{{ study_data_letter }}"
|
||||
$label_regkey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##{{ win_project }}#{{ share_name }}"
|
||||
|
||||
$create_date = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "ConnectFlags" -key "$map_regkey" -Value 0 -Type DWord
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "ConnectionType" -key "$map_regkey" -Value 1 -Type DWord
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "DeferFlags" -key "$map_regkey" -Value 4 -Type DWord
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "ProviderFlags" -key "$map_regkey" -Value 1 -Type DWord
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "ProviderName" -key "$map_regkey" -Value "Microsoft Windows Network" -Type String
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "ProviderType" -key "$map_regkey" -Value 131072 -Type DWord
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "RemotePath" -key "$map_regkey" -Value "{{ study_data_dfs }}" -Type String
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "UserName" -key "$map_regkey" -Value "" -Type String
|
||||
|
||||
$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
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "_LabelFromDesktopINI" -key "$labe_regkey" -Value "" -Type String
|
||||
Set-GPRegistryValue -Name "$gp_name" -ValueName "_LabelFromReg" -key "$label_regkey" -Value "{{ study_data_label }}" -Type String
|
||||
|
||||
$DomainInfo = Get-ADDomain
|
||||
$DomainOU = $DomainInfo.DistinguishedName
|
||||
|
||||
@@ -8,7 +8,8 @@ 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
|
||||
share_name: Study_Data
|
||||
study_data_dfs: \\{{ win_project }}\{{ share_name }}
|
||||
study_data_label: Study Data
|
||||
study_data_letter: S
|
||||
|
||||
|
||||
Reference in new issue
Block a user