Skip to content

Commit

Permalink
Refactor: Get-BapEnvironmentSecurityRole
Browse files Browse the repository at this point in the history
  • Loading branch information
Splaxi committed Aug 22, 2024
1 parent 0f56cd1 commit dd9de53
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
48 changes: 21 additions & 27 deletions d365bap.tools/functions/Get-BapEnvironmentSecurityRole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
It will only list the Security Roles that are tied to the Environment.
Sample output:
Id Name IsManaged RoleType
-- ---- --------- --------
5a8c8098-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
1cbf96a1-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
PpacRoleId Name IsManaged PpacRoleType
---------- ---- --------- ------------
5a8c8098-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
1cbf96a1-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
d364ba1c-1bfb-eb11-94f0-0022482381ee Accounts Payable Admin True Environment
.EXAMPLE
Expand All @@ -46,30 +46,24 @@
It will only list the Security Roles that are tied to the Environment.
Sample output:
Id Name IsManaged RoleType
-- ---- --------- --------
5a8c8098-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
1cbf96a1-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
PpacRoleId Name IsManaged PpacRoleType
---------- ---- --------- ------------
5a8c8098-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
1cbf96a1-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
d364ba1c-1bfb-eb11-94f0-0022482381ee Accounts Payable Admin True Environment
.EXAMPLE
PS C:\> Get-BapEnvironmentSecurityRole -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -Name "*Administrator*"
PS C:\> Get-BapEnvironmentSecurityRole -EnvironmentId *uat* -Name "*Administrator*"
This will list all Security Roles, which matches the "*Administrator*" pattern, from the Dataverse environment.
It will only list the Security Roles that are tied to the Environment.
Sample output:
Id Name IsManaged RoleType
-- ---- --------- --------
5a8c8098-b933-eb11-a813-000d3a8e7ded (Deprecated) Marketing Realtime Feature True Environment
4758a2be-ccd8-ea11-a813-000d3a579805 App Profile Manager Administrator True Environment
PpacRoleId Name IsManaged PpacRoleType
---------- ---- --------- ------------
470a750f-d810-4ee7-a64a-ec002965c1ec Copilot for Service Administrator True Environment
5e4a9faa-b260-e611-8106-00155db8820b IoT - Administrator True Environment
947229e9-e868-45cf-a361-5635eaf35ee2 Microsoft Copilot Administrator True Environment
f7f90019-dc14-e911-816a-000d3a069ebd Omnichannel administrator True Environment
6beb51c1-0eda-e911-a81c-000d3af75d63 Productivity tools administrator True Environment
ebbb3fcb-fcd7-4bf8-9a48-7b5a9878e79e Sales Copilot Administrator True Environment
abce3b01-5697-4973-9d7d-fca48ca84445 Survey Services Administrator(Deprecat True Environment
abce3b01-5697-4973-9d7d-fca48ca84445 Survey Services Administrator(Deprecate… True Environment
63e389ae-bc55-ec11-8f8f-6045bd88b210 System Administrator True Environment
.EXAMPLE
Expand All @@ -79,8 +73,8 @@
It will only list the Security Roles that are tied to the Environment.
Sample output:
Id Name IsManaged RoleType
-- ---- --------- --------
PpacRoleId Name IsManaged PpacRoleType
---------- ---- --------- ------------
63e389ae-bc55-ec11-8f8f-6045bd88b210 System Administrator True Environment
.EXAMPLE
Expand All @@ -90,13 +84,13 @@
It will only list the Security Roles that are tied to the Environment.
Sample output:
Id Name IsManaged RoleType
-- ---- --------- --------
PpacRoleId Name IsManaged PpacRoleType
---------- ---- --------- ------------
0cdbad8e-72e7-406c-ae38-8c4406caea59 System Administrator False BusinessUnit
63e389ae-bc55-ec11-8f8f-6045bd88b210 System Administrator True Environment
.EXAMPLE
PS C:\> Get-BapEnvironmentSecurityRole -EnvironmentId eec2c11a-a4c7-4e1d-b8ed-f62acc9c74c6 -AsExcelOutput
PS C:\> Get-BapEnvironmentSecurityRole -EnvironmentId *uat* -AsExcelOutput
This will list all Security Roles from the Dataverse environment.
Will output all details into an Excel file, that will auto open on your machine.
Expand Down Expand Up @@ -157,10 +151,10 @@ function Get-BapEnvironmentSecurityRole {
if (-not ($roleObj.Name -like $Name)) { continue }
}

$tmp = $roleObj | Select-PSFObject -TypeName "D365Bap.Tools.Role" `
$tmp = $roleObj | Select-PSFObject -TypeName "D365Bap.Tools.PpacRole" `
-ExcludeProperty "@odata.etag" `
-Property "roleid as Id", *,
@{Name = "RoleType"; Expression = {
-Property "roleid as PpacRoleId", *,
@{Name = "PpacRoleType"; Expression = {
if ($null -eq $_.businessunitid._parentbusinessunitid_value) {
"Environment"
}
Expand All @@ -173,7 +167,7 @@ function Get-BapEnvironmentSecurityRole {
if ($IncludeAll) {
$resCol.Add($tmp)
}
elseif ($tmp.RoleType -eq "Environment") {
elseif ($tmp.PpacRoleType -eq "Environment") {
$resCol.Add($tmp)
}
}
Expand Down
8 changes: 4 additions & 4 deletions d365bap.tools/xml/d365bap.tools.Format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@
</TableControl>
</View>
<View>
<Name>D365Bap.Tools.Role</Name>
<Name>D365Bap.Tools.PpacRole</Name>
<ViewSelectedBy>
<TypeName>D365Bap.Tools.Role</TypeName>
<TypeName>D365Bap.Tools.PpacRole</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
Expand All @@ -493,7 +493,7 @@
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
<PropertyName>PpacRoleId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
Expand All @@ -502,7 +502,7 @@
<PropertyName>IsManaged</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>RoleType</PropertyName>
<PropertyName>PpacRoleType</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
Expand Down

0 comments on commit dd9de53

Please sign in to comment.