De bedoeling is , dat dit vba script (in access) de gefilterde database overloopt en op basis van de data het structuur script maakt en het rechten script.
Je voert deze scripts uit in powershell en de mappen zullen aangemaakt worden en de rechten zullen goed aangepast zijn.
Private Sub Knop15_Click()
Dim o As Integer
Dim test As String
DoCmd.GoToRecord , , acLast
p = Me.CurrentRecord
DoCmd.GoToRecord , , acFirst
Target = Me.Tekst20 & “\users.ps1”
target2 = Me.Tekst20 & “\struct.ps1”
Open Target For Output As #1
Open target2 For Output As #2
For i = 1 To p
test = Me.netpath
If FolderExists(test) = False Then
MkDir (test)
End If
cmdscript = “xcopy ” + “””” + “g:\ccd\cns\structuur dossier” + “””” + ” ” + “””” + Me.netpath + “””” + ” /E /Y ”
psscript = “$NasPath = ‘” & Me.netpath & “‘” & vbNewLine
psscript = psscript & “$Acl = Get-Acl $NasPath” & vbNewLine
psscript = psscript & “$Ar = New-Object system.security.accesscontrol.filesystemaccessrule(‘” & Me.ccdschrijf & “‘,’Modify’,’ContainerInherit, ObjectInherit’, ‘None’, ‘Allow’)” & vbNewLine
psscript = psscript & “$Acl.AddAccessRule($Ar)” & vbNewLine
psscript = psscript & “Set-Acl $NasPath $Acl” & vbNewLine
psscript = psscript & “$Ar = New-Object system.security.accesscontrol.filesystemaccessrule(‘” & Me.ccdlees & “‘,’Read,ReadAndExecute,ListDirectory’,’ContainerInherit, ObjectInherit’, ‘None’, ‘Allow’)” & vbNewLine
psscript = psscript & “$Acl.AddAccessRule($Ar)” & vbNewLine
psscript = psscript & “Set-Acl $NasPath $Acl” & vbNewLine
Print #1, psscript
Print #2, cmdscript
If i < p Then
DoCmd.GoToRecord , , acNext
End If
Next i
Close #1
Close #2
End Sub