<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6043753706400514186</id><updated>2026-06-13T13:20:14.526-07:00</updated><category term="tfs 2010"/><category term="Windows Azure"/><category term="VS 2010"/><category term="PIM"/><category term="Privileged Identity Management"/><category term="azure"/><category term="azure active directory"/><category term="Azure AD"/><category term="build"/><category term="fiddler"/><category term="lab management"/><category term="test controller"/><category term="SQL Azure"/><category term="load test"/><category term="mfa"/><category term="mtm"/><category term="PowerShell"/><category term="Selenium"/><category term="UI automation"/><category term="build agent"/><category term="error"/><category term="msgraph"/><category term="sql server"/><category term="test"/><category term="testsettings"/><category term="Automated Build-Deploy-Test"/><category term="Conditional Access"/><category term="FiddlerCore"/><category term="JIT"/><category term="VS 2012"/><category term="aad"/><category term="build deploy test"/><category term="microsoft"/><category term="reports"/><category term="sql"/><category term="tfs 2010 api"/><category term="tfs 2012"/><category term="web driver"/><category term="%"/><category term="Cloud"/><category term="Coded UI"/><category term="Entra"/><category term="MSAL"/><category term="RBAC"/><category term="Testing"/><category term="VS 2015"/><category term="access denied"/><category term="azure table storage"/><category term="code coverage"/><category term="controller"/><category term="database project"/><category term="gated checkin"/><category term="https"/><category term="latency"/><category term="localhost"/><category term="mstest"/><category term="mvp"/><category term="percentile"/><category term="sqlcmd"/><category term="ssdt"/><category term="ssl"/><category term="ssrs"/><category term="tcm"/><category term="test agent"/><category term="tfs 11"/><category term="timeout"/><category term="visual studio unit test"/><category term="0x80070643"/><category term="90"/><category term="95"/><category term="99"/><category term="AADSTS65001"/><category term="ACS"/><category term="Agents"/><category term="Android"/><category term="Applying computer settings"/><category term="C#"/><category term="CloudTableQuery"/><category term="Custom Extensions"/><category term="Emulator"/><category term="Entity Framework"/><category term="GetAgentMachine"/><category term="HttpWatch"/><category term="IIS 7"/><category term="Keyset"/><category term="MSDN"/><category term="MVP Award Program"/><category term="MVP Monday"/><category term="Microsoft Graph"/><category term="OData"/><category term="PsExec"/><category term="QUOTED_IDENTIFIER"/><category term="Report"/><category term="SignalR"/><category term="TPU"/><category term="TableServiceContext"/><category term="Task"/><category term="TeamTest.targets"/><category term="Terms of Use"/><category term="VM"/><category term="WaitN"/><category term="Windows Azure Tools 1.4"/><category term="Windows Azure Tools 1.6"/><category term="Windows Phone 8"/><category term="Windows Store"/><category term="X509Certificate"/><category term="abort"/><category term="accessibility"/><category term="action recording and playback"/><category term="agent"/><category term="area"/><category term="associated automation"/><category term="automate"/><category term="azure code coverage"/><category term="bandwidth"/><category term="branching"/><category term="bug"/><category term="build.csdef"/><category term="client"/><category term="conversion"/><category term="copied"/><category term="count"/><category term="custom CA"/><category term="custom rule"/><category term="debug"/><category term="deploy"/><category term="deployment"/><category term="deployment directory"/><category term="deployment items"/><category term="dev fabric"/><category term="devices"/><category term="dir"/><category term="disk space"/><category term="dns"/><category term="e2e demo"/><category term="email"/><category term="extension method"/><category term="fail"/><category term="fatal error"/><category term="file"/><category term="folder"/><category term="folder tree"/><category term="generate"/><category term="hanged"/><category term="id"/><category term="iis express"/><category term="import test cases"/><category term="in progress"/><category term="interceptors"/><category term="intranet"/><category term="iteration"/><category term="kill connections"/><category term="labdefaulttemplate"/><category term="labeling"/><category term="localization"/><category term="manage test controllers"/><category term="master.dacpac"/><category term="mobile"/><category term="modem speed"/><category term="network"/><category term="newsequentialid"/><category term="not supported"/><category term="offline"/><category term="on premise"/><category term="out folder"/><category term="parallel tests"/><category term="pause"/><category term="performance test"/><category term="phone"/><category term="port"/><category term="portal"/><category term="private accessors"/><category term="project"/><category term="proxy"/><category term="publish"/><category term="quality"/><category term="query"/><category term="random"/><category term="reconcile workspace"/><category term="redirect"/><category term="remote"/><category term="replay"/><category term="resume"/><category term="save"/><category term="secure"/><category term="setvar"/><category term="sharepoint"/><category term="simulate"/><category term="slow debugging"/><category term="sql azure reporting service"/><category term="sql server 2012"/><category term="sql72027"/><category term="sqlcmdvar"/><category term="sqlpackage"/><category term="stuck"/><category term="subject"/><category term="team explorer"/><category term="tenant id"/><category term="tenant name"/><category term="test case"/><category term="test connection"/><category term="test explorer"/><category term="test logs"/><category term="testrunstorage"/><category term="tfs"/><category term="time"/><category term="tls"/><category term="traffic"/><category term="transactions"/><category term="trust"/><category term="trx"/><category term="udl"/><category term="unit tests"/><category term="user story"/><category term="user_interaction_required"/><category term="visual studio"/><category term="vmware"/><category term="warning"/><category term="web access"/><category term="web test"/><category term="website testing"/><category term="windows live"/><category term="windows service"/><category term="xaml"/><title type='text'>Anuj Chaudhary</title><subtitle type='html'>Software Engineering</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>124</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-2051560342004048890</id><published>2026-06-13T13:20:14.525-07:00</published><updated>2026-06-13T13:20:14.526-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Custom Extensions"/><category scheme="http://www.blogger.com/atom/ns#" term="Entra"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><title type='text'>Custom Extensions for Microsoft Entra Privileged Identity Management (PIM)</title><content type='html'>&lt;p&gt;&amp;nbsp;You can now bring your own business logic into the Microsoft Entra Privileged Identity Management workflow with Custom Extensions. Validate ticket numbers against your ticketing system, verify required training completion, collect and validate additional business context, or integrate with your own internal approval and compliance processes before granting Just-In-Time access.&lt;/p&gt;&lt;p&gt;Whether you&#39;re enforcing security requirements, meeting compliance obligations, or integrating with existing business systems, Custom Extensions provide a flexible and powerful way to tailor PIM workflows to your organization&#39;s unique needs. The possibilities are endless. See &lt;a href=&quot;https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/privileged-identity-management-custom-extensions&quot;&gt;https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/privileged-identity-management-custom-extensions&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;644&#39; height=&#39;536&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dwoGAqRnHxfoH8owv7D4aR3E2NOSTJJsOU-e0QI4vUsqp0VUDt_Mb2uNqGUEOqXzSn1ZxQ5RAN1N9njR5y5LA&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/2051560342004048890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2026/06/custom-extensions-for-microsoft-entra.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2051560342004048890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2051560342004048890'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2026/06/custom-extensions-for-microsoft-entra.html' title='Custom Extensions for Microsoft Entra Privileged Identity Management (PIM)'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-4003957119494963477</id><published>2026-04-06T09:20:00.000-07:00</published><updated>2026-04-06T09:21:28.310-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Conditional Access"/><category scheme="http://www.blogger.com/atom/ns#" term="Entra"/><category scheme="http://www.blogger.com/atom/ns#" term="mfa"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><title type='text'>Re-prompt for Multi-factor authentication on every Just-In-Time request using Privileged Identity Management</title><content type='html'>&lt;p&gt;&amp;nbsp;Microsoft Entra Privileged Identity Management now re‑prompts users for Multi‑Factor Authentication on every Just‑In‑Time activation request, even if they’ve already signed in with MFA.&lt;/p&gt;&lt;p&gt;See how we’re raising the bar for secure privileged access &lt;a href=&quot;https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/groups-role-settings#on-activation-require-microsoft-entra-conditional-access-authentication-context&quot;&gt;https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/groups-role-settings#on-activation-require-microsoft-entra-conditional-access-authentication-context&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;684&#39; height=&#39;569&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dwSmK6oIgZhdlMsWLZ6zreX2q-499p6CVcdGUfCaqqhBjRmeH_0o5ZndpxK0FPG_InWbcagZPLf9xgU4NnqLg&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/4003957119494963477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2026/04/re-prompt-for-multi-factor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/4003957119494963477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/4003957119494963477'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2026/04/re-prompt-for-multi-factor.html' title='Re-prompt for Multi-factor authentication on every Just-In-Time request using Privileged Identity Management'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-4212444290206400336</id><published>2024-12-03T15:34:00.000-08:00</published><updated>2024-12-03T15:34:33.877-08:00</updated><title type='text'>Connect to Azure PowerShell with Conditional Access Authentical Context</title><content type='html'>&lt;p&gt;You can require users who are eligible for a role to satisfy Conditional Access policy requirements. For example, you can require users to use a specific authentication method enforced through Authentication Strengths, elevate the role from an Intune-compliant device, and comply with terms of use. Learn more here &lt;a href=&quot;https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/pim-resource-roles-configure-role-settings#on-activation-require-microsoft-entra-conditional-access-authentication-context&quot;&gt;https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/pim-resource-roles-configure-role-settings#on-activation-require-microsoft-entra-conditional-access-authentication-context&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;However, once this is enabled, users cannot activate their eligible roles using Azure PowerShell since there is no way to login to Azure PowerShell with authentication context.&amp;nbsp;&lt;/p&gt;&lt;p&gt;To solve this issue, you can first acquire a token with authentication context and use it to connect to Azure PowerShell.&lt;/p&gt;&lt;p&gt;First, remember to disconnect so an older token is not used by Azure PowerShell&lt;/p&gt;&lt;p&gt;DisConnect-AzAccount&lt;/p&gt;&lt;p&gt;Now, acquire a token with authentication context. Replace c1 with the id of your authentication context. Learn more here&amp;nbsp;&lt;a href=&quot;https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-conditional-access-cloud-apps#configure-authentication-contexts&quot;&gt;https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-conditional-access-cloud-apps#configure-authentication-contexts&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;$MsResponse = Get-MSALToken -Scopes @(&quot;https://management.core.windows.net//.default openid profile offline_access&quot;) -ClientId &quot;04b07795-8ddb-461a-bbee-02f9e1bf7b46&quot; -RedirectUri &quot;http://localhost:8400/&quot; -Authority &quot;https://login.microsoftonline.com/common&quot; -Interactive -ExtraQueryParameters @{claims=&#39;{&quot;access_token&quot;:{&quot;xms_cc&quot;:{&quot;values&quot;:[&quot;CP1&quot;]},&quot;acrs&quot;:{&quot;essential&quot;:true, &quot;value&quot;:&quot;c1&quot;}}}&#39;}&amp;nbsp;&lt;/p&gt;&lt;p&gt;Connect to Azure PowerShell with the acquired access token and provide the upn of the user if prompted for AccountId&lt;/p&gt;&lt;p&gt;Connect-AzAccount -AccessToken $MsResponse.AccessToken&amp;nbsp;&lt;/p&gt;&lt;p&gt;Activate your eligible role. Replace $scope, $role and $principal with your values. Learn more here&amp;nbsp;&lt;a href=&quot;https://learn.microsoft.com/en-us/powershell/module/az.resources/new-azroleassignmentschedulerequest?view=azps-13.0.0#example-3-activate-a-new-role-assignment-schedule-request-as-user&quot;&gt;https://learn.microsoft.com/en-us/powershell/module/az.resources/new-azroleassignmentschedulerequest?view=azps-13.0.0#example-3-activate-a-new-role-assignment-schedule-request-as-user&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;$guid = (New-Guid).Guid&amp;nbsp;&lt;/p&gt;&lt;p&gt;$startTime = Get-Date -Format o&amp;nbsp;&lt;/p&gt;&lt;p&gt;$scope = &quot;/subscriptions/c896b064-0cd9-49d5-a7df-c82df3dc60f3&quot;&amp;nbsp;&lt;/p&gt;&lt;p&gt;$role = &quot;/subscriptions/c896b064-0cd9-49d5-a7df-c82df3dc60f3/providers/Microsoft.Authorization/roleDefinitions/18d7d88d-d35e-4fb5-a5c3-7773c20a72d9&quot;&amp;nbsp;&lt;/p&gt;&lt;p&gt;$principal = &quot;290190c3-1372-4076-99a5-9efa5a1a18e3&quot;&amp;nbsp;&lt;/p&gt;&lt;p&gt;New-AzRoleAssignmentScheduleRequest -Name $guid -Scope $scope -ExpirationDuration PT1H -ExpirationType AfterDuration -PrincipalId $principal -RequestType SelfActivate -RoleDefinitionId $role -ScheduleInfoStartDateTime $startTime -Justification &quot;test&quot;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/4212444290206400336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2024/12/connect-to-azure-powershell-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/4212444290206400336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/4212444290206400336'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2024/12/connect-to-azure-powershell-with.html' title='Connect to Azure PowerShell with Conditional Access Authentical Context'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-1152232213056864974</id><published>2020-09-30T19:12:00.002-07:00</published><updated>2020-09-30T19:22:32.007-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure AD"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><title type='text'>Azure AD PowerShell for Azure Resources in PIM</title><content type='html'>Have you wondered how to user&amp;nbsp;Azure AD PowerShell for Azure Resources in PIM. This is a little tricky since the id&#39;s in OData do not support slashes but the id&#39;s for Azure resources contains slashes. Hence the id for these resources are mapped to a GUID in Graph.&lt;div&gt;To query the azure resources in Graph, you will need to pass an ExternalId filter and the rest should be straight forward.&lt;/div&gt;&lt;div&gt;Below is an example of adding a user as Eligible Owner on a subscription.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The pre-requisite is that you have already installed Azure AD Preview PowerShell by following these steps &lt;a href=&quot;https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0&quot;&gt;https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Connect-AzureAD&lt;/div&gt;&lt;div&gt;$resource = Get-AzureADMSPrivilegedResource -Provider azureResources -Filter &quot;ExternalId eq &#39;/subscriptions/38ab2ccc-3747-4567-b36b-9478f5602f0d&#39;&quot;&lt;/div&gt;&lt;div&gt;$roleDefinition = Get-AzureADMSPrivilegedRoleDefinition -ProviderId azureResources -ResourceId $resource.Id -Filter &quot;DisplayName eq &#39;Owner&#39;&quot;&lt;/div&gt;&lt;div&gt;$subject = Get-AzureADUser -Filter &quot;userPrincipalName eq &#39;upn&#39;&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;$schedule = New-Object Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule&lt;/div&gt;&lt;div&gt;$schedule.Type = &quot;Once&quot;&lt;/div&gt;&lt;div&gt;$schedule.StartDateTime = (Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;)&lt;/div&gt;&lt;div&gt;$schedule.EndDateTime = (Get-Date).AddDays(30).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId azureResources -Schedule $schedule -ResourceId $resource.Id -RoleDefinitionId $roleDefinition.Id -SubjectId $subject.ObjectId -AssignmentState &quot;Eligible&quot; -Type &quot;AdminAdd&quot; -Reason &quot;Test&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/1152232213056864974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2020/09/azure-ad-powershell-for-azure-resources.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/1152232213056864974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/1152232213056864974'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2020/09/azure-ad-powershell-for-azure-resources.html' title='Azure AD PowerShell for Azure Resources in PIM'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-7147600037169035706</id><published>2020-02-14T18:44:00.003-08:00</published><updated>2020-09-30T19:22:56.146-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure AD"/><category scheme="http://www.blogger.com/atom/ns#" term="mfa"/><category scheme="http://www.blogger.com/atom/ns#" term="MSAL"/><category scheme="http://www.blogger.com/atom/ns#" term="msgraph"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><title type='text'>Connect to Azure AD PowerShell with MFA</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Sometimes you might want to connect to Azure AD PowerShell
with MFA but there is no way for the PowerShell to prompt you for MFA unless
you have MFA enforced on the account.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The scenario which I had was calling a cmdlet for Privileged
Identity Management where I was activating a role which requires MFA &lt;a href=&quot;https://docs.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0-preview#privileged_role_management&quot;&gt;https://docs.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0-preview#privileged_role_management&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The solution is to get an access token with MFA and pass the
token while connecting to PowerShell.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The pre-requisite is that you have already installed Azure
AD Preview PowerShell by following these steps &lt;a href=&quot;https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0&quot;&gt;https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;# Install msal.ps&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;if(!(Get-Module | Where-Object {$_.Name -eq &#39;PowerShellGet&#39; -and $_.Version -ge &#39;2.2.4.1&#39;})) { Install-Module PowerShellGet -Force }&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;if(!(Get-Package msal.ps)) { Install-Package msal.ps }&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;# Get token for MS Graph by prompting for MFA&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$MsResponse = Get-MSALToken -Scopes @(&quot;https://graph.microsoft.com/.default&quot;) -ClientId &quot;1b730954-1685-4b74-9bfd-dac224a7b894&quot; -RedirectUri &quot;urn:ietf:wg:oauth:2.0:oob&quot; -Authority &quot;https://login.microsoftonline.com/common&quot; -Interactive -ExtraQueryParameters @{claims=&#39;{&quot;access_token&quot; : {&quot;amr&quot;: { &quot;values&quot;: [&quot;mfa&quot;] }}}&#39;}&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;# Get token for AAD Graph&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$AadResponse = Get-MSALToken -Scopes @(&quot;https://graph.windows.net/.default&quot;) -ClientId &quot;1b730954-1685-4b74-9bfd-dac224a7b894&quot; -RedirectUri &quot;urn:ietf:wg:oauth:2.0:oob&quot; -Authority &quot;https://login.microsoftonline.com/common&quot;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;Connect-AzureAD -AadAccessToken $AadResponse.AccessToken -MsAccessToken $MsResponse.AccessToken -AccountId: &quot;upn&quot; -tenantId: &quot;tenantId&quot;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;# Call cmdlet which requires MFA&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$resource = Get-AzureADMSPrivilegedResource -ProviderId AadRoles&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$roleDefinition = Get-AzureADMSPrivilegedRoleDefinition&amp;nbsp; -ProviderId AadRoles -ResourceId $resource.Id -Filter &quot;DisplayName eq &#39;Global Administrator&#39;&quot;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$subject = Get-AzureADUser -Filter &quot;userPrincipalName eq &#39;upn&#39;&quot;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$schedule = New-Object Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$schedule.Type = &quot;Once&quot;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$schedule.Duration=&quot;PT1H&quot;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;$schedule.StartDateTime = (Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;)&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId AadRoles -Schedule $schedule -ResourceId $resource.Id -RoleDefinitionId $roleDefinition.Id -SubjectId $subject.ObjectId -AssignmentState &quot;Active&quot; -Type &quot;UserAdd&quot; -Reason &quot;Test&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/7147600037169035706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2020/02/connect-to-azure-ad-powershell-with-mfa.html#comment-form' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7147600037169035706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7147600037169035706'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2020/02/connect-to-azure-ad-powershell-with-mfa.html' title='Connect to Azure AD PowerShell with MFA'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-7888450633766672363</id><published>2019-08-02T11:14:00.006-07:00</published><updated>2020-09-15T18:52:25.137-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Conditional Access"/><category scheme="http://www.blogger.com/atom/ns#" term="mfa"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Graph"/><category scheme="http://www.blogger.com/atom/ns#" term="msgraph"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><title type='text'>Handle Conditional Access challenge for Privileged Identity Management on Microsoft Graph</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Privileged Identity Management (PIM) for Azure resources api’s&amp;nbsp;are available on
Microsoft Graph (MSGraph) so that developers can automate the PIM operations
like activation, assignment, etc. To learn more, see &lt;a href=&quot;http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html&quot;&gt;http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Some organizations enable conditional policies like Multi factor
authentication (MFA) for accessing any Azure resources. When users go to PIM
through Azure Portal, they are prompted for MFA while logging into the Azure
Portal. When they access the PIM UI, everything works since they have already
performed MFA.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
However, if the users are accessing PIM api’s for Azure
resources through MSGraph, they might not be prompted for MFA on login since no
conditional access policy might be enabled for MSGraph. When a PIM api is
called, it fails with 400 Bad Request invalid_grant error&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 10pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;/code&gt;since
a conditional access policy is not met for Azure resources. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Example:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;HTTP/1.1 400 Bad Request&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &quot;error&quot;: {&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;code&quot;: &quot;invalid_grant&quot;,&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;message&quot;: &quot;{\&quot;Name\&quot;:\&quot;MsalUiRequiredException\&quot;,\&quot;Message\&quot;:\&quot;AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access &#39;797f4846-ba00-4fd7-ba43-dac1f8f63013&#39;.\\r\\nTrace ID: 7bdbe148-89e6-4493-a150-93dac7a06c00\\r\\nCorrelation ID: ff221ee5-ebb9-42d0-8f70-dbffde1b2104\\r\\nTimestamp: 2020-09-16 01:16:03Z\&quot;,\&quot;Claims\&quot;:\&quot;{\\\&quot;access_token\\\&quot;:{\\\&quot;capolids\\\&quot;:{\\\&quot;essential\\\&quot;:true,\\\&quot;values\\\&quot;:[\\\&quot;051744ca-6abe-4095-b526-14a7f4033309\\\&quot;]}}}\&quot;}&quot;,&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;innerError&quot;: {&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;date&quot;: &quot;2020-09-16T01:16:03&quot;,&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;request-id&quot;: &quot;82cd21d1-6413-4512-a2d1-fa1d0a3c5826&quot;,&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;client-request-id&quot;: &quot;82cd21d1-6413-4512-a2d1-fa1d0a3c5826&quot;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;}&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To handle this, the user needs to catch the error, get the claims challenge and send in a login request with claims challenge as an extra query string parameter.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To learn more, see &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/develop/conditional-access-dev-guide#scenario-app-performing-the-on-behalf-of-flow&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/develop/conditional-access-dev-guide#scenario-app-performing-the-on-behalf-of-flow&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span&gt;Below is a PowerShell sample which showcases on
how to handle the &lt;/span&gt;&lt;span&gt;conditional&lt;/span&gt;&lt;span&gt;&amp;nbsp;access challenge when calling PIM api&#39;s on MSGraph.&amp;nbsp;Just save this as a .ps1 file and run it with PowerShell.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;Sceenshot&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ms_3bLke8shefXjfzzzt07BO-M0uPikIBjb0CqOc9F71kx-qGrEySJzFRp5aYTYIPSlfzt1KrtOrr3_hE6TF41zzsHeGXCiZPp88GvyaoKMfXY4qdtExeGTsuppAaTVu8jI6WnU4ZQ85/s1600/CA.PNG&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;183&quot; data-original-width=&quot;834&quot; height=&quot;139&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ms_3bLke8shefXjfzzzt07BO-M0uPikIBjb0CqOc9F71kx-qGrEySJzFRp5aYTYIPSlfzt1KrtOrr3_hE6TF41zzsHeGXCiZPp88GvyaoKMfXY4qdtExeGTsuppAaTVu8jI6WnU4ZQ85/s640/CA.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;b&gt;&lt;u&gt;Source code&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span face=&quot;&amp;quot;calibri&amp;quot; , sans-serif&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;#Acquire AAD token&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;function AcquireToken($claims){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $clientID = &quot;dabc52c4-106b-4179-9df2-2f791f44ba14&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $redirectUri = &quot;https://pimmsgraph&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $authority = &quot;https://login.microsoftonline.com/common&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($claims -ne $null)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $authResult = Get-MSALToken -Scopes @(&quot;https://graph.microsoft.com/.default&quot;) -ClientId $ClientID -RedirectUri $redirectUri -Authority $authority -Interactive -ExtraQueryParameters @{claims=$claims}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set-Variable -Name mfaDone -Value $true -Scope Global&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $authResult = Get-MSALToken -Scopes @(&quot;https://graph.microsoft.com/.default&quot;) -ClientId $ClientID -RedirectUri $redirectUri -Authority $authority -Interactive&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($authResult -ne $null)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;User logged in successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; Set-Variable -Name headerParams -Value @{&#39;Authorization&#39;=&quot;$($authResult.AccessTokenType) $($authResult.AccessToken)&quot;} -Scope Global&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; Set-Variable -Name assigneeId -Value $authResult.UserInfo.UniqueId -Scope Global&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;#List resources&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;function ListResources(){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;resources?`$filter=(type+eq+&#39;subscription&#39;)&quot;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Write-Host $url&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($resource in $resources.value)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = ++$i&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceId =&amp;nbsp; $resource.id&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceName =&amp;nbsp; $resource.displayName&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceType =&amp;nbsp; $resource.type&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;return $obj&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;#Disaplay resources&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;function DisplayResources(){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap Id,ResourceName,ResourceType&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;############################################################################################################################################################################&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;$global:serviceRoot = &quot;https://graph.microsoft.com/beta/privilegedAccess/azureResources/&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;$global:MSGraphRoot = &quot;https://graph.microsoft.com/v1.0/&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;$global:headerParams = &quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;$global:assigneeId = &quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;$global:mfaDone = $false;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;# Install msal.ps&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;if(!(Get-Module | Where-Object {$_.Name -eq &#39;PowerShellGet&#39; -and $_.Version -ge &#39;2.2.4.1&#39;})) { Install-Module PowerShellGet -Force }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;if(!(Get-Package msal.ps)) { Install-Package msal.ps }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;$Authed = AcquireToken $global:clientID $global:redirectUri $global:resourceAppIdURI $global:authority $false&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;if ($Authed -eq $false)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;try&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; DisplayResources&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;catch&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($err.Contains(&quot;invalid_grant&quot;))&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $errorObject = ConvertFrom-Json $err&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $message = ConvertFrom-Json $errorObject.error.message&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $claims = $message.claims&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Prompting the user again since since a conditional access policy is enabled...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AcquireToken $claims&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DisplayResources&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $err -ForegroundColor Red&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 14.6667px;&quot;&gt;Write-Host &quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/7888450633766672363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2019/08/handle-conditional-access-challenge-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7888450633766672363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7888450633766672363'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2019/08/handle-conditional-access-challenge-for.html' title='Handle Conditional Access challenge for Privileged Identity Management on Microsoft Graph'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ms_3bLke8shefXjfzzzt07BO-M0uPikIBjb0CqOc9F71kx-qGrEySJzFRp5aYTYIPSlfzt1KrtOrr3_hE6TF41zzsHeGXCiZPp88GvyaoKMfXY4qdtExeGTsuppAaTVu8jI6WnU4ZQ85/s72-c/CA.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-3350133108276861953</id><published>2019-06-20T13:55:00.000-07:00</published><updated>2019-06-20T13:55:32.313-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="interceptors"/><category scheme="http://www.blogger.com/atom/ns#" term="query"/><category scheme="http://www.blogger.com/atom/ns#" term="random"/><category scheme="http://www.blogger.com/atom/ns#" term="sql"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Azure"/><title type='text'>SQL interceptors</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
SQL interceptors are a way to apply filtering by tenant for
securing multi-tenant applications. Here is a good read on it &lt;a href=&quot;http://xabikos.com/2014/11/18/Create-a-multitenant-application-with-Entity-Framework-Code-First-Part-2/&quot;&gt;http://xabikos.com/2014/11/18/Create-a-multitenant-application-with-Entity-Framework-Code-First-Part-2/&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
However, you need to be careful with it since they modify
your query at runtime.&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Specifically, DbExpressionBuilder.Bind(databaseExpression) in
the interceptor causes a random variable to be created which creates a random
query text for the same query on every reinitialize which is generally a
recycle on the VM where the application is running.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
This puts unnecessary unnecessary pressure on QDS (Query Data Store).&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Also, if you force a query plan for a specific query hash,
a new query hash will be generated the next time so the forced plan will not work.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To fix this, make sure to bind it with a specific variable
name like DbExpressionBuilder.BindAs(databaseExpression, &quot;Filter&quot;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/3350133108276861953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2019/06/sql-interceptors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3350133108276861953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3350133108276861953'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2019/06/sql-interceptors.html' title='SQL interceptors'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-5457154575047197605</id><published>2019-06-20T13:49:00.000-07:00</published><updated>2019-06-20T13:58:14.761-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Azure"/><category scheme="http://www.blogger.com/atom/ns#" term="timeout"/><title type='text'>Troubleshooting SQL Azure issues</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Query Performance Insights&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/h1&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The most common place to look for SQL Azure issues is Query
Performance Insights on Azure portal &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/sql-database/sql-database-query-performance&quot;&gt;https://docs.microsoft.com/en-us/azure/sql-database/sql-database-query-performance&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;h1&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Troubleshoot SQL query timeouts&lt;/span&gt;&lt;/h1&gt;
&lt;h1&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/h1&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
There are various Data Management Views (DMV’s) created by
SQL Azure team &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/sql-database/sql-database-monitoring-with-dmvs&quot;&gt;https://docs.microsoft.com/en-us/azure/sql-database/sql-database-monitoring-with-dmvs&lt;/a&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I tweaked them a little below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Find query hashes which are timing out&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Look for Aborted_Execution_Count column.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;--
Top 15 CPU consuming queries by query hash&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;--
note that a query&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;hash can have many
query id if not parameterized or not parameterized properly&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;--
it grabs a sample query text by min&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;WITH
AggregatedCPU AS (SELECT q.query_hash, p.query_plan_hash, SUM(count_executions
* avg_cpu_time / 1000.0) AS total_cpu_millisec, SUM(count_executions *
avg_cpu_time / 1000.0)/ SUM(count_executions) AS avg_cpu_millisec,
MAX(rs.max_cpu_time / 1000.00) AS max_cpu_millisec, MAX(max_logical_io_reads)
max_logical_reads, COUNT(DISTINCT p.plan_id) AS number_of_distinct_plans,
COUNT(DISTINCT p.query_id) AS number_of_distinct_query_ids, SUM(CASE WHEN rs.execution_type_desc=&#39;Aborted&#39;
THEN count_executions ELSE 0 END) AS Aborted_Execution_Count, SUM(CASE WHEN
rs.execution_type_desc=&#39;Regular&#39; THEN count_executions ELSE 0 END) AS
Regular_Execution_Count, SUM(CASE WHEN rs.execution_type_desc=&#39;Exception&#39; THEN
count_executions ELSE 0 END) AS Exception_Execution_Count,
SUM(count_executions) AS total_executions, MIN(qt.query_sql_text) AS
sampled_query_text&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FROM
sys.query_store_query_text AS qt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_query AS q ON qt.query_text_id=q.query_text_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_plan AS p ON q.query_id=p.query_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_runtime_stats AS rs ON rs.plan_id=p.plan_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_runtime_stats_interval AS rsi ON
rsi.runtime_stats_interval_id=rs.runtime_stats_interval_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WHERE
rs.execution_type_desc IN (&#39;Regular&#39;, &#39;Aborted&#39;, &#39;Exception&#39;)AND
rsi.start_time&amp;gt;=DATEADD(HOUR, -24, GETUTCDATE())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GROUP BY q.query_hash,
p.query_plan_hash), OrderedCPU AS (SELECT query_hash, query_plan_hash,
total_cpu_millisec, avg_cpu_millisec, max_cpu_millisec, max_logical_reads,
number_of_distinct_plans, number_of_distinct_query_ids, total_executions,
Aborted_Execution_Count, Regular_Execution_Count, Exception_Execution_Count,
sampled_query_text, ROW_NUMBER() OVER (ORDER BY total_cpu_millisec DESC,
query_hash ASC) AS RN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;FROM AggregatedCPU)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;SELECT
OD.query_hash, OD.query_plan_hash, OD.total_cpu_millisec, OD.avg_cpu_millisec,
OD.max_cpu_millisec, OD.max_logical_reads, OD.number_of_distinct_plans,
OD.number_of_distinct_query_ids, OD.total_executions, OD.Aborted_Execution_Count,
OD.Regular_Execution_Count, OD.Exception_Execution_Count,
OD.sampled_query_text, OD.RN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;FROM
OrderedCPU AS OD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;WHERE
OD.RN&amp;lt;=15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;ORDER
BY total_cpu_millisec DESC;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Compare query plans for timing out query hash&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
Look for avg_cpu_millisec column. The query plan with lower
value is better. If there is only one query plan, then you need to change your
query to use the right indexes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;--
Top 15 CPU consuming queries by query hash&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;--
note that a query&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;hash can have many
query id if not parameterized or not parameterized properly&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;--
it grabs a sample query text by min&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;WITH
AggregatedCPU AS (SELECT q.query_hash, p.query_plan_hash, SUM(count_executions
* avg_cpu_time / 1000.0) AS total_cpu_millisec, SUM(count_executions *
avg_cpu_time / 1000.0)/ SUM(count_executions) AS avg_cpu_millisec,
MAX(rs.max_cpu_time / 1000.00) AS max_cpu_millisec, MAX(max_logical_io_reads)
max_logical_reads, COUNT(DISTINCT p.plan_id) AS number_of_distinct_plans,
COUNT(DISTINCT p.query_id) AS number_of_distinct_query_ids, SUM(CASE WHEN
rs.execution_type_desc=&#39;Aborted&#39; THEN count_executions ELSE 0 END) AS
Aborted_Execution_Count, SUM(CASE WHEN rs.execution_type_desc=&#39;Regular&#39; THEN
count_executions ELSE 0 END) AS Regular_Execution_Count, SUM(CASE WHEN rs.execution_type_desc=&#39;Exception&#39;
THEN count_executions ELSE 0 END) AS Exception_Execution_Count,
SUM(count_executions) AS total_executions, MIN(qt.query_sql_text) AS
sampled_query_text&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FROM
sys.query_store_query_text AS qt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;JOIN sys.query_store_query AS q ON
qt.query_text_id=q.query_text_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_plan AS p ON q.query_id=p.query_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_runtime_stats AS rs ON rs.plan_id=p.plan_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;JOIN
sys.query_store_runtime_stats_interval AS rsi ON
rsi.runtime_stats_interval_id=rs.runtime_stats_interval_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WHERE
rs.execution_type_desc IN (&#39;Regular&#39;, &#39;Aborted&#39;, &#39;Exception&#39;)AND
rsi.start_time&amp;gt;=DATEADD(HOUR, -24, GETUTCDATE())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GROUP BY q.query_hash,
p.query_plan_hash), OrderedCPU AS (SELECT query_hash, query_plan_hash,
total_cpu_millisec, avg_cpu_millisec, max_cpu_millisec, max_logical_reads,
number_of_distinct_plans, number_of_distinct_query_ids, total_executions,
Aborted_Execution_Count, Regular_Execution_Count, Exception_Execution_Count,
sampled_query_text, ROW_NUMBER() OVER (ORDER BY total_cpu_millisec DESC,
query_hash ASC) AS RN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;FROM AggregatedCPU)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;SELECT
OD.query_hash, OD.query_plan_hash, OD.total_cpu_millisec, OD.avg_cpu_millisec,
OD.max_cpu_millisec, OD.max_logical_reads, OD.number_of_distinct_plans,
OD.number_of_distinct_query_ids, OD.total_executions, OD.Aborted_Execution_Count,
OD.Regular_Execution_Count, OD.Exception_Execution_Count,
OD.sampled_query_text, OD.RN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;FROM
OrderedCPU AS OD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;WHERE
OD.query_hash= query_hash&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;ORDER
BY total_cpu_millisec DESC;&lt;/span&gt;&lt;/i&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Analyze the query plan&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
Once you have the query plan hash for which the query is
timing out, you can view and analyze it by running this query&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;select
qsq.query_hash&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsp.query_plan_hash&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsq.query_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsp.plan_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsq.query_text_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsq.is_internal_query&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsrts.first_execution_time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsrts.last_execution_time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsqt.query_sql_text&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,CAST(qsp.query_plan AS XML)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;,qsrts.count_executions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;from&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;[sys].[query_store_runtime_stats] qsrts&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;inner join [sys].[query_store_plan] qsp on
qsrts.plan_id = qsp.plan_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;inner join [sys].[query_store_query] qsq on
qsp.query_id = qsq.query_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;inner join [sys].[query_store_query_text] qsqt
on qsq.query_text_id = qsqt.query_text_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;where&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;qsp.query_plan_hash = query_plan_hash&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Force a query plan&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
If you have multiple query plans for a query, where one
query plan is performing far better than the other, you can force that query
plan. You need to analyze both query plans before you decide a force a specific
plan so that it will work for both large and small volume of data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-query-store-force-plan-transact-sql?view=sql-server-2017&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;select
* from sys.query_store_plan where is_forced_plan=1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i&gt;&lt;span style=&quot;background: lightgrey; mso-highlight: lightgrey;&quot;&gt;EXEC
sp_query_store_force_plan query_id, plan_id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/5457154575047197605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2019/06/troubleshooting-sql-azure-issues.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/5457154575047197605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/5457154575047197605'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2019/06/troubleshooting-sql-azure-issues.html' title='Troubleshooting SQL Azure issues'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-6637843800172964300</id><published>2018-10-25T18:00:00.000-07:00</published><updated>2018-10-25T18:00:51.129-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MSDN"/><title type='text'>MSDN blog posts</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
My MSDN blog posts have been moved here.&lt;br /&gt;
Please see the list of redirections below:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;PowerShell sample for Privileged Identity Management (PIM) for Azure AD Roles&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;a href=&quot;https://blogs.msdn.microsoft.com/anujchaudhary/2018/06/07/powershell-sample-for-privileged-identity-management-pim-for-azure-ad-roles/&quot;&gt;https://blogs.msdn.microsoft.com/anujchaudhary/2018/06/07/powershell-sample-for-privileged-identity-management-pim-for-azure-ad-roles/&lt;/a&gt; &lt;b&gt;&amp;gt;&lt;/b&gt; &lt;a href=&quot;http://www.anujchaudhary.com/2018/06/powershell-sample-for-privileged_7.html&quot;&gt;http://www.anujchaudhary.com/2018/06/powershell-sample-for-privileged_7.html&lt;/a&gt;&lt;/div&gt;
&lt;br style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot; /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;PowerShell sample for Privileged Identity Management (PIM) for Azure Resources&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;a href=&quot;https://blogs.msdn.microsoft.com/anujchaudhary/2018/02/07/powershell-sample-for-privileged-identity-management-pim-for-azure-resources/&quot;&gt;https://blogs.msdn.microsoft.com/anujchaudhary/2018/02/07/powershell-sample-for-privileged-identity-management-pim-for-azure-resources/&lt;/a&gt; &lt;b&gt;&amp;gt;&lt;/b&gt; &lt;a href=&quot;http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html&quot;&gt;http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html&lt;/a&gt;&lt;/div&gt;
&lt;br style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot; /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;Securing Azure resources with Privileged Identity Management&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;a href=&quot;https://blogs.msdn.microsoft.com/anujchaudhary/2018/04/12/securing-azure-resources-with-privileged-identity-management/&quot;&gt;https://blogs.msdn.microsoft.com/anujchaudhary/2018/04/12/securing-azure-resources-with-privileged-identity-management/&lt;/a&gt; &lt;b&gt;&amp;gt;&lt;/b&gt; &lt;a href=&quot;http://www.anujchaudhary.com/2018/04/securing-azure-resources-with.html&quot;&gt;http://www.anujchaudhary.com/2018/04/securing-azure-resources-with.html&lt;/a&gt;&lt;/div&gt;
&lt;br style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot; /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;/div&gt;
&lt;b&gt;Windows Azure: Automated UI testing using the power of cloud&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;color: #222222; font-family: &amp;quot;Segoe UI&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, Verdana; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt;
&lt;a href=&quot;http://blogs.msdn.com/b/anujchaudhary/archive/2012/11/02/windows-azure-automated-ui-testing-using-the-power-of-cloud.aspx&quot;&gt;http://blogs.msdn.com/b/anujchaudhary/archive/2012/11/02/windows-azure-automated-ui-testing-using-the-power-of-cloud.aspx&lt;/a&gt; &lt;b&gt;&amp;gt;&lt;/b&gt; &lt;a href=&quot;http://www.anujchaudhary.com/2012/11/windows-azure-automated-ui-testing.html&quot;&gt;http://www.anujchaudhary.com/2012/11/windows-azure-automated-ui-testing.html&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/6637843800172964300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/10/msdn-blog-posts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/6637843800172964300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/6637843800172964300'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/10/msdn-blog-posts.html' title='MSDN blog posts'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-6135518499364136950</id><published>2018-07-18T08:28:00.000-07:00</published><updated>2018-07-18T08:28:41.592-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="client"/><category scheme="http://www.blogger.com/atom/ns#" term="OData"/><category scheme="http://www.blogger.com/atom/ns#" term="VS 2015"/><title type='text'>OData Client Code Generator for VS 2015</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I had been using&amp;nbsp;OData Client Code Generator for VS 2015 to generate client for my OData service.&lt;br /&gt;
See &lt;a href=&quot;https://blogs.msdn.microsoft.com/odatateam/2014/03/11/tutorial-sample-how-to-use-odata-client-code-generator-to-generate-client-side-proxy-class/&quot;&gt;https://blogs.msdn.microsoft.com/odatateam/2014/03/11/tutorial-sample-how-to-use-odata-client-code-generator-to-generate-client-side-proxy-class/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The extension used to be deployed in my VS 2015 but recently it disappeared.&lt;br /&gt;
When I tried to search for it in Extension and Updates, it would show a newer version of OData Client Code Generator which won&#39;t work for VS 2015.&lt;br /&gt;
&lt;br /&gt;
After looking around, I found the older version here&amp;nbsp;&lt;a href=&quot;https://github.com/OData/lab/blob/Tools/Tools/ODataT4ItemTemplate.2.4.0.vsix&quot;&gt;https://github.com/OData/lab/blob/Tools/Tools/ODataT4ItemTemplate.2.4.0.vsix&lt;/a&gt;&lt;br /&gt;
You can download and install it from here and restart VS 2015.&lt;br /&gt;
&lt;br /&gt;
After that, you should be able to generate the OData client as usual in VS 2015.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/6135518499364136950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/07/odata-client-code-generator-for-vs-2015.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/6135518499364136950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/6135518499364136950'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/07/odata-client-code-generator-for-vs-2015.html' title='OData Client Code Generator for VS 2015'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-3271894961469299773</id><published>2018-06-07T16:11:00.000-07:00</published><updated>2020-07-07T19:04:44.636-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure AD"/><category scheme="http://www.blogger.com/atom/ns#" term="JIT"/><category scheme="http://www.blogger.com/atom/ns#" term="msgraph"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Azure"/><title type='text'>PowerShell sample for Privileged Identity Management (PIM) for Azure AD Roles</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
PIM for Azure AD Roles provides Just in Time (JIT) capability for Azure AD Roles. See more at&amp;nbsp;&lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/active-directory-privileged-identity-management-getting-started&quot; style=&quot;box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/active-directory-privileged-identity-management-getting-started&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
How cool would it be if I can use the MSGraph PIM api’s to build custom applications. For example, you have multiple roles where you want to activate every day. It would be time consuming to activate them one by one. Instead, you can build a custom app using PowerShell or UI so that you can activate to all of these roles in one shot.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
In this blog, I will share a sample to list all your eligible roles and activate or deactivate them. You will also be able to assign someone to a role.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
I will share the full source code so you can customize it to suit your needs. Just save this as a .ps1 file and run it with PowerShell.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;b&gt;&lt;u&gt;Note&lt;/u&gt;&lt;/b&gt;: If you tenant has migrated to newer version of PIM, see&amp;nbsp;&lt;a href=&quot;http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html&quot;&gt;http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;u style=&quot;box-sizing: border-box;&quot;&gt;Screenshot&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;u style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWzDsWbtIDaXI1Fs0nmAJNJOV8JRNYmZM6SGDIJaWUqA2AfMHYH7NIzQhtcie2R2YxtqfNh8yTFaRiinx22Nh3PwIsr2iaV8Yewjq0TmcMDkMmhcTBGXoUv2YFWc5q0GqFV6QUwF2cpfRz/s1600/aad.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;312&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWzDsWbtIDaXI1Fs0nmAJNJOV8JRNYmZM6SGDIJaWUqA2AfMHYH7NIzQhtcie2R2YxtqfNh8yTFaRiinx22Nh3PwIsr2iaV8Yewjq0TmcMDkMmhcTBGXoUv2YFWc5q0GqFV6QUwF2cpfRz/s640/aad.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Setup&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;u style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif; font-weight: 400;&quot;&gt; &lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px; margin-top: 0px; text-align: left;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Create a native AAD application. See &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications&quot; style=&quot;box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPkJoN4BLTCV9WbpbMI9ZXdUjsC1ux5Lj_Fk_Q59qwdXsXz_bETK6XR-igb865WFNXS3DCaVCWJc9SC13pRlAzmpWt5VcI9_-cs3xOxnfVNLVTVDm55ATGWIx0_HY961io3mK3A2k7v-0f/s1600/native.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;141&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPkJoN4BLTCV9WbpbMI9ZXdUjsC1ux5Lj_Fk_Q59qwdXsXz_bETK6XR-igb865WFNXS3DCaVCWJc9SC13pRlAzmpWt5VcI9_-cs3xOxnfVNLVTVDm55ATGWIx0_HY961io3mK3A2k7v-0f/s400/native.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Grant it the following permissions to the application.&lt;div style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;div style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;ul style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Read and write privileged access to Azure AD - You will need it if you are going to use the app for PIM for Azure AD Roles&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Read and write privileged access to Azure resources - You will need it if you are going to use the app for PIM for Azure Resources&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Read directory data - You will need it if you are going to read users, etc. from directory like the assignment example in the below source code&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaOOd0lFy6dBKy_F1gcaHtoHKkmpbslo0G2_3eWK7Zc9jNdci-gCYx0tvUw1tcfiAH5OkqmPM7jWhLa5Kmzenr8udRySEsZZTIlhXU6F7s9KYTSJzspPU4Tirk8tRAms_sneCdioAZyDcr/s1600/permissions.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaOOd0lFy6dBKy_F1gcaHtoHKkmpbslo0G2_3eWK7Zc9jNdci-gCYx0tvUw1tcfiAH5OkqmPM7jWhLa5Kmzenr8udRySEsZZTIlhXU6F7s9KYTSJzspPU4Tirk8tRAms_sneCdioAZyDcr/s400/permissions.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8rFPNI2PPnTkhEg1KonEFT1nqDQNa49qxQuLvKJuC2uB5drwrAaqgEPAu79FwlzEUz_9If6XZnEcqOOMO2D14fq9N4pTlgateHg5H-K7JUxvihJN5pIqbF5AUaGU9q0PNhXJ1IMGPSfon/s1600/perm2.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;152&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8rFPNI2PPnTkhEg1KonEFT1nqDQNa49qxQuLvKJuC2uB5drwrAaqgEPAu79FwlzEUz_9If6XZnEcqOOMO2D14fq9N4pTlgateHg5H-K7JUxvihJN5pIqbF5AUaGU9q0PNhXJ1IMGPSfon/s400/perm2.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Note than these permissions require Admin consent so you will have to contact the tenant admin to grant these permissions. See &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/application-dev-registration-config-grant-permissions-how-to&quot; style=&quot;box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/application-dev-registration-config-grant-permissions-how-to&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;In the below code, update $clientID with your application id and $redirectUri with the redirect uri of the application.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;b&gt;&lt;u&gt;Source code&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Loads Active Directory Authentication Library&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;
&lt;div&gt;
function Load-ActiveDirectoryAuthenticationLibrary(){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $moduleDirPath = [Environment]::GetFolderPath(&quot;MyDocuments&quot;) + &quot;\WindowsPowerShell\Modules&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $modulePath = $moduleDirPath + &quot;\AADGraph&quot;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if(-not (Test-Path ($modulePath+&quot;\Nugets&quot;))) {New-Item -Path ($modulePath+&quot;\Nugets&quot;) -ItemType &quot;Directory&quot; | out-null}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $adalPackageDirectories = (Get-ChildItem -Path ($modulePath+&quot;\Nugets&quot;) -Filter &quot;Microsoft.IdentityModel.Clients.ActiveDirectory*&quot; -Directory)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if($adalPackageDirectories.Length -eq 0){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Active Directory Authentication Library Nuget doesn&#39;t exist. Downloading now ...&quot; -ForegroundColor Yellow&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(-not(Test-Path ($modulePath + &quot;\Nugets\nuget.exe&quot;)))&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;nuget.exe not found. Downloading from http://www.nuget.org/nuget.exe ...&quot; -ForegroundColor Yellow&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $wc = New-Object System.Net.WebClient&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $wc.DownloadFile(&quot;http://www.nuget.org/nuget.exe&quot;,$modulePath + &quot;\Nugets\nuget.exe&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $nugetDownloadExpression = $modulePath + &quot;\Nugets\nuget.exe install Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.14.201151115 -OutputDirectory &quot; + $modulePath + &quot;\Nugets | out-null&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Invoke-Expression $nugetDownloadExpression&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $adalPackageDirectories = (Get-ChildItem -Path ($modulePath+&quot;\Nugets&quot;) -Filter &quot;Microsoft.IdentityModel.Clients.ActiveDirectory*&quot; -Directory)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $ADAL_Assembly = (Get-ChildItem &quot;Microsoft.IdentityModel.Clients.ActiveDirectory.dll&quot; -Path $adalPackageDirectories[$adalPackageDirectories.length-1].FullName -Recurse)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $ADAL_WindowsForms_Assembly = (Get-ChildItem &quot;Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll&quot; -Path $adalPackageDirectories[$adalPackageDirectories.length-1].FullName -Recurse)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if($ADAL_Assembly.Length -gt 0 -and $ADAL_WindowsForms_Assembly.Length -gt 0){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Loading ADAL Assemblies ...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [System.Reflection.Assembly]::LoadFrom($ADAL_Assembly[0].FullName) | out-null&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [System.Reflection.Assembly]::LoadFrom($ADAL_WindowsForms_Assembly.FullName) | out-null&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return $true&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; else{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Fixing Active Directory Authentication Library package directories ...&quot; -ForegroundColor Yellow&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $adalPackageDirectories | Remove-Item -Recurse -Force | Out-Null&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Not able to load ADAL assembly. Delete the Nugets folder under&quot; $modulePath &quot;, restart PowerShell session and try again ...&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return $false&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
#Acquire AAD token&lt;/div&gt;
&lt;div&gt;
function AcquireToken($mfa){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $clientID = &quot;c7c64917-42bd-4a36-8ed6-af40122626eb&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $redirectUri = &quot;https://pimmsgraph&quot;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $authority = &quot;https://login.microsoftonline.com/common&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $authContext = New-Object &quot;Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext&quot; -ArgumentList $authority,$false&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if($mfa)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $authResult = $authContext.AcquireToken(&quot;https://graph.microsoft.com&quot;,$ClientID,$redirectUri,[Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto, [Microsoft.IdentityModel.Clients.ActiveDirectory.UserIdentifier]::AnyUser, &quot;amr_values=mfa&quot;)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set-Variable -Name mfaDone -Value $true -Scope Global&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; else&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $authResult = $authContext.AcquireToken(&quot;https://graph.microsoft.com&quot;,$ClientID,$redirectUri,[Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Always)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if($authResult -ne $null)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;User logged in successfully ...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Set-Variable -Name headerParams -Value @{&#39;Authorization&#39;=&quot;$($authResult.AccessTokenType) $($authResult.AccessToken)&quot;} -Scope Global&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Set-Variable -Name assigneeId -Value $authResult.UserInfo.UniqueId -Scope Global&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
#Gets my jit assignments&lt;/div&gt;
&lt;div&gt;
function MyJitAssignments(){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoleAssignments/my?`$expand=roleInfo&amp;amp;`$filter=isElevated+eq+false&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $assignments = ConvertFrom-Json $response.Content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;Role assignments...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $i = 0&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = @()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; foreach ($assignment in $assignments.value)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = ++$i&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleAssignmentId =&amp;nbsp; $assignment.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId =&amp;nbsp; $assignment.roleInfo.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName =&amp;nbsp; $assignment.roleInfo.name&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserId = $assignment.userid&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; return $obj&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
#Gets my active assignments&lt;/div&gt;
&lt;div&gt;
function MyActivatedAssignments(){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoleAssignments/my?`$expand=roleInfo&amp;amp;`$filter=isElevated+eq+true+and+expirationDateTime+ne+null&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $assignments = ConvertFrom-Json $response.Content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;Role assignments...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $i = 0&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = @()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; foreach ($assignment in $assignments.value)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = ++$i&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleAssignmentId =&amp;nbsp; $assignment.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId =&amp;nbsp; $assignment.roleInfo.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName =&amp;nbsp; $assignment.roleInfo.name&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserId = $assignment.userid&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExpirationDateTime = $assignment.expirationDateTime&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; return $obj&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#List roles&lt;/div&gt;
&lt;div&gt;
function ListRoles(){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoles?&amp;amp;`$orderby=name&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roles = ConvertFrom-Json $response.Content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $i = 0&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = @()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; foreach ($role in $roles.value)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = ++$i&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId =&amp;nbsp; $role.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName =&amp;nbsp; $role.name&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; return $obj&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#List Assignment&lt;/div&gt;
&lt;div&gt;
function ListAssignmentsWithFilter($roleId){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoleAssignments?`$expand=roleInfo&amp;amp;`$filter=roleId+eq+&#39;&quot; + $roleId + &quot;&#39;&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleAssignments = ConvertFrom-Json $response.Content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $i = 0&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = @()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; foreach ($roleAssignment in $roleAssignments.value)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = ++$i&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleAssignmentId =&amp;nbsp; $roleAssignment.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId = $roleAssignment.roleInfo.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName = $roleAssignment.roleInfo.name&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IsElevated = $roleAssignment.isElevated&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExpirationDateTime = $roleAssignment.expirationDateTime&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserId = $roleAssignment.userId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
return $obj&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#List Users&lt;/div&gt;
&lt;div&gt;
function ListUsers($user_search){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $MSGraphRoot + &quot;users?`$filter=startswith(displayName,&#39;&quot; + $user_search + &quot;&#39;)&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $users = ConvertFrom-Json $response.Content&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $i = 0&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = @()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; foreach ($user in $users.value)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Id = ++$i&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserId =&amp;nbsp; $user.id&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserName =&amp;nbsp; $user.DisplayName&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; return $obj&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#Activates the user&lt;/div&gt;
&lt;div&gt;
function Activate($isRecursive = $false){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if($isRecursive -eq $false)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments = MyJitAssignments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments | Format-Table -AutoSize -Wrap Id,RoleName&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $choice = Read-Host &quot;Enter Id to activate&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $hours = Read-Host &quot;Enter Activation duration in hours&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $reason = Read-Host &quot;Enter Reason&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleId = $assignments[$choice-1].RoleId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoles(&#39;&quot; + $roleId + &quot;&#39;)/selfActivate&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;duration&quot;:&quot;&#39; + $hours + &#39;&quot;,&quot;reason&quot;:&quot;&#39; + $reason + &#39;&quot;}&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; write-Host $postParams&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; try&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Role activated successfully ...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; catch&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if($mfaDone -eq $false -and $err.Contains(&quot;MfaRule&quot;))&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Prompting the user for mfa ...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AcquireToken true&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Activate $true&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $err -ForegroundColor Red&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
#Deactivates the user&lt;/div&gt;
&lt;div&gt;
function Deactivate($isRecursive = $false){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; if($isRecursive -eq $false)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments = MyActivatedAssignments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments | Format-Table -AutoSize -Wrap Id,RoleName,ExpirationDateTime&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $choice = Read-Host &quot;Enter Id to deactivate&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleId = $assignments[$choice-1].RoleId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoles(&#39;&quot; + $roleId + &quot;&#39;)/selfDeactivate&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;Role deactivated successfully ...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
#List RoleAssignment&lt;/div&gt;
&lt;div&gt;
function ListAssignment(){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; #List and Pick a role&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roles = ListRoles&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roles | Format-Table -AutoSize -Wrap Id, RoleName, RoleId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $role_choice = Read-Host &quot;Pick a role Id&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleId = $roles[$role_choice-1].RoleId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; write-Host $roleId&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; #List Member&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleAssignments = ListAssignmentsWithFilter $roleId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleAssignments | Format-Table -AutoSize -Wrap Id, RoleName, UserId, IsElevated, ExpirationDateTime&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#Assign a user to Eligible&lt;/div&gt;
&lt;div&gt;
function AssignmentEligible() {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; #List and Pick a role&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roles = ListRoles&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roles | Format-Table -AutoSize -Wrap Id, RoleName&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $role_choice = Read-Host &quot;Pick a role Id&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $roleId = $roles[$role_choice-1].RoleId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; write-Host $roleId&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; #Search user by Name, and pick a user&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $user_search = Read-Host &quot;user Name start with...&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $users = ListUsers($user_search)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $users | Format-Table -AutoSize -Wrap Id, UserName, UserId&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $user_choice = Read-Host &quot;Pick a user Id&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $userId = $users[$user_choice-1].UserId&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;privilegedRoleAssignments&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;roleId&quot;:&quot;&#39; + $roleId + &#39;&quot;,&quot;userId&quot;:&quot;&#39; + $userId + &#39;&quot;}&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; write-Host $postParams&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;Assignment added successfully ...&quot; -ForegroundColor Green&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
#Show menu&lt;/div&gt;
&lt;div&gt;
function ShowMenu(){&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;Azure AD JIT - PowerShell Menu v1.0&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 1. List your eligible role assignments&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 2. Activate an eligible role&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 3. Deactivate an active role&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 4. List Assignment against a role&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 5. Assign a user to a role&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 6. Exit&quot;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
############################################################################################################################################################################&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
$global:serviceRoot = &quot;https://graph.microsoft.com/beta/&quot;&lt;/div&gt;
&lt;div&gt;
$global:MSGraphRoot = &quot;https://graph.microsoft.com/v1.0/&quot;&lt;/div&gt;
&lt;div&gt;
$global:headerParams = &quot;&quot;&lt;/div&gt;
&lt;div&gt;
$global:assigneeId = &quot;&quot;&lt;/div&gt;
&lt;div&gt;
$global:mfaDone = $false;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Load-ActiveDirectoryAuthenticationLibrary&lt;/div&gt;
&lt;div&gt;
AcquireToken&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
do&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; ShowMenu&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; #Write-Host &quot;Enter your selection&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; $input = Read-Host &quot;Enter your selection&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; switch ($input)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;1&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments = MyJitAssignments&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments | Format-Table -AutoSize -Wrap Id,RoleName&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;2&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Activate&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;3&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Deactivate&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;4&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ListAssignment&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;5&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AssignmentEligible&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;6&#39;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
until ($input -eq &#39;6&#39;)&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Write-Host &quot;&quot;&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/3271894961469299773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/06/powershell-sample-for-privileged_7.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3271894961469299773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3271894961469299773'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/06/powershell-sample-for-privileged_7.html' title='PowerShell sample for Privileged Identity Management (PIM) for Azure AD Roles'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWzDsWbtIDaXI1Fs0nmAJNJOV8JRNYmZM6SGDIJaWUqA2AfMHYH7NIzQhtcie2R2YxtqfNh8yTFaRiinx22Nh3PwIsr2iaV8Yewjq0TmcMDkMmhcTBGXoUv2YFWc5q0GqFV6QUwF2cpfRz/s72-c/aad.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-7998155031574707683</id><published>2018-05-11T16:40:00.000-07:00</published><updated>2018-05-11T18:24:35.355-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aad"/><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="Conditional Access"/><category scheme="http://www.blogger.com/atom/ns#" term="Terms of Use"/><category scheme="http://www.blogger.com/atom/ns#" term="TPU"/><category scheme="http://www.blogger.com/atom/ns#" term="user_interaction_required"/><category scheme="http://www.blogger.com/atom/ns#" term="VS 2015"/><title type='text'>user_interaction_required – Not able to add/refresh account in VS 2015</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
One day all of a sudden most of our team members were not
able to add/refresh their account in VS 2015. We were getting an error&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;---------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;Microsoft Visual
Studio&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;---------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;We could not refresh
the credentials for the account xxx&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;user_interaction_required:
One of two conditions was encountered: 1. The PromptBehavior.Never flag was
passed, but the constraint could not be honored, because user interaction was
required. 2. An error occurred during a silent web authentication that prevented
the http authentication flow from completing in a short enough time frame&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;---------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;OK&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;---------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I then started looking at the network traces to figure out
what’s wrong. I saw that there was an interaction between login.microsoftonline.com
and tokenprovider.termsofuse.identitygovernance.azure.com after which the error
would occur.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I copied the first url which looks like&amp;nbsp;&lt;a href=&quot;https://login.microsoftonline.com/foo/oauth2/authorize?resource=https%3a%2f%2fmanagement.core.windows.net%2f&amp;amp;client_id=872cd9fa-d31f-45e0-9eab-6e460a02d1f1&amp;amp;response_type=code&amp;amp;redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&amp;amp;login_hint=foo&amp;amp;client-request-id=f9c9ba16-48c2-4def-9b2d-c2218191eb7f&amp;amp;prompt=attempt_none&amp;amp;x-client-SKU=.NET&amp;amp;x-client-Ver=2.16.0.0&amp;amp;x-client-CPU=x64&amp;amp;x-client-OS=Microsoft+Windows+NT+10.0.16299.0&amp;amp;sso_nonce=foo&amp;amp;mscrid=foo&quot; style=&quot;font-family: Calibri, sans-serif; font-size: 11pt;&quot;&gt;https://login.microsoftonline.com/xxx/oauth2/authorize?resource=https%3a%2f%2fmanagement.core.windows.net%2f&amp;amp;client_id=872cd9fa-d31f-45e0-9eab-6e460a02d1f1&amp;amp;response_type=code&amp;amp;redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&amp;amp;login_hint=xxx&amp;amp;client-request-id=f9c9ba16-48c2-4def-9b2d-c2218191eb7f&amp;amp;prompt=attempt_none&amp;amp;x-client-SKU=.NET&amp;amp;x-client-Ver=2.16.0.0&amp;amp;x-client-CPU=x64&amp;amp;x-client-OS=Microsoft+Windows+NT+10.0.16299.0&amp;amp;sso_nonce=xxx&amp;amp;mscrid=xxx&lt;/a&gt;&lt;span style=&quot;font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-size: 11pt;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;calibri&amp;quot; , sans-serif; font-size: 11pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;and pasted it into browser.&lt;br /&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now, I saw a prompt to accept Terms Of Use in a different
tenant that my home tenant. Looked like someone had enabled a Terms of Use Conditional Access policy on that tenant. See more details
about Terms of Use here &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/active-directory-tou&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/active-directory-tou&lt;/a&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
On analyzing more, it looks like VS tries to get a token for
all the tenants you belong to. If one of the tenant has a Conditional Access
policy like Terms of Use which requires a user input, VS 2015 will not be able
to show it to you. So will you have to upgrade to VS 2017 or disable the Conditional Access policy.&lt;br /&gt;
&lt;br /&gt;
Once
this is done, everything should start working as usual.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/7998155031574707683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/05/userinteractionrequired-not-able-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7998155031574707683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7998155031574707683'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/05/userinteractionrequired-not-able-to.html' title='user_interaction_required – Not able to add/refresh account in VS 2015'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-2011109163584307405</id><published>2018-04-11T18:16:00.000-07:00</published><updated>2018-10-25T18:38:16.383-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="JIT"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><category scheme="http://www.blogger.com/atom/ns#" term="RBAC"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Azure"/><title type='text'>Securing Azure resources with Privileged Identity Management</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
With Azure Active Directory Privileged Identity Management (PIM), you can now manage, control, and monitor access to Azure Resources within your organization. To learn more, see &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/privileged-identity-management/azure-pim-resource-rbac&quot; style=&quot;box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/privileged-identity-management/azure-pim-resource-rbac&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
It is important to have a Just In Time (JIT) capability to JIT into an Azure subscription for few hours to investigate any issues. However, once a bad guy has access to the subscription, he can get a lot of information out (like secrets, etc.) and do bad things even after the access is lost.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
With PIM, you can assign JIT access not only at the subscription level but also at a specific Resource group or Resource level to prevent any information disclosure. Here is an example of how you can manage your subscription securely with PIM.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikq5aIsYonxfpQm84BSs__KTD9FhbSqyoto8A09INsZKTCHMMgWdYrliwN2LGNwyep61u4-SYDkxU8t-C1Epqzjz4T6UgFS_mUJjEHRJvmBeCUtHXRiHs6iWdbAP_hNBlXJe7Q2jBxRxRH/s1600/Capture.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;204&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikq5aIsYonxfpQm84BSs__KTD9FhbSqyoto8A09INsZKTCHMMgWdYrliwN2LGNwyep61u4-SYDkxU8t-C1Epqzjz4T6UgFS_mUJjEHRJvmBeCUtHXRiHs6iWdbAP_hNBlXJe7Q2jBxRxRH/s640/Capture.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
Create a Resource group for all your secrets. Let’s call it SecretsResourceGroup. This resource group can have the following resources:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Azure Storage&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;SQL Azure&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Cosmos DB&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Etc.&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
Create a Resource group for all your deployments. Let’s call it DeploymentsResourceGroup. This resource can have the following resources:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Cloud Service&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Service Fabric&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;App Service&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Virtual Machines&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Etc.&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
You will notice that almost anyone who needs access to the subscription actually needs access to a resource within DeploymentsResourceGroup. Typical scenarios include:&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Investigating live site issue with a specific deployment&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Restarting a VM&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Installing a software update&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
  &lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Etc.&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
If they need access to multiple resources, you can assign them Eligible assignment on the Resource group. If they need access to a specific resource, you can assign them Eligible assignment on the specific resource. Now whenever, they need access, they can JIT into the specific resource at that time. You can also configure approval so that they can only JIT upon approval.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Segoe UI&amp;quot;, Tahoma, Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-variant-east-asian: normal; font-variant-numeric: normal;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
Thus, due to the granularity that PIM supports, you can now prevent people from accessing your secrets but still allow them to JIT into the specific resources where they need to investigate any issues.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/2011109163584307405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/04/securing-azure-resources-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2011109163584307405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2011109163584307405'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/04/securing-azure-resources-with.html' title='Securing Azure resources with Privileged Identity Management'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikq5aIsYonxfpQm84BSs__KTD9FhbSqyoto8A09INsZKTCHMMgWdYrliwN2LGNwyep61u4-SYDkxU8t-C1Epqzjz4T6UgFS_mUJjEHRJvmBeCUtHXRiHs6iWdbAP_hNBlXJe7Q2jBxRxRH/s72-c/Capture.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-7218638466061006404</id><published>2018-02-26T10:52:00.001-08:00</published><updated>2018-02-26T10:52:53.895-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure AD"/><category scheme="http://www.blogger.com/atom/ns#" term="mfa"/><category scheme="http://www.blogger.com/atom/ns#" term="phone"/><title type='text'>Change Azure AD MFA option or phone number</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently someone asked how can I change my Azure AD MFA option (like call/text/app) or how can I change my phone number.&lt;br /&gt;
The easiest way to do this is to go to&amp;nbsp;&lt;a href=&quot;https://account.activedirectory.windowsazure.com/Proofup.aspx&quot; style=&quot;font-family: Calibri, sans-serif; font-size: 11pt;&quot;&gt;https://account.activedirectory.windowsazure.com/Proofup.aspx&lt;/a&gt;&amp;nbsp;where you will be able to update your MFA option or phone number.&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/7218638466061006404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/02/change-azure-ad-mfa-option-or-phone.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7218638466061006404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/7218638466061006404'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/02/change-azure-ad-mfa-option-or-phone.html' title='Change Azure AD MFA option or phone number'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-8386298919394054808</id><published>2018-02-07T11:30:00.005-08:00</published><updated>2021-02-16T18:30:55.592-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure AD"/><category scheme="http://www.blogger.com/atom/ns#" term="JIT"/><category scheme="http://www.blogger.com/atom/ns#" term="mfa"/><category scheme="http://www.blogger.com/atom/ns#" term="MSAL"/><category scheme="http://www.blogger.com/atom/ns#" term="msgraph"/><category scheme="http://www.blogger.com/atom/ns#" term="PIM"/><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><category scheme="http://www.blogger.com/atom/ns#" term="RBAC"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Azure"/><title type='text'>PowerShell sample for Privileged Identity Management (PIM)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
PIM for Azure Resources provides Just in Time (JIT) and Temporary access capabilities for Azure AD roles and Azure Resource roles. See more at&amp;nbsp;&lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/privileged-identity-management/pim-configure&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/privileged-identity-management/pim-configure&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
How cool would it be if I can use the MSGraph PIM api’s to build custom applications. For example, your IT Org has N different resource groups where you want to activate every day. It would be time consuming to activate them one by one. Instead, you can build a custom app using PowerShell or UI so that you can activate to all of these resource groups in one shot.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
In this blog, I will share a sample to list all your eligible roles and activate or deactivate them. You will also be able to assign someone to a role.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
I will share the full source code so you can customize it to suit your needs. Just save this as a .ps1 file and run it with PowerShell.&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;u style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;Screenshot&lt;/u&gt;&lt;br /&gt;
&lt;u style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/u&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ5aUbnhf_Qc49sPelG_ZWPqiWTVGw_tHxgJKQcpimE0_upnBMHrCof5iCDZiDSxGmwDa6V3i6xsSY9GYuZIJRM-Dc81DxgPN7pol6mOKurV-Krc3AHcXyVRbViBDM0I9nrHqHRcsoUvAs/s1600/PS.JPG&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;586&quot; data-original-width=&quot;1600&quot; height=&quot;233&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ5aUbnhf_Qc49sPelG_ZWPqiWTVGw_tHxgJKQcpimE0_upnBMHrCof5iCDZiDSxGmwDa6V3i6xsSY9GYuZIJRM-Dc81DxgPN7pol6mOKurV-Krc3AHcXyVRbViBDM0I9nrHqHRcsoUvAs/s640/PS.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;u style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/u&gt;
&lt;u style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;u style=&quot;box-sizing: border-box;&quot;&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;box-sizing: border-box; text-decoration-line: underline;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;u style=&quot;font-weight: 700;&quot;&gt;Setup&lt;/u&gt;&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;span style=&quot;box-sizing: border-box; font-weight: 700;&quot;&gt;&lt;span face=&quot;&amp;quot;segoe ui&amp;quot;, tahoma, arial, &amp;quot;helvetica neue&amp;quot;, helvetica, sans-serif&quot; style=&quot;background-color: white; font-weight: 400;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px; margin-top: 0px; text-align: left;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Create a native AAD application. See &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications&quot; style=&quot;box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsORIpFnsjg0zQlvKd5TGJtWat0kW5TNNxwiW3rXx6SL9RKjtHktXWkjnkclZ36G4XKPivct7JqGQ2TEp7FSUhy6PMJ_6xfj9lHvfPeJ9mf7nC6ilHGg_MDQuFy74xGuYAZzinHMc6o_AA/s1600/native.png&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;141&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsORIpFnsjg0zQlvKd5TGJtWat0kW5TNNxwiW3rXx6SL9RKjtHktXWkjnkclZ36G4XKPivct7JqGQ2TEp7FSUhy6PMJ_6xfj9lHvfPeJ9mf7nC6ilHGg_MDQuFy74xGuYAZzinHMc6o_AA/s400/native.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Grant it the following permissions to the application.&lt;div style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;span face=&quot;&amp;quot;segoe ui&amp;quot;, tahoma, arial, &amp;quot;helvetica neue&amp;quot;, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt; &lt;/span&gt;&lt;div style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; margin-bottom: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Read and write privileged access to Azure AD - You will need it if you are going to use the app for PIM for Azure AD Roles&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Read and write privileged access to Azure resources - You will need it if you are going to use the app for PIM for Azure Resources&lt;/li&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;box-sizing: border-box; margin-bottom: 10px;&quot;&gt;
&lt;/div&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Read directory data - You will need it if you are going to read users, etc. from directory like the assignment example in the below source code&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVkGF9W7OxNIqz-AckbuyQtPBFqpY7ppgz7mczdaUI9dknauB2SP_wN2pQ43VC-SgdZsT3drgvxnLcmqgQGiakb82rPJYCHr650qCwgXcwRzv8RH7dit4KXmtfB2pKo8CCu4TpL6w4S2uu/s1600/permissions.png&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVkGF9W7OxNIqz-AckbuyQtPBFqpY7ppgz7mczdaUI9dknauB2SP_wN2pQ43VC-SgdZsT3drgvxnLcmqgQGiakb82rPJYCHr650qCwgXcwRzv8RH7dit4KXmtfB2pKo8CCu4TpL6w4S2uu/s400/permissions.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMoav4NnjnolKmM84IqbKigDrHyNRtherUWxvV8EEZe7mZo7X_P5vNB7tnXXLL3eSoODtuFf0Xk-4g2_H1LgmAFtjFpIujsxlQUjeeh1xKfMyiIDeSSpskXotErYI2AS9tmEK6oy4is3BX/s1600/perm2.png&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;122&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMoav4NnjnolKmM84IqbKigDrHyNRtherUWxvV8EEZe7mZo7X_P5vNB7tnXXLL3eSoODtuFf0Xk-4g2_H1LgmAFtjFpIujsxlQUjeeh1xKfMyiIDeSSpskXotErYI2AS9tmEK6oy4is3BX/s320/perm2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Note than these permissions require Admin consent so you will have to contact the tenant admin to grant these permissions. See &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/application-dev-registration-config-grant-permissions-how-to&quot; style=&quot;box-sizing: border-box; color: #337ab7; text-decoration-line: none;&quot;&gt;https://docs.microsoft.com/en-us/azure/active-directory/application-dev-registration-config-grant-permissions-how-to&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;In the below code, update $clientID with your application id and $redirectUri with the redirect uri of the application.&lt;/li&gt;
&lt;li&gt;For Azure resources, set&amp;nbsp;$global:serviceRoot = &quot;https://graph.microsoft.com/beta/privilegedAccess/azureResources/&quot;&lt;/li&gt;
&lt;li&gt;For Azure AD roles, set&amp;nbsp;$global:serviceRoot = &quot;https://graph.microsoft.com/beta/privilegedAccess/aadRoles/&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;box-sizing: border-box; color: #333333; font-size: 14px; font-weight: 700;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 400; margin-bottom: 10px; margin-top: 0px;&quot;&gt;&lt;li&gt;For Azure AD groups, set&amp;nbsp;$global:serviceRoot = &quot;https://graph.microsoft.com/beta/privilegedAccess/aadGroups/&quot;&lt;/li&gt;&lt;/ul&gt;&lt;u&gt;Source code&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;box-sizing: border-box; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Acquire AAD token&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function AcquireToken($clientID, $redirectUri, $scopes, $authority, $mfa)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($mfa)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $authResult = Get-MSALToken -Scopes $scopes -ClientId $clientID -RedirectUri $redirectUri -Authority $authority -Interactive -ExtraQueryParameters @{claims=&#39;{&quot;access_token&quot; : {&quot;amr&quot;: { &quot;values&quot;: [&quot;mfa&quot;] }}}&#39;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set-Variable -Name mfaDone -Value $true -Scope Global&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $authResult = Get-MSALToken -Scopes $scopes -ClientId $clientID -RedirectUri $redirectUri -Authority $authority -Interactive&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($authResult -ne $null)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;User logged in successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Set-Variable -Name headerParams -Value @{&#39;Authorization&#39;=&quot;$($authResult.AccessTokenType) $($authResult.AccessToken)&quot;} -Scope Global&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Set-Variable -Name assigneeId -Value $authResult.UserInfo.UniqueId -Scope Global&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Gets my jit assignments&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function MyJitAssignments(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $urlme = $global:MSGraphRoot + &quot;me/&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $urlme -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $me = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $subjectId = $me.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $subjectId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignments?`$expand=linkedEligibleRoleAssignment,subject,roleDefinition(`$expand=resource)&amp;amp;`$filter=(assignmentState+eq+&#39;Eligible&#39;)+and+(subjectId+eq+&#39;&quot; + $subjectId + &quot;&#39;)&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $assignments = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;Role assignments...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($assignment in $assignments.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IdGuid =&amp;nbsp; $assignment.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceId =&amp;nbsp; $assignment.roleDefinition.resource.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OriginalId =&amp;nbsp; $assignment.roleDefinition.resource.externalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceName =&amp;nbsp; $assignment.roleDefinition.resource.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceType =&amp;nbsp; $assignment.roleDefinition.resource.type&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId = $assignment.roleDefinition.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName = $assignment.roleDefinition.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExpirationDate = $assignment.endDateTime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SubjectId = $assignment.subject.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List resources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListResources(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;resources?`$filter=(type+eq+&#39;subscription&#39;)&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($resource in $resources.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceId =&amp;nbsp; $resource.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceName =&amp;nbsp; $resource.DisplayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type =&amp;nbsp; $resource.type&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExternalId =&amp;nbsp; $resource.externalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List roles&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListRoles($resourceId){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;resources/&quot; + $resourceId + &quot;/roleDefinitions?&amp;amp;`$orderby=displayName&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($role in $roles.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleDefinitionId =&amp;nbsp; $role.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName =&amp;nbsp; $role.DisplayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List roles&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListRoleSettings($resourceId){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;resources/&quot; + $resourceId + &quot;/roleSettings?&amp;amp;`$expand=resource,roleDefinition&amp;amp;`$orderby=lastUpdatedDateTime+desc&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettings = ConvertFrom-Json -InputObject $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($roleSetting in $roleSettings.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # userMemberSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSExp = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSMFA = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSJus = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSActDay = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSApprov = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSTicket = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach ($UMS in $roleSetting.userMemberSettings)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; switch ($UMS.ruleIdentifier) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;MfaRule&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSMFA = $UMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;ExpirationRule&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSExp = $UMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;JustificationRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSJus = $UMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ActivationDayRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSActDay = $UMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ApprovalRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSApprov = $UMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;TicketingRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UMSTicket = $UMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # AdminEligibleSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESExp = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESMFA = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESJus = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESActDay = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESApprov = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESTicket = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach ($AES in $roleSetting.adminEligibleSettings)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; switch ($AES.ruleIdentifier) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;MfaRule&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESMFA = $AES.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;ExpirationRule&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESExp = $AES.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;JustificationRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESJus = $AES.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ActivationDayRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESActDay = $AES.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ApprovalRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESApprov = $AES.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;TicketingRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AESTicket = $AES.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # AdminMemberSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSExp = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSMFA = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSJus = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSActDay = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSApprov = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSTicket = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach ($AMS in $roleSetting.adminMemberSettings)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; switch ($AMS.ruleIdentifier) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;MfaRule&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSMFA = $AMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;ExpirationRule&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSExp = $AMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;JustificationRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSJus = $AMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ActivationDayRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSActDay = $AMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;ApprovalRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSApprov = $AMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;TicketingRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AMSTicket = $AMS.setting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleSettingId = $roleSetting.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceId = $roleSetting.resourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceName = $roleSetting.resource.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleDefinitionId = $roleSetting.roleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName = $roleSetting.roleDefinition.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettings = $roleSetting.adminMemberSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettings = $roleSetting.adminEligibleSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserEligibleSettings = $roleSetting.userEligibleSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettings = $roleSetting.userMemberSettings&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettingsMfaRule = $UMSMFA&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettingsExpirationRule = $UMSExp&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettingsJustificationRule = $UMSJus&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettingsActivationDayRule = $UMSActDay&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettingsApprovalRule = $UMSApprov&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserMemberSettingsTicketingRule = $UMSTicket&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettingsMfaRule = $AESMFA&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettingsExpirationRule = $AESExp&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettingsJustificationRule = $AESJus&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettingsActivationDayRule = $AESActDay&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettingsApprovalRule = $AESApprov&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminEligibleSettingsTicketingRule = $AESTicket&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettingsMfaRule = $AMSMFA&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettingsExpirationRule = $AMSExp&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettingsJustificationRule = $AMSJus&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettingsActivationDayRule = $AMSActDay&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettingsApprovalRule = $AMSApprov&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AdminMemberSettingsTicketingRule = $AMSTicket&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List Assignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListAssignmentsWithFilter($resourceId, $roleDefinitionId){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;resources/&quot; + $resourceId + &quot;`/roleAssignments?`$expand=subject,roleDefinition(`$expand=resource)&amp;amp;`$filter=(roleDefinition/id+eq+&#39;&quot; + $roleDefinitionId + &quot;&#39;)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($roleAssignment in $roleAssignments.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleAssignmentId =&amp;nbsp; $roleAssignment.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceId =&amp;nbsp; $roleAssignment.roleDefinition.resource.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OriginalId =&amp;nbsp; $roleAssignment.roleDefinition.resource.externalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceName =&amp;nbsp; $roleAssignment.roleDefinition.resource.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceType =&amp;nbsp; $roleAssignment.roleDefinition.resource.type&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId = $roleAssignment.roleDefinition.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName = $roleAssignment.roleDefinition.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExpirationDate = $roleAssignment.endDateTime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SubjectId = $roleAssignment.subject.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserName = $roleAssignment.subject.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AssignmentState = $roleAssignment.AssignmentState&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List Assignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListExpiringEligibleAssignmentsWithFilter($resourceId){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;resources/&quot; + $resourceId + &quot;`/roleAssignments?`$expand=subject,roleDefinition(`$expand=resource)&amp;amp;`$filter=(assignmentState+eq+&#39;Eligible&#39;)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;$expiration = (Get-Date).ToUniversalTime().AddDays(14)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($roleAssignment in $roleAssignments.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(($roleAssignment.endDateTime -ne $null) -and ([DateTime]$roleAssignment.endDateTime -lt $expiration))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleAssignmentId =&amp;nbsp; $roleAssignment.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceId =&amp;nbsp; $roleAssignment.roleDefinition.resource.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OriginalId =&amp;nbsp; $roleAssignment.roleDefinition.resource.externalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceName =&amp;nbsp; $roleAssignment.roleDefinition.resource.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ResourceType =&amp;nbsp; $roleAssignment.roleDefinition.resource.type&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleId = $roleAssignment.roleDefinition.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoleName = $roleAssignment.roleDefinition.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExpirationDate = $roleAssignment.endDateTime&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SubjectId = $roleAssignment.subject.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserName = $roleAssignment.subject.displayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AssignmentState = $roleAssignment.AssignmentState&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List Users&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListUsers($user_search){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $MSGraphRoot + &quot;users?`$filter=startswith(displayName,&#39;&quot; + $user_search + &quot;&#39;)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Get&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $users = ConvertFrom-Json $response.Content&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $i = 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = @()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; foreach ($user in $users.value)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $item = New-Object psobject -Property @{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id = ++$i&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserId =&amp;nbsp; $user.id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UserName =&amp;nbsp; $user.DisplayName&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $obj = $obj + $item&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; return $obj&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Activates the user&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function Activate($isRecursive = $false){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($isRecursive -eq $false)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments = MyJitAssignments&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments | Format-Table -AutoSize -Wrap id,RoleName,ResourceName,ResourceType,ExpirationDate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $choice = Read-Host &quot;Enter Id to activate&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [int]$hours = Read-Host &quot;Enter Activation duration in hours&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $reason = Read-Host &quot;Enter Reason&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $id = $assignments[$choice-1].IdGuid&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $assignments[$choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleDefinitionId = $assignments[$choice-1].RoleId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $subjectId = $assignments[$choice-1].SubjectId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignmentRequests&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;id&quot;:&quot;00000000-0000-0000-0000-000000000000&quot;,&quot;assignmentState&quot;:&quot;Active&quot;,&quot;type&quot;:&quot;UserAdd&quot;,&quot;reason&quot;:&quot;&#39; + $reason + &#39;&quot;,&quot;roleDefinitionId&quot;:&quot;&#39; + $roleDefinitionId + &#39;&quot;,&quot;resourceId&quot;:&quot;&#39; + $resourceId + &#39;&quot;,&quot;subjectId&quot;:&quot;&#39; + $subjectId + &#39;&quot;,&quot;schedule&quot;:{&quot;duration&quot;:&quot;PT&#39; + $hours + &#39;H&quot;,&quot;startDateTime&quot;:&quot;&#39; + (Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;) + &#39;&quot;,&quot;type&quot;:&quot;Once&quot;},&quot;linkedEligibleRoleAssignmentId&quot;:&quot;&#39; + $id + &#39;&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Activation request queued successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; catch&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if($mfaDone -eq $false -and $err.Contains(&quot;MfaRule&quot;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Prompting the user for mfa ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AcquireToken $global:clientID $global:redirectUri $global:resourceAppIdURI $global:authority $true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Activate $true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $err -ForegroundColor Red&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Extend the user role assignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ExtendRoleAssignment($roleAssignment, $hours){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignmentRequests&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;id&quot;:&quot;00000000-0000-0000-0000-000000000000&quot;,&quot;assignmentState&quot;:&quot;Eligible&quot;,&quot;type&quot;:&quot;AdminExtend&quot;,&quot;reason&quot;:&quot;bulk extend&quot;,&quot;roleDefinitionId&quot;:&quot;&#39; + $roleAssignment.RoleId + &#39;&quot;,&quot;resourceId&quot;:&quot;&#39; + $roleAssignment.ResourceId + &#39;&quot;,&quot;subjectId&quot;:&quot;&#39; + $roleAssignment.SubjectId + &#39;&quot;,&quot;schedule&quot;:{&quot;duration&quot;:&quot;PT&#39; + $hours + &#39;H&quot;,&quot;startDateTime&quot;:&quot;&#39; + (Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;) + &#39;&quot;,&quot;type&quot;:&quot;Once&quot;}}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Extend Successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; catch&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Delete the user role assignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function DeleteRoleAssignment($roleAssignment){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $roleAssignments[$ra_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleDefinitionId = $roleAssignments[$ra_choice-1].RoleId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $subjectId = $roleAssignments[$ra_choice-1].SubjectId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $assignmentState = $roleAssignments[$ra_choice-1].AssignmentState&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; # Delete the chosen member&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignmentRequests&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;assignmentState&quot;:&quot;&#39; + $assignmentState + &#39;&quot;,&quot;type&quot;:&quot;AdminRemove&quot;,&quot;reason&quot;:&quot;Assign&quot;,&quot;roleDefinitionId&quot;:&quot;&#39; + $roleDefinitionId + &#39;&quot;,&quot;resourceId&quot;:&quot;&#39; + $resourceId + &#39;&quot;,&quot;subjectId&quot;:&quot;&#39; + $subjectId + &#39;&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Assignment has been deleted&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; catch&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $err -ForegroundColor Red&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Deactivates the user&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function Deactivate($isRecursive = $false){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if($isRecursive -eq $false)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments = MyJitAssignments&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments | Format-Table -AutoSize -Wrap id,RoleName,ResourceName,ResourceType,ExpirationDate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $choice = Read-Host &quot;Enter Id to deactivate&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $id = $assignments[$choice-1].IdGuid&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $assignments[$choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleDefinitionId = $assignments[$choice-1].RoleId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $subjectId = $assignments[$choice-1].SubjectId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignmentRequests&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;assignmentState&quot;:&quot;Active&quot;,&quot;type&quot;:&quot;UserRemove&quot;,&quot;roleDefinitionId&quot;:&quot;&#39; + $roleDefinitionId + &#39;&quot;,&quot;resourceId&quot;:&quot;&#39; + $resourceId + &#39;&quot;,&quot;subjectId&quot;:&quot;&#39; + $subjectId + &#39;&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;Role deactivated successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Patch RoleSetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function PatchRoleSetting($patchParams, $roleSettingId){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleSettings/&quot; + $roleSettingId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host $patchParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Patch -ContentType &quot;application/json&quot; -Body $patchParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Update RoleSetting successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; catch&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List RoleAssignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListAssignment(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap id, ResourceName, Type, ExternalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $res_choice = Read-Host &quot;Pick an resource Id for assigment&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $resources[$res_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick a role&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles = ListRoles($resourceId)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles | Format-Table -AutoSize -Wrap id, RoleName, RoleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $role_choice = Read-Host &quot;Pick a role Id&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleDefinitionId = $roles[$role_choice-1].RoleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $roleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List Member&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments = ListAssignmentsWithFilter $resourceId $roleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments | Format-Table -AutoSize -Wrap id, ResourceName, ResourceType, RoleName, UserName, AssignmentState, ExpirationDate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Delete RoleAssignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function DelAssignment(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap id, ResourceName, Type, ExternalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $res_choice = Read-Host &quot;Pick an resource Id for assigment&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $resources[$res_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick a role&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles = ListRoles($resourceId)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles | Format-Table -AutoSize -Wrap id, RoleName, RoleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $role_choice = Read-Host &quot;Pick a role Id&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleDefinitionId = $roles[$role_choice-1].RoleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $roleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List Member&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments = ListAssignmentsWithFilter $resourceId $roleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments | Format-Table -AutoSize -Wrap id, ResourceName, ResourceType, RoleName, UserName, AssignmentState, ExpirationDate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $ra_choice = Read-Host &quot;Pick a roleAssignment you want to delete, Pick 0 for Del All active, and Pick -1 to exit&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if ($ra_choice -eq -1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if (($roleAssignments -eq $null) -or ($roleAssignments[$ra_choice-1] -eq $null))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Number out-of range&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if ($ra_choice -gt 0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DeleteRoleAssignment $roleAssignments[$ra_choice-1]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; } elseif&amp;nbsp; ($ra_choice -eq 0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach ($ra in $roleAssignments)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ra.AssignmentState -eq &quot;Active&quot;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DeleteRoleAssignment $ra&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List ExpiringRoleAssignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListExpiringEligibleAssignments(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap id, ResourceName, Type, ExternalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $res_choice = Read-Host &quot;Pick a resource Id for assigment&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $resources[$res_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List Expiring Member of the target resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments = ListExpiringEligibleAssignmentsWithFilter $resourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleAssignments | Format-Table -AutoSize -Wrap id, ResourceName, ResourceType, RoleName, UserName, AssignmentState, ExpirationDate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if ($roleAssignments -eq $null)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;No Eligible memberships are expiring&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; } else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ra_choice = Read-Host &quot;Pick a roleAssignment you want to extend, Pick 0 for ExtendAll, and Pick -1 to exit&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ra_choice -eq -1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $days = Read-Host &quot;Pick number of days, you want to extends&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $hours = [int]$days * 24&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $hours&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ra_choice -gt 0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExtendRoleAssignment $roleAssignments[$ra_choice-1] $hours&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elseif&amp;nbsp; ($ra_choice -eq 0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach ($ra in $roleAssignments)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ExtendRoleAssignment $ra $hours&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Assign a user to Eligible&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function AssignmentEligible() {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap id, ResourceName, Type, ExternalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $res_choice = Read-Host &quot;Pick an resource Id for assigment&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $resources[$res_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick a role&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles = ListRoles($resourceId)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roles | Format-Table -AutoSize -Wrap id, RoleName, RoleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $role_choice = Read-Host &quot;Pick a role Id&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleDefinitionId = $roles[$role_choice-1].RoleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $roleDefinitionId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #Search user by Name, and pick a user&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $user_search = Read-Host &quot;user Name start with...&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $users = ListUsers($user_search)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $users | Format-Table -AutoSize -Wrap id, UserName, UserId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $user_choice = Read-Host &quot;Pick a user Id&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if (($users -eq $null) -or ($users[$user_choice-1] -eq $null))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Number out-of range&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $subjectId = $users[$user_choice-1].UserId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignmentRequests&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; # Update end time&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $ts = New-TimeSpan -Days 30&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $postParams = &#39;{&quot;assignmentState&quot;:&quot;Eligible&quot;,&quot;type&quot;:&quot;AdminAdd&quot;,&quot;reason&quot;:&quot;Assign&quot;,&quot;roleDefinitionId&quot;:&quot;&#39; + $roleDefinitionId + &#39;&quot;,&quot;resourceId&quot;:&quot;&#39; + $resourceId + &#39;&quot;,&quot;subjectId&quot;:&quot;&#39; + $subjectId + &#39;&quot;,&quot;schedule&quot;:{&quot;startDateTime&quot;:&quot;&#39; + (Get-Date).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;) + &#39;&quot;,&quot;endDateTime&quot;:&quot;&#39; + ((Get-Date) + $ts).ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;) + &#39;&quot;,&quot;type&quot;:&quot;Once&quot;}}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot; -Body $postParams&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Assignment request queued successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; catch&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if($mfaDone -eq $false -and $err.Contains(&quot;MfaRule&quot;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Prompting the user for mfa ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AcquireToken $global:clientID $global:redirectUri $global:resourceAppIdURI $global:authority $true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Activate $true&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $err -ForegroundColor Red&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Cancel Request&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; function CancelRequest() {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $requestId = Read-Host &quot;RequestId&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $url = $serviceRoot + &quot;roleAssignmentRequests/&quot; + $requestId + &quot;/cancel&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $url&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $response = Invoke-WebRequest -UseBasicParsing -Headers $headerParams -Uri $url -Method Post -ContentType &quot;application/json&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host &quot;Cancel request queued successfully ...&quot; -ForegroundColor Green&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $recursive = $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; catch&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream = $_.Exception.Response.GetResponseStream()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Position = 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader = New-Object System.IO.StreamReader($stream)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $err = $streamReader.ReadToEnd()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $streamReader.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $stream.Close()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-host $err&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#List RoleSetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ListRoleSetting(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap id, ResourceName, Type, ExternalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $res_choice = Read-Host &quot;Pick an resource Id for assigment&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $resources[$res_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List RoleSettings and Pick a role/multiple role to update&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettings = ListRoleSettings($resourceId)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettings | Format-List id, RoleName, RoleDefinitionId, ResourceName, ResourceId, AdminMemberSettings, AdminEligibleSettings, UserMemberSettings, UserEligibleSettings,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; AdminMemberSettingsMfaRule, AdminMemberSettingsExpirationRule, AdminMemberSettingsJustificationRule, AdminMemberSettingsActivationDayRule, AdminMemberSettingsApprovalRule, AdminMemberSettingsTicketingRule,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; AdminEligibleSettingsMfaRule, AdminEligibleSettingsExpirationRule, AdminEligibleSettingsJustificationRule, AdminEligibleSettingsActivationDayRule, AdminEligibleSettingsApprovalRule, AdminEligibleSettingsTicketingRule,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; UserMemberSettingsMfaRule, UserMemberSettingsExpirationRule, UserMemberSettingsJustificationRule, UserMemberSettingsActivationDayRule, UserMemberSettingsApprovalRule, UserMemberSettingsTicketingRule,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; UserEligibleSettingsMfaRule, UserEligibleSettingsExpirationRule, UserEligibleSettingsJustificationRule, UserEligibleSettingsActivationDayRule, UserEligibleSettingsApprovalRule, UserEligibleSettingsTicketingRule&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Update RoleSetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function UpdateRoleSetting(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List and Pick resource&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources = ListResources&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resources | Format-Table -AutoSize -Wrap id, ResourceName, Type, ExternalId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $res_choice = Read-Host &quot;Pick an resource Id for assigment&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $resourceId = $resources[$res_choice-1].ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #List RoleSettings and Pick a role/multiple role to update&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettings = ListRoleSettings($resourceId)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettings | Format-List id, RoleName, RoleDefinitionId, ResourceName, ResourceId, AdminMemberSettings, AdminEligibleSettings, UserMemberSettings, UserEligibleSettings,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; AdminMemberSettingsMfaRule, AdminMemberSettingsExpirationRule, AdminMemberSettingsJustificationRule, AdminMemberSettingsActivationDayRule, AdminMemberSettingsApprovalRule, AdminMemberSettingsTicketingRule,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; AdminEligibleSettingsMfaRule, AdminEligibleSettingsExpirationRule, AdminEligibleSettingsJustificationRule, AdminEligibleSettingsActivationDayRule, AdminEligibleSettingsApprovalRule, AdminEligibleSettingsTicketingRule,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; UserMemberSettingsMfaRule, UserMemberSettingsExpirationRule, UserMemberSettingsJustificationRule, UserMemberSettingsActivationDayRule, UserMemberSettingsApprovalRule, UserMemberSettingsTicketingRule,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; UserEligibleSettingsMfaRule, UserEligibleSettingsExpirationRule, UserEligibleSettingsJustificationRule, UserEligibleSettingsActivationDayRule, UserEligibleSettingsApprovalRule, UserEligibleSettingsTicketingRule&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettings | Format-Table -AutoSize -Wrap id, RoleName, ResourceName, RoleDefinitionId, ResourceId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSetting_choice = Read-Host &quot;Pick a role Id&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $roleSettingId = $roleSettings[$roleSetting_choice-1].RoleSettingId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; write-Host $roleSettingId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; # Activation Setting: &quot;MfaRule&quot;, &quot;ExpirationRule&quot;, &quot;JustificationRule&quot;, &quot;ActivationDayRule&quot;, &quot;ApprovalRule&quot;, &quot;TicketingRule&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $Activation = Read-Host &quot;Update Activation Setting or not (Y or N)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if ($Activation -like &#39;Y&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ActivationMfaRule = Read-Host &quot;Activation MFA enabled (Y or N)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ActivationExpirationRule = Read-Host &quot;Activation Grant period in mins (ie. 240 is 4 hr)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ActivationJustificationRule = Read-Host &quot;Activation Justification enabled (Y or N)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ActivationGP = [timespan]::fromminutes($ActivationExpirationRule)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #$UserMemberSetting = &#39;{@{ruleIdentifier=ExpirationRule; setting={&quot;maximumGrantPeriod&quot;:&quot;&#39;+$ActivationGP+&#39;&quot;,&quot;maximumGrantPeriodInMinutes&quot;:&#39;+$ActivationExpirationRule+&#39;,&quot;permanentAssignment&quot;:false}}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UserMemberSetting =&#39;,&quot;userMemberSettings&quot;: [{&quot;ruleIdentifier&quot;:&quot;ExpirationRule&quot;,&quot;setting&quot;: &quot;{\&quot;permanentAssignment\&quot;:false,\&quot;maximumGrantPeriodInMinutes\&quot;:&#39;+$ActivationExpirationRule+&#39;}&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ActivationMfaRule -like &#39;Y&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UserMemberSetting = $UserMemberSetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;MfaRule&quot;,&quot;setting&quot;:&quot;{\&quot;mfaRequired\&quot;:true}&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elseif ($ActivationMfaRule -like &#39;N&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UserMemberSetting = $UserMemberSetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;MfaRule&quot;,&quot;setting&quot;:&quot;{\&quot;mfaRequired\&quot;:false}&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($ActivationJustificationRule -like &#39;Y&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UserMemberSetting = $UserMemberSetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;JustificationRule&quot;,&quot;setting&quot;:&quot;{\&quot;required\&quot;:true}&quot;}]&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elseif ($ActivationJustificationRule -like &#39;N&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $UserMemberSetting = $UserMemberSetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;JustificationRule&quot;,&quot;setting&quot;:&quot;{\&quot;required\&quot;:false}&quot;}]&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $UserMemberSetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $AdminE = Read-Host &quot;Update Admin Eligible Setting or not (Y or N)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if ($AdminE -like &#39;Y&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminEMfaRule = Read-Host &quot;Admin Eligible MFA enabled (Y or N)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminEExpirationRule = Read-Host &quot;Admin Eligible Grant period in mins (ie. 240 is 4 hr)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminEJustificationRule = Read-Host &quot;Admin Eligible Justification enabled (Y or N)&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminEGP = [timespan]::fromminutes($AdminEExpirationRule)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminESetting =&#39;,&quot;adminEligibleSettings&quot;: [{&quot;ruleIdentifier&quot;:&quot;ExpirationRule&quot;,&quot;setting&quot;: &quot;{\&quot;permanentAssignment\&quot;:false,\&quot;maximumGrantPeriodInMinutes\&quot;:&#39;+$AdminEExpirationRule+&#39;}&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($AdminEMfaRule -like &#39;Y&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminESetting = $AdminESetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;MfaRule&quot;,&quot;setting&quot;:&quot;{\&quot;mfaRequired\&quot;:true}&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elseif ($ActivationMfaRule -like &#39;N&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminESetting = $AdminESetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;MfaRule&quot;,&quot;setting&quot;:&quot;{\&quot;mfaRequired\&quot;:false}&quot;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($AdminEJustificationRule -like &#39;Y&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminESetting = $AdminESetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;JustificationRule&quot;,&quot;setting&quot;:&quot;{\&quot;required\&quot;:true}&quot;}]&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } elseif ($ActivationJustificationRule -like &#39;N&#39;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $AdminESetting = $AdminESetting + &#39;,{&quot;ruleIdentifier&quot;:&quot;JustificationRule&quot;,&quot;setting&quot;:&quot;{\&quot;required\&quot;:false}&quot;}]&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $AdminESetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; if (($AdminE -like &#39;Y&#39;) -or ($Activation -like &#39;Y&#39;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #foreach&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $SettingId = &#39;{&quot;id&quot;:&quot;&#39;+$roleSettingId+&#39;&quot;&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $SettingId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $RoleSet = $SettingId+$UserMemberSetting+$AdminESetting+&#39;}&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host $RoleSet&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PatchRoleSetting $RoleSet $roleSettingId&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;#Show menu&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;function ShowMenu(){&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;--------------------------------------- &quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;Azure RBAC JIT - PowerShell Menu&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;--------------------------------------- &quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 1.&amp;nbsp; EndUser List:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;List your eligible role assignments&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 2.&amp;nbsp; EndUser Activate:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Activate an eligible role&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 3.&amp;nbsp; EndUser Deactivate:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Deactivate an active role&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 4.&amp;nbsp; Admin List:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;List Assignment against a resource&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 5.&amp;nbsp; Admin Assign:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Assign a user to a role&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 6.&amp;nbsp; Admin Delete:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Delete Assignment against a resource+role+user&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 7.&amp;nbsp; Admin Extend:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;List Expiring Eligible Assignment against a resource and option to extend&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 8.&amp;nbsp; Admin/EndUser Cancel:&amp;nbsp; &amp;nbsp; &amp;nbsp;Cancel a request&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 9.&amp;nbsp; Admin Query RoleSetting:&amp;nbsp; List roleSetting against a resource&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 10. Admin Update RoleSetting: Choose RoleSetting to apply to a single or multiple roles&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&amp;nbsp; 11. Exit&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; Write-Host &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;############################################################################################################################################################################&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:serviceRoot = &quot;https://graph.microsoft.com/beta/privilegedAccess/azureResources/&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:MSGraphRoot = &quot;https://graph.microsoft.com/v1.0/&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:headerParams = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:assigneeId = &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:mfaDone = $false;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:expiration = &#39;2019-07-01T00:00:00Z&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:authority = &quot;https://login.microsoftonline.com/common&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$global:scopes = @(&quot;https://graph.microsoft.com/.default&quot;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$clientID = &quot;dabc52c4-106b-4179-9df2-2f791f44ba14&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$redirectUri = &quot;https://pimmsgraph&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;# Install msal.ps&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;if(!(Get-Module | Where-Object {$_.Name -eq &#39;PowerShellGet&#39; -and $_.Version -ge &#39;2.2.4.1&#39;})) { Install-Module PowerShellGet -Force }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;if(!(Get-Package msal.ps)) { Install-Package msal.ps }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;$Authed = AcquireToken $global:clientID $global:redirectUri $global:scopes $global:authority $false&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;if ($Authed -eq $false)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;do&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; ShowMenu&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; #Write-Host &quot;Enter your selection&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; $input = Read-Host &quot;Enter your selection&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; switch ($input)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;1&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments = MyJitAssignments&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $assignments | Format-Table -AutoSize -Wrap id,RoleName,ResourceName,ResourceType,ExpirationDate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;2&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Activate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;3&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Deactivate&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;4&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ListAssignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;5&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AssignmentEligible&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;6&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DelAssignment&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;7&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ListExpiringEligibleAssignments&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;8&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CancelRequest&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;9&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ListRoleSetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;10&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UpdateRoleSetting&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;11&#39;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;until ($input -eq &#39;11&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;Write-Host &quot;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;span style=&quot;box-sizing: border-box; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #333333;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/8386298919394054808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/8386298919394054808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/8386298919394054808'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2018/02/powershell-sample-for-privileged.html' title='PowerShell sample for Privileged Identity Management (PIM)'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ5aUbnhf_Qc49sPelG_ZWPqiWTVGw_tHxgJKQcpimE0_upnBMHrCof5iCDZiDSxGmwDa6V3i6xsSY9GYuZIJRM-Dc81DxgPN7pol6mOKurV-Krc3AHcXyVRbViBDM0I9nrHqHRcsoUvAs/s72-c/PS.JPG" height="72" width="72"/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-8438274688008549133</id><published>2017-07-05T10:40:00.000-07:00</published><updated>2017-07-05T10:40:17.999-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Entity Framework"/><category scheme="http://www.blogger.com/atom/ns#" term="newsequentialid"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Azure"/><title type='text'>NEWSEQUENTIALID() with Entity Framework and SQL Azure</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I was creating on a table in my database on SQL Azure which
had a GUID column as the primary key. I wanted to use NEWSEQUENTIALID()&amp;nbsp;instead
of NEWID() as the default value for the column because that would generate a sequentially
incrementing GUID instead of a random GUID and have better performance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
To do this in entity framework, I added &lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;DatabaseGenerated&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;DatabaseGeneratedOption&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;.Identity)] &lt;/span&gt;attribute on the on column.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I was also using code first migrations. To know more about
code first migrations, see &lt;a href=&quot;https://msdn.microsoft.com/en-us/data/jj591621.aspx&quot;&gt;https://msdn.microsoft.com/en-us/data/jj591621.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
This generates this script &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;c.Guid(nullable: &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;, identity: &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now when the database would be created in SQL Azure, the column
values were still random instead of being sequentially incrementing. But if the
same database was created locally on SQL server, the values were sequentially
incrementing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The fix was to change the script to&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;c.Guid(nullable: &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;, identity: &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;,
defaultValueSql: &lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas; font-size: 9.5pt; line-height: 107%; mso-bidi-font-family: Consolas;&quot;&gt;&quot;newsequentialid()&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 107%;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/8438274688008549133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2017/07/newsequentialid-with-entity-framework.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/8438274688008549133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/8438274688008549133'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2017/07/newsequentialid-with-entity-framework.html' title='NEWSEQUENTIALID() with Entity Framework and SQL Azure'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-3853849566123188857</id><published>2017-03-28T14:29:00.000-07:00</published><updated>2017-03-29T15:51:56.975-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure AD"/><category scheme="http://www.blogger.com/atom/ns#" term="Privileged Identity Management"/><title type='text'>Troubleshooting Elevated Permissions with Azure AD Privileged Identity Management</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here is my TechNet article&amp;nbsp;&lt;a href=&quot;https://social.technet.microsoft.com/wiki/contents/articles/37568.troubleshooting-elevated-permissions-with-azure-ad-privileged-identity-management.aspx&quot;&gt;https://social.technet.microsoft.com/wiki/contents/articles/37568.troubleshooting-elevated-permissions-with-azure-ad-privileged-identity-management.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/3853849566123188857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2017/03/troubleshooting-elevated-permissions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3853849566123188857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3853849566123188857'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2017/03/troubleshooting-elevated-permissions.html' title='Troubleshooting Elevated Permissions with Azure AD Privileged Identity Management'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-1643009305162503417</id><published>2016-12-22T12:41:00.000-08:00</published><updated>2016-12-22T13:42:48.081-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fiddler"/><category scheme="http://www.blogger.com/atom/ns#" term="localhost"/><category scheme="http://www.blogger.com/atom/ns#" term="port"/><category scheme="http://www.blogger.com/atom/ns#" term="redirect"/><title type='text'>Redirecting cloud service traffic to load host and port</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
When you are developing cloud services, sometimes you want
to debug the service which is hosted outside of your dev box.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The most common case is that there is a web portal which
talks to a web service. The web service is not behaving as expected and you
want to debug it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The easiest step is to add an entry in host file (%SystemRoot%\System32\drivers\etc\hosts)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
127.0.0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mywebservice.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now, when you open the web portal on your dev box, the web
service hosted on your dev box will be called and you can debug it by putting
breakpoints.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Now comes the interesting part. What if the web service on
your dev box is running on a specific port say &lt;a href=&quot;https://localhost:44310/&quot;&gt;https://localhost:44310/&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Just adding a host entry will not work since you want to
redirect the traffic to your host as well as port.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Fiddler comes to rescue here which can be downloaded from &lt;a href=&quot;http://www.telerik.com/fiddler&quot;&gt;http://www.telerik.com/fiddler&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
You need to do the following steps:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
1. No need to change the host file (%SystemRoot%\System32\drivers\etc\hosts)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
2. Open Fiddler&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
3. Go to Tools-&amp;gt;Host and add the below entry&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&amp;nbsp;localhost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mywebservice.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
4. Go to Rule-&amp;gt;Customize Rules and add the below snippet in static
function OnBeforeRequest(oSession: Session)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
if (oSession.HostnameIs(&quot;mywebservice.com&quot;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oSession.host=&quot;localhost:44310&quot;;&lt;br /&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
5.Restart Fiddler&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
That’s it, now when you open the web portal on your dev box,
the web service hosted on your dev box will be called and you can debug it by
putting breakpoints.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/1643009305162503417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2016/12/redirecting-cloud-service-traffic-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/1643009305162503417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/1643009305162503417'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2016/12/redirecting-cloud-service-traffic-to.html' title='Redirecting cloud service traffic to load host and port'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-1068126088452179353</id><published>2016-01-06T14:25:00.000-08:00</published><updated>2016-01-06T14:27:29.413-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aad"/><category scheme="http://www.blogger.com/atom/ns#" term="azure active directory"/><category scheme="http://www.blogger.com/atom/ns#" term="tenant id"/><category scheme="http://www.blogger.com/atom/ns#" term="tenant name"/><title type='text'>Azure Active Directory - Get Tenant Id from Tenant Name</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This question &quot;How do I get my Tenant Id?&quot; has come up several times so I though I will blog it.&lt;br /&gt;
&lt;br /&gt;
You can do that my going to&amp;nbsp;https://login.windows.net/TenantName/.well-known/openid-configuration where TenantName is the one of the domain name of your tenant.&lt;br /&gt;
&lt;br /&gt;
For example,&amp;nbsp;https://login.windows.net/anujc.onmicrosoft.com/.well-known/openid-configuration will return&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;white-space: pre-wrap; word-wrap: break-word;&quot;&gt;{&quot;authorization_endpoint&quot;:&quot;https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/authorize&quot;,&quot;token_endpoint&quot;:&quot;https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/token&quot;,&quot;token_endpoint_auth_methods_supported&quot;:[&quot;client_secret_post&quot;,&quot;private_key_jwt&quot;],&quot;jwks_uri&quot;:&quot;https://login.windows.net/common/discovery/keys&quot;,&quot;response_modes_supported&quot;:[&quot;query&quot;,&quot;fragment&quot;,&quot;form_post&quot;],&quot;subject_types_supported&quot;:[&quot;pairwise&quot;],&quot;id_token_signing_alg_values_supported&quot;:[&quot;RS256&quot;],&quot;response_types_supported&quot;:[&quot;code&quot;,&quot;id_token&quot;,&quot;code id_token&quot;,&quot;token id_token&quot;,&quot;token&quot;],&quot;scopes_supported&quot;:[&quot;openid&quot;],&quot;issuer&quot;:&quot;https://sts.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/&quot;,&quot;claims_supported&quot;:[&quot;sub&quot;,&quot;iss&quot;,&quot;aud&quot;,&quot;exp&quot;,&quot;iat&quot;,&quot;auth_time&quot;,&quot;acr&quot;,&quot;amr&quot;,&quot;nonce&quot;,&quot;email&quot;,&quot;given_name&quot;,&quot;family_name&quot;,&quot;nickname&quot;],&quot;microsoft_multi_refresh_token&quot;:true,&quot;check_session_iframe&quot;:&quot;https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/checksession&quot;,&quot;end_session_endpoint&quot;:&quot;https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/logout&quot;,&quot;userinfo_endpoint&quot;:&quot;https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/openid/userinfo&quot;}&lt;/pre&gt;
&lt;br /&gt;
This contains my Tenant Id&amp;nbsp;46650ea8-7413-4415-82c6-f891fc15a31e&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/1068126088452179353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2016/01/azure-active-directory-get-tenant-id.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/1068126088452179353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/1068126088452179353'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2016/01/azure-active-directory-get-tenant-id.html' title='Azure Active Directory - Get Tenant Id from Tenant Name'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-2202269433446040323</id><published>2015-09-29T09:46:00.002-07:00</published><updated>2015-09-29T09:46:30.080-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Selenium"/><category scheme="http://www.blogger.com/atom/ns#" term="web driver"/><title type='text'>Mastering Selenium WebDriver</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Reviewed book on Mastering Selenium WebDriver. You can find it here&amp;nbsp;&lt;a href=&quot;https://www.packtpub.com/web-development/mastering-selenium-webdriver&quot;&gt;https://www.packtpub.com/web-development/mastering-selenium-webdriver&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style=&quot;border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 233.75pt;&quot; valign=&quot;top&quot; width=&quot;312&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKE3VG69QdIoic4DxkHmGDuJg5xpgDMH3qB6niAepeYsxzYgcjb7Y0LnZiM1WNAINDKaoAefBs2_2vA3foTOPCeG2f54otaPGTaDSKGNjIFiQ244-t-sAKU2mPTE6TUvkdpfv27W1lWr5t/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKE3VG69QdIoic4DxkHmGDuJg5xpgDMH3qB6niAepeYsxzYgcjb7Y0LnZiM1WNAINDKaoAefBs2_2vA3foTOPCeG2f54otaPGTaDSKGNjIFiQ244-t-sAKU2mPTE6TUvkdpfv27W1lWr5t/s400/1.png&quot; width=&quot;306&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;

  &lt;/td&gt;
  &lt;td style=&quot;border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 233.75pt;&quot; valign=&quot;top&quot; width=&quot;312&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3-DESp0RrWyms3zf9hqt5xkV2CRs7SSmx2fmRm_H0TCVkXO6voszJ0o7TmrfxqiKD1mIoBlZzuDzmfq0jFWNuNTzgv8qWUHTPiw5I-8c6UJczFW785J88qJrDrIwpyeXqF7TV2mY31u9N/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3-DESp0RrWyms3zf9hqt5xkV2CRs7SSmx2fmRm_H0TCVkXO6voszJ0o7TmrfxqiKD1mIoBlZzuDzmfq0jFWNuNTzgv8qWUHTPiw5I-8c6UJczFW785J88qJrDrIwpyeXqF7TV2mY31u9N/s400/2.png&quot; width=&quot;310&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;

  &lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/2202269433446040323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2015/09/mastering-selenium-webdriver.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2202269433446040323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2202269433446040323'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2015/09/mastering-selenium-webdriver.html' title='Mastering Selenium WebDriver'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKE3VG69QdIoic4DxkHmGDuJg5xpgDMH3qB6niAepeYsxzYgcjb7Y0LnZiM1WNAINDKaoAefBs2_2vA3foTOPCeG2f54otaPGTaDSKGNjIFiQ244-t-sAKU2mPTE6TUvkdpfv27W1lWr5t/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-5547212608596020253</id><published>2015-09-28T14:45:00.000-07:00</published><updated>2015-09-28T14:45:23.436-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="azure"/><category scheme="http://www.blogger.com/atom/ns#" term="error"/><category scheme="http://www.blogger.com/atom/ns#" term="publish"/><title type='text'>One or more errors occurred while publishing Azure Cloud Service from Visual Studio</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently, I was trying to publish my Azure Cloud Service from Visual Studio and was getting an error &quot;One or more errors occurred&quot;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUor0px8_c7NkBI1lAglTYmLqGW8qiabKy0Q9zg5AG8mp0-8T-wutAux6JsU90YT_EsuZuMHAQdZ_wThbjXfe4B-7jwxOmYl0EByIUbbNIcnYlEOMco186Yl0HaJMuMq2rWS_V21o8-97w/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUor0px8_c7NkBI1lAglTYmLqGW8qiabKy0Q9zg5AG8mp0-8T-wutAux6JsU90YT_EsuZuMHAQdZ_wThbjXfe4B-7jwxOmYl0EByIUbbNIcnYlEOMco186Yl0HaJMuMq2rWS_V21o8-97w/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I couldn&#39;t find any more details in the Output window and was wondering what went wrong&lt;br /&gt;
Finally I looked at Server Explorer and it showed &quot;Reneter your credentials&quot;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitkflLtMwG-yqRG3ZhkZ907vQ3PhrF6bmTnxSWqZBJglUeBJH9vuBgNSXnLla1zRBMWahz1XMf0O2wTTbBqWd2xwOdLnFCxVMGseIH5jQCthEEm5Ztp_cLtS4dRF3nh2QY9gGGmM8n17RO/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitkflLtMwG-yqRG3ZhkZ907vQ3PhrF6bmTnxSWqZBJglUeBJH9vuBgNSXnLla1zRBMWahz1XMf0O2wTTbBqWd2xwOdLnFCxVMGseIH5jQCthEEm5Ztp_cLtS4dRF3nh2QY9gGGmM8n17RO/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After right clicking and re-entering the credentials, I was finally able to publish the cloud service.&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/5547212608596020253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2015/09/one-or-more-errors-occurred-while.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/5547212608596020253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/5547212608596020253'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2015/09/one-or-more-errors-occurred-while.html' title='One or more errors occurred while publishing Azure Cloud Service from Visual Studio'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUor0px8_c7NkBI1lAglTYmLqGW8qiabKy0Q9zg5AG8mp0-8T-wutAux6JsU90YT_EsuZuMHAQdZ_wThbjXfe4B-7jwxOmYl0EByIUbbNIcnYlEOMco186Yl0HaJMuMq2rWS_V21o8-97w/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-3837323094667114185</id><published>2015-08-28T16:26:00.001-07:00</published><updated>2016-01-06T14:25:52.517-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aad"/><category scheme="http://www.blogger.com/atom/ns#" term="AADSTS65001"/><title type='text'>AADSTS65001: No permission to access user information is configured for xxx&#39; application, or it is expired or revoked</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Recently, I had built an AAD application in my tenant with
the permission “Enable single sign-on and read user’s profile”. &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The application didn’t have admin consent so any time a user
would login to my site, he would be asked for consent. I had some users who had
consented to my app.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
After some time, I added another permission “Access Azure
Service Management” to my app and I was able to login fine. Users who had never
consented to my app earlier could also sign in. However, users who had already
consented to my app before I added the new permission started seeing this error
“AADSTS65001: No permission to access user information is configured for xxx&#39;
application, or it is expired or revoked. “&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I was really confused why the app works for some users but
not for others.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
After understanding the pattern that the error occurs only
for users who had already consented, I asked them to perform the following work
around:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to &lt;a href=&quot;https://myapps.microsoft.com/&quot;&gt;https://myapps.microsoft.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Remove the app&lt;/li&gt;
&lt;li&gt;Sign in again to the app in a fresh browser session&lt;/li&gt;
&lt;li&gt;Now you will see the consent prompt for two permission&lt;/li&gt;
&lt;li&gt;Grant consent&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
After this, all users were able to login successfully.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/3837323094667114185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2015/08/aadsts65001-no-permission-to-access.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3837323094667114185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/3837323094667114185'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2015/08/aadsts65001-no-permission-to-access.html' title='AADSTS65001: No permission to access user information is configured for xxx&#39; application, or it is expired or revoked'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-2836742193966877775</id><published>2015-03-31T14:27:00.000-07:00</published><updated>2015-03-31T14:28:21.072-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="FiddlerCore"/><category scheme="http://www.blogger.com/atom/ns#" term="intranet"/><title type='text'>FiddlerCore - ByPass Intranet Traffic</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Found a nice trick to bypass intranet traffic while using fiddler core.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas;&quot;&gt;CONFIG&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;.sHostsThatBypassFiddler = &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas;&quot;&gt;&quot;&amp;lt;local&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/2836742193966877775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2015/03/fiddlercore-bypass-intranet-traffic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2836742193966877775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/2836742193966877775'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2015/03/fiddlercore-bypass-intranet-traffic.html' title='FiddlerCore - ByPass Intranet Traffic'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-8562737001664193530</id><published>2015-02-27T13:49:00.002-08:00</published><updated>2015-02-27T13:49:51.793-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="subject"/><category scheme="http://www.blogger.com/atom/ns#" term="X509Certificate"/><title type='text'>Comparing X509Certificate Subject with User Input</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Recently I encountered an issue where I was comparing the
certificate name of an X509Certificate with a user input. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The issue was that the subject a user would see on the
certificate property has spaces in it &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;E.g. CN = xxx&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, when querying
the subject of an &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;X509Certificate2&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;
object, it won’t have any spaces in it&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;E.g. CN=xxx&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;This would make the subject comparison fail&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The fix was to use &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;X500DistinguishedName
&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;for comparison of subject. Below is a snippet&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;X509Certificate2&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; certificate = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;X509Certificate2&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;xxx.cer&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: x-small;&quot;&gt;// certificate.Subject results in CN=xxx&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;X500DistinguishedName&lt;/span&gt; certificateSubjectname = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;X500DistinguishedName&lt;/span&gt;(certificate.Subject);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;X500DistinguishedName&lt;/span&gt; configuredSubjectname = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;X500DistinguishedName&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;CN = xxx&quot;&lt;/span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; result = &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Equals(certificateSubjectname.Decode(&lt;span style=&quot;color: #2b91af;&quot;&gt;X500DistinguishedNameFlags&lt;/span&gt;.None),
configuredSubjectname.Decode(&lt;span style=&quot;color: #2b91af;&quot;&gt;X500DistinguishedNameFlags&lt;/span&gt;.None),
&lt;span style=&quot;color: #2b91af;&quot;&gt;StringComparison&lt;/span&gt;.CurrentCulture);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/8562737001664193530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2015/02/comparing-x509certificate-subject-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/8562737001664193530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/8562737001664193530'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2015/02/comparing-x509certificate-subject-with.html' title='Comparing X509Certificate Subject with User Input'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6043753706400514186.post-6346936284599008854</id><published>2014-11-24T14:56:00.001-08:00</published><updated>2014-11-24T14:56:52.909-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fiddler"/><category scheme="http://www.blogger.com/atom/ns#" term="https"/><category scheme="http://www.blogger.com/atom/ns#" term="iis express"/><category scheme="http://www.blogger.com/atom/ns#" term="localhost"/><title type='text'>Capturing traffic from .Net app to https://localhost using Fiddler</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently I was trying to capture traffic from my .Net help to a site hosted in IIS Express at &amp;nbsp;https://localhost:port&lt;br /&gt;
The issue was that fiddler wasn&#39;t capturing these requests. I found various alternatives like using IP address or machine name but that would results in certificate errors due to host name mismatch.&lt;br /&gt;
&lt;br /&gt;
Finally found the option of using https://localhost.fiddler:port instead of https://localhost:port which would then capture the traffic in Fiddler.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Anuj Chaudhary&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.anujchaudhary.com/feeds/6346936284599008854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.anujchaudhary.com/2014/11/capturing-traffic-from-net-app-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/6346936284599008854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6043753706400514186/posts/default/6346936284599008854'/><link rel='alternate' type='text/html' href='http://www.anujchaudhary.com/2014/11/capturing-traffic-from-net-app-to.html' title='Capturing traffic from .Net app to https://localhost using Fiddler'/><author><name>Anuj Chaudhary</name><uri>http://www.blogger.com/profile/17202872472362473841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbF5xPuNdmXcXiKKqcUCyPSkXiQ9jZ8yclVHVl3Q9Z7sgV6Ev30eBIXeoYJZowRh7guJ6PxWba4ZuC85ULR6ZUgV1kyLRAkBS4N5eU_UxzQU9QsHOrXUZ_yfHtcXuGRjA/s220/Anuj2.jpg'/></author><thr:total>0</thr:total></entry></feed>