Automatically disable On-prem AD User using a Playbook triggered in Azure

Published 02-09-2021 08:33 AM 4,908 Views
Microsoft

Many organizations have an on-premises Active Directory infrastructure that is synced to Azure AD in the cloud. However, given that the on-prem side is the authoritative source of truth, any changes, such as disabling a user in the cloud (Azure AD), are overridden by the setting defined in the on-prem AD during the next sync. This presents challenges when you want to orchestrate a user property change from Azure that needs to persist even after the sync happens.  To address the problem, this solution leverages the Automation Accounts and Hybrid Worker features across on-prem Windows resources & Azure . Automation Accounts can be used to perform cloud-based automation across Azure and non-Azure environments, including on Linux and Windows servers sitting in AWS, and GCP clouds so long as those machines have the Log Analytics agent installed.

 

Solution Overview

 

A typical use-case for this solution would flow as below:

 

i. Existing Azure Sentinel Analytics rule generates an incident requiring a user to be blocked from further domain access.

 

ii. The incident has the playbook attached to kick off the actions needed to block user access both on the cloud and on Azure AD

 

iii. The playbook includes the "create hybrid automation job" action, which executes a PowerShell script against the on-prem DC to block the user.

 

iv. User blocked in iii. above remains blocked even after subsequent Azure AD connect syncs with Azure cloud.

 

Deployment Steps

 

High-level summary

 

Before you begin to review the pre-requisites of deploying a Hybrid Runbook Worker here: Deploy a Windows Hybrid Runbook Worker in Azure Automation | Microsoft Docs

 

i. Create Automation Account

ii. Deploy the Automation Hybrid Worker solution from the Azure Market place

iii. Create a Hybrid Worker Group

iv. Create a new PowerShell Runbook.

v. Register the Hybrid Worker with Azure

vi. Test the Runbook.

vii. Deploy/build the Playbook.

viii. Attach the Playbook to the relevant Analytics rule in Azure Sentinel.

 

Detailed steps

 

1. Create an Automation Account from the Azure Portal

02-Automationacc.png

2. Deploy the Automation Hybrid Worker solution from the Azure Market place

03-marketplace.png

 

From the same Automation Account menu, create a Hybrid Worker Group.

 

06-HybridWorkerGroup.png

 

05-credentials.png

 

It is highly recommended that the account's permissions be restricted to the minimum required to disable user accounts using the Delegation userAccountControl bitmask. More details can be found here: UserAccountControl property flags - Windows Server | Microsoft Docs

To create a new PowerShell Runbook, navigate to your Automation Account and select the Runbooks blade.
 
05-createrunbook.png

 

Select PowerShell from the Runbook type menu and paste the below script in the resulting window. Click save, then publish to activate the Runbook.
 
Note: the script also includes code to report an error in case of a failure in the process of disabling the account:

 

 

Param (

[string] $SAMAccountName

)

if (Get-Module -ListAvailable -Name ActiveDirectory) {
    Write-Output "ActiveDirectory PowerShell module already exists on host."
} 
else {
    Write-Output "ActiveDirectory PowerShell module does not exist on host. Installing..."
    try {
        Import-Module ActiveDirectory
    }
    catch{
        Write-Error "Error installing ActiveDirectory PowerShell module."
        throw $_
        break
    }

    Write-Output "ActiveDirectory PowerShell module installed."
}

Write-Output "Finding and disabling user $SAMAccountName"
try {
    Get-ADUser -Identity $SAMAccountName | Disable-ADAccount
}
catch {
    Write-Error "Error disabling user account $SAMAccountName"
    throw $_
    break
}
Write-Output "Successfully disabled user account $SAMAccountName"

 

 

The script takes in a SAMAccountName parameter which it uses to find the appropriate user and disable the account. This script can be modified to do various other tasks, such as password resets, adding/removing users to/from groups, etc.


Create a test user in Active Directory, then perform the steps in the on-prem machine to install the Hybrid Worker feature.

Deploy the below script from this URL: PowerShell Gallery | New-OnPremiseHybridWorker 1.7. Depending on the PowerShell module currently installed on your machine, you may need to download the file manually. If you do so, you will need to rename the extension to a .zip file first, then extract it to the directory you’ll execute the script from.

This script performs the following actions:
1) Install the necessary modules
2) Login to an Azure account
3) Check for the resource group and automation account
4) Create references to automation account attributes
5) Create a Log Analytics Workspace if needed
6) Enable the Azure Automation solution in Log Analytics
7) Download and install the Microsoft Monitoring Agent
8) Register the machine as a hybrid worker

To register your HybridWorker in Azure, add your hybrid runbook's details into the parameters to be passed to the creation command. Execute the below statement at your PowerShell prompt:
$NewOnPremiseHybridWorkerParameters = @{
AutomationAccountName = "iwauto"
AAResourceGroupName = "AD-Onprem"
OMSResourceGroupName = "AD-Onprem"
HybridGroupName = "AutoGroup"
SubscriptionID = "xxxxxxxxxxxxxxxx"
WorkspaceName = "iwautola"}
 
From the same PowerShell command prompt type: Install-Script -Name New-OnPremiseHybridWorker which will use parameters specified above.
This command will open a log-on screen to Azure Portal to register the Hybrid Worker in Azure.
 
The command will use the parameters specified above to register your Hybrid Worker Group in your Azure Subscription. You can learn more about the process of deploying Hybrid Workers here: Deploy a Windows Hybrid Runbook Worker in Azure Automation | Microsoft Docs

The command will open a logon screen in Azure Portal to register the Hybrid Worker in Azure.

 

07-azurereg.png

To confirm successful registration, navigate to your automation account, then select Hybrid worker groups. You should see the recently registered Hybrid Worker Group in the list in the below screenshot.

 

08-HybridWorker.png

 

If you get the error indicating that the PowerShell file is not digitally signed, then you will need to execute the command below:
Set-ExecutionPolicy RemoteSigned
 
You may still have to unblock the file in case changing the execution policy alone does not work. The command to do this is from a PowerShell prompt is:
Unblock-File -Path .\New-OmPremiseHybridWorker.ps1

It is also recommended that you use TLS versions more recent than 1.0 and 1.1. For this reason, you may be required to run the below command as well:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
 
You can learn more about the process of deploying Hybrid Workers here:
 
On successful registration, you should see an output similar to the below:
08-successoutput.png
To confirm successful registration, navigate to your automation account, then select Hybrid worker groups. You should see the recently registered hybrid worker group in the list in the below screenshot.
 
08-HybridWorker.png
 
 
Test the Runbook
To ensure the Runbook is working ok before integrating with a Logic App, execute the Runbook manually from the Azure Portal and specify a test account in the SAMAccountName box, select HybridWorker in the Run Settings section and then choose your Hybrid Worker group name from the drop-down list:
 
09-manualtest.png
 

 

Steps to orchestrate from Azure Sentinel/Logic Apps

Below is the structure of the orchestration Logic App that triggers the runbook to disable qualifying accounts from the On-Prem AD. With this action, the next on-prem to cloud AD sync will maintain the state on the account – in this case disabled, until the setting is reversed from the on-prem AD Users & Computers management console.

The high-Level structure of the Playbook

10-LogicAppOverview.png

 

The detailed structure of the Playbook:

Extract entity details (to capture user ID) following trigger execution

Createjob.png

Parse the JSON output from the Entities-Get Actions step above to extract the Azure User ID and SAM Account name needed to perform disable operations-first on Azure then on the On-Prem Active directory.

 

ParseJSON.png

 

Disable Account in Azure AD

DisableonAzureAD.png

 

Create Hybrid Automation Job
Createjob.png
 
The string function below is contained in the 'Runbook Parameter SamAccountName' above and is needed to extract the SAMAccount from the UPN of the user as the On-Prem AD can only act on the User ID when specified in this format:

substring(body('Parse_JSON')?['Name'], 0, sub(length(body('Parse_JSON')?['Name']),indexOf(body('Parse_JSON')?['Name'],'@')))

To simulate the block orchestration from Azure Sentinel, you may use the below sample query to create an Analytics rule that will detect a failed logon due to a wrong password entered on the Azure AD portal. You can then simulate failed logon attempts with the account you wish to test with.

SigninLogs
| where Location == "KE" and Identity contains "mytestaccount" and ResultType =="50126"
| extend AccountCustomEntity = AlternateSignInName

Troubleshooting guide for Hybrid Runbook Workers can be found here: Troubleshoot Azure Automation Hybrid Runbook Worker issues | Microsoft Docs
 

 

This Playbook can be deployed directly from GitHub on this link: Azure-Sentinel/Playbooks/Block-OnPremADUser at master · Azure/Azure-Sentinel (github.com)

 

Troubleshooting guide: Troubleshoot Azure Automation Hybrid Runbook Worker issues | Microsoft Docs

Special thanks to @haelshab for his valuable collaboration in this project & @Yaniv Shasha for suggestions to enhance the solution

 

 

3 Comments
Microsoft

Hello, 

 

Just to add that in case of ActiveDirectory module not present on the hybrid worker, the script cannot do the install by simple Import-Module, as this is only used for importing something already installedm and script will fail on the hybrid worker.

To have the ActiveDirectory module installed, you need to follow the documentations, ActiveDirectory Module | Microsoft Docs

 

"If you don't have the Active Directory module installed on your machine, you need to download the correct Remote Server Administration Tools (RSAT) package for your OS: Remote Server Administration Tools - Windows Server | Microsoft Docs"

 

Thank you,

 

Occasional Visitor

Hello

 

Do you have the following information

 

" Parse the JSON output from the Entities-Get Actions step above to extract the Azure User ID and SAM Account name needed to perform disable operations-first on Azure then on the On-Prem Active directory."   The picture is little blurry and I cant see the information. 

Occasional Visitor

@Dhaval ShastriIn our case we used this:

 

{
    "properties": {
        "$id": {
            "type""string"
        },
        "AadUserId": {
            "type""string"
        },
        "DisplayName": {
            "type""string"
        },
        "Name": {
            "type""string"
        },
        "Type": {
            "type""string"
        }
    },
    "type""object"
}
 
I recommend you to deploy it using the code provided in GitHub since there are some steps missing in this article. Then you can modify the Playbook at your convenience. That is how I did it and it works great!
%3CLINGO-SUB%20id%3D%22lingo-sub-2098272%22%20slang%3D%22en-US%22%3EAutomatically%20disable%20On-prem%20AD%20User%20using%20a%20Playbook%20triggered%20in%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2098272%22%20slang%3D%22en-US%22%3E%3CP%3EMany%20organizations%20have%20an%20on-premises%20Active%20Directory%20infrastructure%20that%20is%20synced%20to%20Azure%20AD%20in%20the%20cloud.%20However%2C%20given%20that%20the%20on-prem%20side%20is%20the%20authoritative%20source%20of%20truth%2C%20any%20changes%2C%20such%20as%20disabling%20a%20user%20in%20the%20cloud%20(Azure%20AD)%2C%20are%20overridden%20by%20the%20setting%20defined%20in%20the%20on-prem%20AD%20during%20the%20next%20sync.%20This%20presents%20challenges%20when%20you%20want%20to%20orchestrate%20a%20user%20property%20change%20from%20Azure%20that%20needs%20to%20persist%20even%20after%20the%20sync%20happens.%26nbsp%3B%20To%20address%20the%20problem%2C%20this%20solution%20leverages%20the%20Automation%20Accounts%20and%20Hybrid%20Worker%20features%20across%20on-prem%20Windows%20resources%20%26amp%3B%20Azure%20.%20Automation%20Accounts%20can%20be%20used%20to%20perform%20cloud-based%20automation%20across%20Azure%20and%20non-Azure%20environments%2C%20including%20on%20Linux%20and%20Windows%20servers%20sitting%20in%20AWS%2C%20and%20GCP%20clouds%20so%20long%20as%20those%20machines%20have%20the%20Log%20Analytics%20agent%20installed.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--549033957%22%20id%3D%22toc-hId--549033957%22%20id%3D%22toc-hId--549033957%22%20id%3D%22toc-hId--549039696%22%3E%3CSTRONG%3ESolution%20Overview%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20typical%20use-case%20for%20this%20solution%20would%20flow%20as%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ei.%20Existing%20Azure%20Sentinel%20Analytics%20rule%20generates%20an%20incident%20requiring%20a%20user%20to%20be%20blocked%20from%20further%20domain%20access.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eii.%20The%20incident%20has%20the%20playbook%20attached%20to%20kick%20off%20the%20actions%20needed%20to%20block%20user%20access%20both%20on%20the%20cloud%20and%20on%20Azure%20AD%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eiii.%20The%20playbook%20includes%20the%20%22%3CSTRONG%3Ecreate%20hybrid%20automation%20job%3C%2FSTRONG%3E%22%20action%2C%20which%20executes%20a%20PowerShell%20script%20against%20the%20on-prem%20DC%20to%20block%20the%20user.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eiv.%20User%20blocked%20in%20iii.%20above%20remains%20blocked%20even%20after%20subsequent%20Azure%20AD%20connect%20syncs%20with%20Azure%20cloud.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1938478876%22%20id%3D%22toc-hId-1938478876%22%20id%3D%22toc-hId-1938478876%22%20id%3D%22toc-hId-1938473137%22%3E%3CSTRONG%3EDeployment%20Steps%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1665926946%22%20id%3D%22toc-hId--1665926946%22%20id%3D%22toc-hId--1665926946%22%20id%3D%22toc-hId--1665932685%22%3E%3CSTRONG%3EHigh-level%20summary%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2014.0pt%3B%20font-family%3A%20'Segoe%20UI%20Light'%2Csans-serif%3B%22%3EBefore%20you%20begin%20to%20review%20the%20pre-requisites%20of%20deploying%20a%20Hybrid%20Runbook%20Worker%20here%3A%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-windows-hrw-install%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20style%3D%22font-size%3A%2014.0pt%3B%20font-family%3A%20'Segoe%20UI%20Light'%2Csans-serif%3B%22%3EDeploy%20a%20Windows%20Hybrid%20Runbook%20Worker%20in%20Azure%20Automation%20%7C%20Microsoft%20Docs%3C%2FSPAN%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ei.%20Create%20Automation%20Account%3C%2FP%3E%0A%3CP%3Eii.%20Deploy%20the%20Automation%20Hybrid%20Worker%20solution%20from%20the%20Azure%20Market%20place%3C%2FP%3E%0A%3CP%3Eiii.%20Create%20a%20Hybrid%20Worker%20Group%3C%2FP%3E%0A%3CP%3Eiv.%20Create%20a%20new%20PowerShell%20Runbook.%3C%2FP%3E%0A%3CP%3Ev.%20Register%20the%20Hybrid%20Worker%20with%20Azure%3C%2FP%3E%0A%3CP%3Evi.%20Test%20the%20Runbook.%3C%2FP%3E%0A%3CP%3Evii.%20Deploy%2Fbuild%20the%20Playbook.%3C%2FP%3E%0A%3CP%3Eviii.%20Attach%20the%20Playbook%20to%20the%20relevant%20Analytics%20rule%20in%20Azure%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-821585887%22%20id%3D%22toc-hId-821585887%22%20id%3D%22toc-hId-821585887%22%20id%3D%22toc-hId-821580148%22%3E%3CSTRONG%3EDetailed%20steps%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Create%20an%20Automation%20Account%20from%20the%20Azure%20Portal%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2202-Automationacc.png%22%20style%3D%22width%3A%20361px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249517iDA860E0D6EB3F4AB%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2202-Automationacc.png%22%20alt%3D%2202-Automationacc.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E2.%20Deploy%20the%20Automation%20Hybrid%20Worker%20solution%20from%20the%20Azure%20Market%20place%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2014.0pt%3B%20font-family%3A%20'Segoe%20UI%20Light'%2Csans-serif%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2203-marketplace.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249518iFCE750C20BD8777C%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2203-marketplace.png%22%20alt%3D%2203-marketplace.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EFrom%20the%20same%20Automation%20Account%20menu%2C%20create%20a%20Hybrid%20Worker%20Group.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2206-HybridWorkerGroup.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251692i25F70659302D5367%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2206-HybridWorkerGroup.png%22%20alt%3D%2206-HybridWorkerGroup.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2205-credentials.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249521i174DF1760A0029E7%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2205-credentials.png%22%20alt%3D%2205-credentials.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EIt%20is%20highly%20recommended%20that%20the%20account's%20permissions%20be%20restricted%20to%20the%20minimum%20required%20to%20disable%20user%20accounts%20using%20the%20Delegation%20userAccountControl%20bitmask.%20More%20details%20can%20be%20found%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Ftroubleshoot%2Fwindows-server%2Fidentity%2Fuseraccountcontrol-manipulate-account-properties%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EUserAccountControl%20property%20flags%20-%20Windows%20Server%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETo%20create%20a%20new%20PowerShell%20Runbook%2C%20navigate%20to%20your%20Automation%20Account%20and%20select%20the%20Runbooks%20blade.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2205-createrunbook.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251693i7A204B41FC0F0758%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2205-createrunbook.png%22%20alt%3D%2205-createrunbook.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3ESelect%20PowerShell%20from%20the%20Runbook%20type%20menu%20and%20paste%20the%20below%20script%20in%20the%20resulting%20window.%20Click%20save%2C%20then%20publish%20to%20activate%20the%20Runbook.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3ENote%3A%20the%20script%20also%20includes%20code%20to%20report%20an%20error%20in%20case%20of%20a%20failure%20in%20the%20process%20of%20disabling%20the%20account%3A%3C%2FEM%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3EParam%20(%0A%0A%5Bstring%5D%20%24SAMAccountName%0A%0A)%0A%0Aif%20(Get-Module%20-ListAvailable%20-Name%20ActiveDirectory)%20%7B%0A%20%20%20%20Write-Output%20%22ActiveDirectory%20PowerShell%20module%20already%20exists%20on%20host.%22%0A%7D%20%0Aelse%20%7B%0A%20%20%20%20Write-Output%20%22ActiveDirectory%20PowerShell%20module%20does%20not%20exist%20on%20host.%20Installing...%22%0A%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20Import-Module%20ActiveDirectory%0A%20%20%20%20%7D%0A%20%20%20%20catch%7B%0A%20%20%20%20%20%20%20%20Write-Error%20%22Error%20installing%20ActiveDirectory%20PowerShell%20module.%22%0A%20%20%20%20%20%20%20%20throw%20%24_%0A%20%20%20%20%20%20%20%20break%0A%20%20%20%20%7D%0A%0A%20%20%20%20Write-Output%20%22ActiveDirectory%20PowerShell%20module%20installed.%22%0A%7D%0A%0AWrite-Output%20%22Finding%20and%20disabling%20user%20%24SAMAccountName%22%0Atry%20%7B%0A%20%20%20%20Get-ADUser%20-Identity%20%24SAMAccountName%20%7C%20Disable-ADAccount%0A%7D%0Acatch%20%7B%0A%20%20%20%20Write-Error%20%22Error%20disabling%20user%20account%20%24SAMAccountName%22%0A%20%20%20%20throw%20%24_%0A%20%20%20%20break%0A%7D%0AWrite-Output%20%22Successfully%20disabled%20user%20account%20%24SAMAccountName%22%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20script%20takes%20in%20a%20%3CSTRONG%3ESAMAccountName%3C%2FSTRONG%3E%20parameter%20which%20it%20uses%20to%20find%20the%20appropriate%20user%20and%20disable%20the%20account.%20This%20script%20can%20be%20modified%20to%20do%20various%20other%20tasks%2C%20such%20as%20password%20resets%2C%20adding%2Fremoving%20users%20to%2Ffrom%20groups%2C%20etc.%3C%2FP%3E%0A%3CDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ECreate%20a%20test%20user%20in%20Active%20Directory%2C%20then%20perform%20the%20steps%20in%20the%20on-prem%20machine%20to%20install%20the%20Hybrid%20Worker%20feature.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EDeploy%20the%20below%20script%20from%20this%20URL%3A%20PowerShell%20Gallery%20%7C%20New-OnPremiseHybridWorker%201.7.%20Depending%20on%20the%20PowerShell%20module%20currently%20installed%20on%20your%20machine%2C%20you%20may%20need%20to%20download%20the%20file%20manually.%20If%20you%20do%20so%2C%20you%20will%20need%20to%20rename%20the%20extension%20to%20a%20.zip%20file%20first%2C%20then%20extract%20it%20to%20the%20directory%20you%E2%80%99ll%20execute%20the%20script%20from.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3EThis%20script%20performs%20the%20following%20actions%3C%2FSTRONG%3E%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E1)%20Install%20the%20necessary%20modules%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E2)%20Login%20to%20an%20Azure%20account%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E3)%20Check%20for%20the%20resource%20group%20and%20automation%20account%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E4)%20Create%20references%20to%20automation%20account%20attributes%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E5)%20Create%20a%20Log%20Analytics%20Workspace%20if%20needed%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E6)%20Enable%20the%20Azure%20Automation%20solution%20in%20Log%20Analytics%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E7)%20Download%20and%20install%20the%20Microsoft%20Monitoring%20Agent%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E8)%3C%2Fimg%3E%20Register%20the%20machine%20as%20a%20hybrid%20worker%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETo%20register%20your%20HybridWorker%20in%20Azure%2C%20add%20your%20hybrid%20runbook's%20details%20into%20the%20parameters%20to%20be%20passed%20to%20the%20creation%20command.%20Execute%20the%20below%20statement%20at%20your%20PowerShell%20prompt%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%24NewOnPremiseHybridWorkerParameters%20%3D%20%40%7B%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20AutomationAccountName%20%3D%20%22iwauto%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20AAResourceGroupName%20%3D%20%22AD-Onprem%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20OMSResourceGroupName%20%3D%20%22AD-Onprem%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20HybridGroupName%20%3D%20%22AutoGroup%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20SubscriptionID%20%3D%20%22xxxxxxxxxxxxxxxx%22%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20WorkspaceName%20%3D%20%22iwautola%22%7D%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EFrom%20the%20same%20PowerShell%20command%20prompt%20type%3A%20%3CEM%3EInstall-Script%20-Name%20New-OnPremiseHybridWorker%3C%2FEM%3E%3C%2FSPAN%3E%3CSPAN%3E%20which%20will%20use%20parameters%20specified%20above.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EThis%20command%20will%20open%20a%20log-on%20screen%20to%20Azure%20Portal%20to%20register%20the%20Hybrid%20Worker%20in%20Azure.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EThe%20command%20will%20use%20the%20parameters%20specified%20above%20to%20register%20your%20Hybrid%20Worker%20Group%20in%20your%20Azure%20Subscription.%20You%20can%20learn%20more%20about%20the%20process%20of%20deploying%20Hybrid%20Workers%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-windows-hrw-install%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDeploy%20a%20Windows%20Hybrid%20Runbook%20Worker%20in%20Azure%20Automation%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EThe%20command%20will%20open%20a%20logon%20screen%20in%20Azure%20Portal%20to%20register%20the%20Hybrid%20Worker%20in%20Azure.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2207-azurereg.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249528i40A8F40544858440%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2207-azurereg.png%22%20alt%3D%2207-azurereg.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ETo%20confirm%20successful%20registration%2C%20navigate%20to%20your%20automation%20account%2C%20then%20select%20Hybrid%20worker%20groups.%20You%20should%20see%20the%20recently%20registered%20Hybrid%20Worker%20Group%20in%20the%20list%20in%20the%20below%20screenshot.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2208-HybridWorker.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249535iFDFE6B035EFB81E1%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2208-HybridWorker.png%22%20alt%3D%2208-HybridWorker.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3EIf%20you%20get%20the%20error%20indicating%20that%20the%20PowerShell%20file%20is%20not%20digitally%20signed%2C%20then%20you%20will%20need%20to%20execute%20the%20command%20below%3A%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3ESet-ExecutionPolicy%20RemoteSigned%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EYou%20may%20still%20have%20to%20unblock%20the%20file%20in%20case%20changing%20the%20execution%20policy%20alone%20does%20not%20work.%20The%20command%20to%20do%20this%20is%20from%20a%20PowerShell%20prompt%20is%3A%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3EUnblock-File%20-Path%20.%5CNew-OmPremiseHybridWorker.ps1%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3EMore%20details%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmicrosoft.powershell.security%2Fset-executionpolicy%3Fview%3Dpowershell-7.1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESet-ExecutionPolicy%20(Microsoft.PowerShell.Security)%20-%20PowerShell%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3EIt%20is%20also%20recommended%20that%20you%20use%20TLS%20versions%20more%20recent%20than%201.0%20and%201.1.%20For%20this%20reason%2C%20you%20may%20be%20required%20to%20run%20the%20below%20command%20as%20well%3A%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CEM%3E%5BNet.ServicePointManager%5D%3A%3ASecurityProtocol%20%3D%20%5BNet.SecurityProtocolType%5D%3A%3ATls12%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EYou%20can%20learn%20more%20about%20the%20process%20of%20deploying%20Hybrid%20Workers%20here%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-windows-hrw-install%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDeploy%20a%20Windows%20Hybrid%20Runbook%20Worker%20in%20Azure%20Automation%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EOn%20successful%20registration%2C%20you%20should%20see%20an%20output%20similar%20to%20the%20below%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2208-successoutput.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251696i0195108571F908E9%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2208-successoutput.png%22%20alt%3D%2208-successoutput.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3ETo%20confirm%20successful%20registration%2C%20navigate%20to%20your%20automation%20account%2C%20then%20select%20Hybrid%20worker%20groups.%20You%20should%20see%20the%20recently%20registered%20hybrid%20worker%20group%20in%20the%20list%20in%20the%20below%20screenshot.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2208-HybridWorker.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251697i8BC9C40C9C019DB7%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2208-HybridWorker.png%22%20alt%3D%2208-HybridWorker.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSTRONG%3ETest%20the%20Runbook%3C%2FSTRONG%3E%20%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3ETo%20ensure%20the%20Runbook%20is%20working%20ok%20before%20integrating%20with%20a%20Logic%20App%2C%20execute%20the%20Runbook%20manually%20from%20the%20Azure%20Portal%20and%20specify%20a%20test%20account%20in%20the%20%3CSTRONG%3ESAMAccountName%3C%2FSTRONG%3E%20box%2C%20select%20HybridWorker%20in%20the%20Run%20Settings%20section%20and%20then%20choose%20your%20Hybrid%20Worker%20group%20name%20from%20the%20drop-down%20list%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2209-manualtest.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251698iC07C2C73A0407D68%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2209-manualtest.png%22%20alt%3D%2209-manualtest.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESteps%20to%20orchestrate%20from%20Azure%20Sentinel%2FLogic%20Apps%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EBelow%20is%20the%20structure%20of%20the%20orchestration%20Logic%20App%20that%20triggers%20the%20runbook%20to%20disable%20qualifying%20accounts%20from%20the%20On-Prem%20AD.%20With%20this%20action%2C%20the%20next%20on-prem%20to%20cloud%20AD%20sync%20will%20maintain%20the%20state%20on%20the%20account%20%E2%80%93%20in%20this%20case%20disabled%2C%20until%20the%20setting%20is%20reversed%20from%20the%20on-prem%20AD%20Users%20%26amp%3B%20Computers%20management%20console.%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSTRONG%3EThe%20high-Level%20structure%20of%20the%20Playbook%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%2210-LogicAppOverview.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249539i3D10D73CF018DCC8%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%2210-LogicAppOverview.png%22%20alt%3D%2210-LogicAppOverview.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorInnocent%20Wafula_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CH3%20id%3D%22toc-hId--985868576%22%20id%3D%22toc-hId--985868576%22%20id%3D%22toc-hId--985868576%22%20id%3D%22toc-hId--985874315%22%3E%3CSTRONG%3EThe%20detailed%20structure%20of%20the%20Playbook%3A%3C%2FSTRONG%3E%3C%2FH3%3E%0A%3CDIV%3E%3CSTRONG%3EExtract%20entity%20details%20(to%20capture%20user%20ID)%20following%20trigger%20execution%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Createjob.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251708iAD6AF4E9F941C6BA%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Createjob.png%22%20alt%3D%22Createjob.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EParse%20the%20JSON%20output%20from%20the%20Entities-Get%20Actions%20step%20above%20to%20extract%20the%20Azure%20User%20ID%20and%20SAM%20Account%20name%20needed%20to%20perform%20disable%20operations-first%20on%20Azure%20then%20on%20the%20On-Prem%20Active%20directory.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ParseJSON.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251709i2520F3E7F62E78F9%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ParseJSON.png%22%20alt%3D%22ParseJSON.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDisable%20Account%20in%20Azure%20AD%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22DisableonAzureAD.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251715i96CF92BC125DB50B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22DisableonAzureAD.png%22%20alt%3D%22DisableonAzureAD.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSTRONG%3ECreate%20Hybrid%20Automation%20Job%20%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Createjob.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F251717i4D5821ECCBE01189%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Createjob.png%22%20alt%3D%22Createjob.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EThe%20string%20function%20below%20is%20contained%20in%20the%20'Runbook%20Parameter%20SamAccountName'%20above%20and%20is%20needed%20to%20extract%20the%20SAMAccount%20from%20the%20UPN%20of%20the%20user%20as%20the%20On-Prem%20AD%20can%20only%20act%20on%20the%20User%20ID%20when%20specified%20in%20this%20format%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3E%20substring(body('Parse_JSON')%3F%5B'Name'%5D%2C%200%2C%20sub(length(body('Parse_JSON')%3F%5B'Name'%5D)%2CindexOf(body('Parse_JSON')%3F%5B'Name'%5D%2C'%40')))%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETo%20simulate%20the%20block%20orchestration%20from%20Azure%20Sentinel%2C%20you%20may%20use%20the%20below%20sample%20query%20to%20create%20an%20Analytics%20rule%20that%20will%20detect%20a%20failed%20logon%20due%20to%20a%20wrong%20password%20entered%20on%20the%20Azure%20AD%20portal.%20You%20can%20then%20simulate%20failed%20logon%20attempts%20with%20the%20account%20you%20wish%20to%20test%20with.%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CEM%3E%20SigninLogs%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%20%7C%20where%20Location%20%3D%3D%20%22KE%22%20and%20Identity%20contains%20%22mytestaccount%22%20and%20ResultType%20%3D%3D%2250126%22%3C%2FEM%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CEM%3E%20%7C%20extend%20AccountCustomEntity%20%3D%20AlternateSignInName%3C%2FEM%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETroubleshooting%20guide%20for%20Hybrid%20Runbook%20Workers%20can%20be%20found%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Ftroubleshoot%2Fhybrid-runbook-worker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ETroubleshoot%20Azure%20Automation%20Hybrid%20Runbook%20Worker%20issues%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20Playbook%20can%20be%20deployed%20directly%20from%20GitHub%20on%20this%20link%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Ftree%2Fmaster%2FPlaybooks%2FBlock-OnPremADUser%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure-Sentinel%2FPlaybooks%2FBlock-OnPremADUser%20at%20master%20%C2%B7%20Azure%2FAzure-Sentinel%20(github.com)%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETroubleshooting%20guide%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Ftroubleshoot%2Fhybrid-runbook-worker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ETroubleshoot%20Azure%20Automation%20Hybrid%20Runbook%20Worker%20issues%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CEM%3ESpecial%20thanks%20to%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F640765%22%20target%3D%22_blank%22%3E%40haelshab%3C%2FA%3E%20for%20his%20valuable%20collaboration%20in%20this%20project%20%26amp%3B%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F185177%22%20target%3D%22_blank%22%3E%40Yaniv%20Shasha%3C%2FA%3E%20for%20suggestions%20to%20enhance%20the%20solution%3C%2FEM%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2098272%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EThis%20blog%20details%20how%20to%20ensure%20persistence%20on%20AD-On%20Prem%20when%20a%20user%20account%20is%20blocked%20from%20Azure%20AD%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%2201-overview.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F261876i0B549866545F9D75%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%2201-overview.png%22%20alt%3D%22Azure%20Sentinel%20overview%20page%20with%20an%20Hybrid%20worker%20schematic%20diagram%20overlaid%20on%20top%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAzure%20Sentinel%20overview%20page%20with%20an%20Hybrid%20worker%20schematic%20diagram%20overlaid%20on%20top%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2098272%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAD%20Connect%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAD%20sync%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAutomation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAWS%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Arc%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EGCP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIdentity%20Management%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESOAR%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2246735%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20disable%20On-prem%20AD%20User%20using%20a%20Playbook%20triggered%20in%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2246735%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJust%20to%20add%20that%20in%20case%20of%20ActiveDirectory%20module%20not%20present%20on%20the%20hybrid%20worker%2C%20the%20script%20cannot%20do%20the%20install%20by%20simple%20Import-Module%2C%20as%20this%20is%20only%20used%20for%20importing%20something%20already%20installedm%20and%20script%20will%20fail%20on%20the%20hybrid%20worker.%3C%2FP%3E%0A%3CP%3ETo%20have%20the%20ActiveDirectory%20module%20installed%2C%20you%20need%20to%20follow%20the%20documentations%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Faddsadministration%2F%3Fview%3Dwindowsserver2019-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EActiveDirectory%20Module%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%22If%20you%20don't%20have%20the%20Active%20Directory%20module%20installed%20on%20your%20machine%2C%20you%20need%20to%20download%20the%20correct%20Remote%20Server%20Administration%20Tools%20(RSAT)%20package%20for%20your%20OS%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-US%2Ftroubleshoot%2Fwindows-server%2Fsystem-management-components%2Fremote-server-administration-tools%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ERemote%20Server%20Administration%20Tools%20-%20Windows%20Server%20%7C%20Microsoft%20Docs%22%3C%2FA%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThank%20you%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2301796%22%20slang%3D%22en-US%22%3ERe%3A%20Automatically%20disable%20On-prem%20AD%20User%20using%20a%20Playbook%20triggered%20in%20Azure%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2301796%22%20slang%3D%22en-US%22%3E%3CP%3EHello%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20have%20the%20following%20information%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%22%20Parse%20the%20JSON%20output%20from%20the%20Entities-Get%20Actions%20step%20above%20to%20extract%20the%20Azure%20User%20ID%20and%20SAM%20Account%20name%20needed%20to%20perform%20disable%20operations-first%20on%20Azure%20then%20on%20the%20On-Prem%20Active%20directory.%22%26nbsp%3B%20%26nbsp%3BThe%20picture%20is%20little%20blurry%26nbsp%3Band%20I%20cant%20see%20the%20information.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎Mar 08 2021 11:41 PM
Updated by: