Genereren van Powershell scripts op basis van

advertisement
This page was exported from De sleutel voor ict [ http://www.dklus.be ]
Export date: Tue Jul 18 16:08:33 2017 / +0000 GMT
Genereren van Powershell scripts op basis van gegevens uit
access database - aanmaken mappen en aanpassen van
security
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:ccdcnsstructuur 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
Post date: 2015-04-15 14:44:40
Post date GMT: 2015-04-15 13:44:40
Post modified date: 2015-04-15 14:47:54
Post modified date GMT: 2015-04-15 13:47:54
Powered by [ Universal Post Manager ] plugin. MS Word saving format developed by gVectors Team www.gVectors.com
Download