Skip to content

Update-BylawRoleCache

SYNOPSIS

Refreshes the built-in role map that Modify -Role resolves role names against.

SYNTAX

Update-BylawRoleCache [[-OutputPath] <String>] [-PassThru] [-WhatIf]
 [-Confirm] [<CommonParameters>]

DESCRIPTION

Reads the built-in role definitions with Get-AzRoleDefinition (read-only) and writes a Bylaw role map of role names and GUIDs. Custom roles are not included: give them to Modify -Role by GUID or full role definition ID. Requires Az.Resources and a signed-in context (Connect-AzAccount). Compiling policies never needs Az (ADR-0022).

Built-in role GUIDs are the same in every tenant, so the map is portable.

By default the map is written to the user cache ($HOME/.bylaw/roles.json), which Build-Bylaw uses in preference to the map bundled with the module. The bundled map has every built-in role as of the module's release; refresh it for roles Azure has added since.

EXAMPLES

EXAMPLE 1

Connect-AzAccount
Update-BylawRoleCache

EXAMPLE 2

Update-BylawRoleCache -OutputPath ./roles.json

PARAMETERS

-OutputPath

Where to write the role map. Defaults to the user cache.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: (Get-BylawUserRoleCachePath)
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

Return a summary object (path, role count).

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS

NOTES