Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Intune RolesCannot bind argument to parameter 'RoleDefinitionId' because it is an empty string. #2771

Closed
hvdbrink opened this issue Jan 12, 2023 · 1 comment · Fixed by #2787 or #2800
Assignees
Labels
Bug Something isn't working Intune V1.23.111.1 Version 1.23.111.1

Comments

@hvdbrink
Copy link

Details of the scenario you tried and the problem that is occurring

In our configuration we have custom roles for specific teams that don't need Intune Admin rol. These are exported, but error on import and don't create them because of this

Verbose logs showing the problem

Cannot bind argument to parameter 'RoleDefinitionId' because it is an empty string. + CategoryInfo : InvalidData: (:) [], CimException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Update-MgDeviceManagementRoleDefinition
+ PSComputerName : localhost

Suggested solution to the issue

The DSC configuration that is used to reproduce the issue (as detailed as possible)

    IntuneRoleDefinition f9f4a1a9-27cd-4bf8-8b4c-269c5222b8e7
    {
        allowedResourceActions    = @("Microsoft.Intune_AppleDeviceSerialNumbers_Delete","Microsoft.Intune_AppleDeviceSerialNumbers_Update","Microsoft.Intune_EnrollmentProgramToken_Delete","Microsoft.Intune_AppleEnrollmentProfiles_Update","Microsoft.Intune_AppleDeviceSerialNumbers_Read","Microsoft.Intune_AppleEnrollmentProfiles_Assign","Microsoft.Intune_AppleDeviceSerialNumbers_Create","Microsoft.Intune_AppleEnrollmentProfiles_Read","Microsoft.Intune_AppleEnrollmentProfiles_Create");
        Credential                = $Credscredential;
        Description               = "With this Custom Role users can read, upload the devices Hash.";
        DisplayName               = "Enrollment Administrators";
        Ensure                    = "Present";
        Id                        = "e05c399b-97d7-4b97-95cd-668ab7b6ad20";
        IsBuiltIn                 = $False;
        notallowedResourceActions = @();
        roleScopeTagIds           = @("0");

The operating system the target node is running

OsName : Microsoft Windows 11 Pro
OsOperatingSystemSKU : 48
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage : en-US
OsMuiLanguages : {en-US, en-GB}

Version of the DSC module that was used ('dev' if using current dev branch)

1.23.111.1

@andikrueger andikrueger added Bug Something isn't working Intune V1.23.111.1 Version 1.23.111.1 labels Jan 16, 2023
@ykuijs ykuijs self-assigned this Jan 16, 2023
@ykuijs
Copy link
Member

ykuijs commented Jan 16, 2023

Code incorrectly handles the retrieval of the definition. If the ID does not exist, it does not also check the DisplayName and if also not found, return the NullReturn. The current if/else-statement does not allow that:

if($Id -match '^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$')
{
$getValue = Get-MgDeviceManagementRoleDefinition -RoleDefinitionId $id -ErrorAction SilentlyContinue
if($null -ne $getValue){
Write-Verbose -Message "Found something with id {$id}"
}
}
else
{
Write-Verbose -Message "Nothing with id {$id} was found"
$Filter = "displayName eq '$DisplayName'"
$getValue = Get-MgDeviceManagementRoleDefinition -Filter $Filter -ErrorAction SilentlyContinue
if($null -ne $getValue){
Write-Verbose -Message "Found something with displayname {$DisplayName}"
}
else{
Write-Verbose -Message "Nothing with displayname {$DisplayName} was found"
return $nullResult
}
}

The Else needs to get changed, so it also checks for the name and return the NullReturn when that also not exists.

Fix will be included my a next PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Intune V1.23.111.1 Version 1.23.111.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants