0 votes

Here is my issue, When I use this code: $DNs = %param-GroupsInRole% $Groups = $DNs -split "|" %Param-GroupsInRole% can have multiple groups. When setting up the parameter I am asked to pick a separator. So far I have picked ; and | (pipe) but I keep getting an errror like this: image.png

I just need to be able to do a foreach with the groups picked by the initiator.

by (1.0k points)

1 Answer

0 votes
by (272k points)

Hello,

That is not something you can do using the value reference. You need to use method $Context.GetParameterValue. Finally, the code should look like the following:

$groupsParam = "param-Groups" # TODO: modify me
$groupsParamSeparator = ";" # TODO: modify me

$groups = $Context.GetParameterValue($groupsParam)
foreach ($dn in $groups.Split($groupsParamSeparator))
{
    # your code here
}
0

That makes sense however, when I am using this code: image.png Useing this set up: image.png I get this error image.png

+1

Hello,

The issue occurs because the parameter name in your script is incorrect. According to your initial request, it is Param-GroupsInRole. As such, the corresponding line in the script should be as follows:

$groupsParam = " param-GroupsInRole " # TODO: modify me
0

Thanks! Working perfectly!

0

One more issue I am having. I am trying to export some properties to a csv file in this script I am building IF($groupInfo.DirectoryType -eq 1){

    $ObjGroupInfo = New-Object System.Object
            $ObjGroupInfo | Add-Member -membertype Noteproperty -Name 'GroupName' -value $groupInfo.Name
            $ObjGroupInfo | Add-Member -MemberType Noteproperty -Name 'DirectoryType' -Value $groupInfo.DirectoryType
            $ObjGroupInfo | Add-Member -membertype Noteproperty -Name 'GUID' -value $groupInfo.GUID

            #Insert into container$
            $ArrangeInfo += $ObjGroupInfo

                }

elseif ($groupInfo.DirectoryType -eq 2){
    $groupInfo = $Context.BindToObjectByDN($dn)
            $ObjGroupInfo = New-Object System.Object
            $ObjGroupInfo | Add-Member -membertype Noteproperty -Name 'GroupName' -value $groupInfo.Name
            $ObjGroupInfo | Add-Member -MemberType Noteproperty -Name 'DirectoryType' -Value $groupInfo.DirectoryType
            $ObjGroupInfo | Add-Member -membertype Noteproperty -Name 'GUID' -value $groupInfo.GUID

First part dealing with AD groups works fine however when dealing with the Azure AD groups I am gettting two issues: The $groupInfo.Name Returns something like this in the csv file: CN=ADX_CloudTest\0AUID:866f290f64fb4eccbcdce2c704fd5e6d Also the $groupInfo.GUID Returns a number that is not the object ID What should I use to get the objectID and correct name for the Azure AD groups. I've tried $groupinfo.ObjectId and $groupinfo.displayname and both of those are empty.

0

Hello,

First of all, after binding to a group it is not required to use cmdlets to add members. It can be easily done using the built-in Add method. As for the property values, the behaviour is expected. The naming convention for cloud objects was changed by Microsoft last year and that is why you get what you get. The objectGUID on the other hand should just be obtained using another property name which is objectGUID.

Related questions

0 votes
1 answer

Occationally Service Desk staff need to clear a DNS record when a desktop has been reimaged but is keeping the same name as loses the ability to manage its original DNS ... running in ADAXES. Can I just install the applet on the ADAXES server using powershell?

asked Jan 17, 2023 by stevehalvorson (110 points)
0 votes
1 answer

I would like to add a parameter for country to a custom command. Since the country has to be entered correctly in order for Active Directory to accept it, I would like to ... ? I didn't find it in the documentation and the sample scripts didn't use parameters.

asked Jun 4, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

I have tried it using the Custom Commands Action "Add the user to a group", which only allows me to add the user to one group at a time, and can't use the multiple DNs that the ... I can't get it to work. Could you assist me in finding the best way to do this?

asked Jan 16 by dominik.stawny (160 points)
0 votes
1 answer

I have a custom command that prompts for a "reporter" for our ticketing system for enabling VPN accounts. Sometimes a technician will enable an account on behalf of another ... do I extract the email address of that object chosen as a parameter? Thank you.

asked Dec 10, 2019 by bjzielinski (70 points)
0 votes
2 answers

I've had a couple custom commands configured since 6/2023 and they've been working just fine up until recently (sometime within the past few weeks or so). Here's a general ... something obvious here. But I can't make sense of why this is suddenly an issue.

asked Mar 20 by msinger (110 points)
3,348 questions
3,049 answers
7,791 comments
545,054 users