Dear all,
Here's my new conundrum,
I have a script where I want to call a sub routine at two different points but with different actions.
I decided I probably want to use arguments and then a case statement in the sub routine itself.
So, in the main part of the code I will have the following commands:
Call CreateSecurityGroups(Parent) 'Call Procedure for creating security groups and send the "Parent" argument
Call CreateSecurityGroups(Child) 'Call Procedure for creating security groups and send the "Child" argument
The Sub routine is as follows (note it has some variables: strNewFolder, strGroupModify, strGroupRestricted, SubDir)
I'm struggling with how to call or pass an argument to then allow the case statement to make use of it.
In the past I've used VBA with the "OpenArgs" command, which would be perfect for this idea.
I look forward to your wisdom.
Thanks,
Simon
Here's my new conundrum,
I have a script where I want to call a sub routine at two different points but with different actions.
I decided I probably want to use arguments and then a case statement in the sub routine itself.
So, in the main part of the code I will have the following commands:
Call CreateSecurityGroups(Parent) 'Call Procedure for creating security groups and send the "Parent" argument
Call CreateSecurityGroups(Child) 'Call Procedure for creating security groups and send the "Child" argument
The Sub routine is as follows (note it has some variables: strNewFolder, strGroupModify, strGroupRestricted, SubDir)
Code:
Public Sub CreateSecurityGroups(Parent,Child) 'I do not know if
'-----------------------------------------------------------
'----------- Security Groups Creation Sub-Routine ----------
'-----------------------------------------------------------
'This case statement is designed to select what the strGroupModify and strGroupRestricted variables
'will become equal to, based on if it is called with the "Parent" or "Child" argument.
Select Case Argument 'I do not know what I am supposed to select here
Case Parent
strGroupModify = strNewFolder & " - Modify Access"
strGroupRestricted = strNewFolder & " - Restricted"
Case Child
strGroupModify = strNewFolder & " - " & SubDir & " - Modify Access"
strGroupRestricted = strNewFolder & " - " & SubDir & " - Restricted"
End Select
strGroupModifyLong = "cn=" & strGroupModify
strGroupRestrictedLong = "cn=" & strGroupRestricted
'Modify Group ****************
Set objGroup = objOU.Create("Group", strGroupModifyLong)
objGroup.Put "sAMAccountName", strGroupModify
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo
Set objGroup = Nothing
'Restricted Group *************
Set objGroup = objOU.Create("Group", strGroupRestrictedLong)
objGroup.Put "sAMAccountName", strGroupRestricted
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo
Set objGroup = Nothing
End Sub
I'm struggling with how to call or pass an argument to then allow the case statement to make use of it.
In the past I've used VBA with the "OpenArgs" command, which would be perfect for this idea.
I look forward to your wisdom.
Thanks,
Simon