%3CLINGO-SUB%20id%3D%22lingo-sub-1723012%22%20slang%3D%22en-US%22%3EHow%20To%20Flush%20Microsoft%20Monitoring%20Agent%20Cache%20Using%20Azure%20Automation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1723012%22%20slang%3D%22en-US%22%3E%3CP%3EGreetings%20from%20Bruno%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fhtml%2Fimages%2Femoticons%2Fsmile_40x40.gif%22%20alt%3D%22%3Asmile%3A%22%20title%3D%22%3Asmile%3A%22%20%2F%3E%3C%2FP%3E%0A%3CP%3EThe%20question%20of%20the%20day%20is%20how%20can%20we%20make%20sure%20our%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fagents-overview%23log-analytics-agent%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELog%20Analytics%20agent%3C%2FA%3E%20(aka%20Microsoft%20Monitoring%20Agent%20(MMA))%20is%20always%20working%20properly%20to%20include%20an%20up%20to%20date%20configuration%3F%3C%2FP%3E%0A%3CP%3EHave%20you%20ever%20experienced%20a%20situation%20in%20which%20the%20MMA%20service%20was%20running%20but%20doing%20really%20nothing%3F%20Similar%20to%20a%20grey%20agent%20when%20referring%20to%20System%20Center%20Operations%20Manager%20(SCOM)%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhy%20flushing%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThere%20are%20several%20reasons%20why%20we%E2%80%99d%20want%20to%20flush%20the%20MMA%20cache.%20The%20most%20common%20being%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EHeartbeat%20failure%3C%2FLI%3E%0A%3CLI%3EInvalid%20configuration%3C%2FLI%3E%0A%3CLI%3ESystem%20workflows%20failure%3C%2FLI%3E%0A%3CLI%3ENetwork%20or%20authentication%20issues%3C%2FLI%3E%0A%3CLI%3EHealth%20service%20issues%20(service%20is%20not%20running)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EInevitably%2C%20it%20almost%20always%20comes%20down%20to%20your%20MMA(s)%20not%20working%20as%20expected.%3C%2FP%3E%0A%3CP%3EIf%20you%E2%80%99re%20curious%20to%20learn%20more%20about%20how%20and%20when%20to%20flush%20the%20MMA%20cache%2C%20take%20a%20look%20at%20the%20%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsystem-center%2Fscom%2Fmanage-clear-healthservice-cache%3Fview%3Dsc-om-2019%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHow%20and%20When%20to%20Clear%20the%20Cache%3C%2FA%3E%3C%2FEM%3E%26nbsp%3BMicrosoft%20article%20for%20more%20details.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20to%20flush%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAccording%20to%20many%20online%20blogs%20and%20documentation%2C%20you%20have%20probably%20learned%20by%20now%20that%20flushing%20the%20MMA%20cache%20is%20quite%20easy.%20In%20a%20nutshell%2C%20here%20is%20what%20that%20entails%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EStop%20the%20%3CSTRONG%3E%3CEM%3EMicrosoft%20Monitoring%20Agent%3C%2FEM%3E%3C%2FSTRONG%3E%20service%20(service%20name%3A%20HealthService).%3C%2FLI%3E%0A%3CLI%3EDelete%20(or%20rename%20if%20you%20prefer)%20the%20%3CSTRONG%3E%3CEM%3EC%3A%5CProgram%20Files%5CMicrosoft%20Monitoring%20Agent%5CAgent%5CHealth%20Service%20State%3C%2FEM%3E%3C%2FSTRONG%3E%20folder.%3C%2FLI%3E%0A%3CLI%3EStart%20the%20%3CSTRONG%3E%3CEM%3EMicrosoft%20Monitoring%20Agent%3C%2FEM%3E%3C%2FSTRONG%3E%20service.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThe%20steps%20above%20can%20result%20in%20something%20boring%20when%20have%20to%20be%20repeated%20frequently%2C%20so%20why%20not%20leverage%20Azure%20Automation%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20easily%20create%20an%20Automation%20Runbook%20that%20will%20do%20this%20for%20you.%20However%2C%20this%20operation%20could%20be%20a%20bit%20tricky.%20Since%20we%20need%20to%20manage%20resources%20on%20a%20guest%20OS%20in%20the%20local%20environment%20or%20possibly%20within%203%3CSUP%3Erd%3C%2FSUP%3E%20party%20cloud%20environments%2C%20we%E2%80%99ll%20need%20to%20install%20and%20configure%20a%20few%20components%20on%20each%20machine.%20More%20specifically%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EThe%20Microsoft%20Monitoring%20Agent%20itself.%3C%2FLI%3E%0A%3CLI%3EThe%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-hybrid-runbook-worker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHybrid%20Runbook%20Worker%3C%2FA%3E%20(HRW).%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EIn%20comparison%20to%20what%20we%20see%20in%20SCOM%2C%20where%20%26nbsp%3Bflushing%20steps%20are%20executed%20as%20an%20agent%20task%20by%20the%20MMA%2C%20%26nbsp%3Bwe%20have%20the%20sandbox%20agent%20that%20is%20responsible%20thus%20making%20our%20effort%20easier.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYessss%2C%20you%20got%20it%20%E2%80%A6%20All%20you%20have%20to%20do%20is%20create%20an%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-runbook-types%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Automation%20runbook%3C%2FA%3E%20that%20manages%20the%20flushing%20steps%20and%20that%E2%80%99s%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOf%20course%2C%20this%20is%20just%20one%20use%20case.%20You%20could%20also%20decide%20to%20leverage%20other%20methods%20such%20as%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAn%20Azure%20Automation%20runbook%20that%20call%20a%20scheduled%20task.%3C%2FLI%3E%0A%3CLI%3EAn%20Azure%20Automation%20runbook%20that%20picks%20the%20necessary%20components%20(i.e.%20scripts)%20from%20a%20storage%20account%20%2F%20share%20and%20copies%20it%20to%20the%20relevant%20computers.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20reference%20to%20the%20given%20scenario%2C%20here%E2%80%99s%20the%20script%20I%20will%20be%20using.%20Feel%20free%20to%20make%20any%20necessary%20change%3A%3C%2FP%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-powershell%22%3E%3CCODE%3E%23Stopping%20Service%0AWrite-Output%20%22Stopping%20the%20'Microsoft%20Monitoring%20Agent'%20service%20...%22%0AStop-Service%20-name%20Healthservice%20-Force%20-Confirm%3A%24false%0AWrite-Output%20%22The%20'Microsoft%20Monitoring%20Agent'%20service%20has%20been%20succesfully%20stopped.%22%0A%0A%23Getting%20installation%20folder%0A%24installationPath%20%3D%20Get-ItemProperty%20-Path%20Registry%3A%3A%22HKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CMicrosoft%20Operations%20Manager%5C3.0%5CSetup%22%20%7C%20Select-Object%20-expandproperty%20InstallDirectory%0AWrite-Output%20%22The%20'Microsoft%20Monitoring%20Agent'%20is%20installed%20in%20the%20'%24installationPath'%20folder%22%0A%0A%23Removing%20Health%20Service%20State%20folder%0AWrite-Output%20%22Deleting%20the%20'Health%20Service%20State'%20folder%20...%22%0ARemove-Item%20-LiteralPath%20%22%24installationPath%5CHealth%20Service%20State%22%20-Recurse%3A%24true%20-Force%20-Confirm%3A%24false%0AWrite-Output%20%22The%20folder%20'Health%20Service%20State'%20as%20been%20succesfully%20deleted.%22%0A%0A%23Wait%20a%20bit%20before%20restarting%20the%20agent%0AStart-sleep%20-Seconds%2010%0A%0A%23Starting%20service%0AWrite-Output%20%22Starting%20the%20'Microsoft%20Monitoring%20Agent'%20service%20...%22%0AStart-Service%20-name%20Healthservice%20-Confirm%3A%24false%0AWrite-Output%20%22The%20'Microsoft%20Monitoring%20Agent'%20service%20has%20been%20succesfully%20started.%22%0A%0A%23Logging%20runbook%20completion%0AWrite-Output%20%22Runbook%20execution%20completed.%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EKeep%20in%20mind%20that%20the%20HRW%20depends%20on%20the%20Log%20Analytics%20agent%20which%20writes%20to%20an%20Azure%20Monitor%20Log%20Analytics%20workspace.%20The%20workspace%20is%20not%20only%20to%20monitor%20the%20machine%2C%20but%20also%20to%20download%20the%20components%20required%20for%20the%20Hybrid%20Runbook%20Worker.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20won%E2%80%99t%20get%20into%20details%20of%20deploying%20the%20HRW.%20For%20more%20information%20about%20the%20subject%2C%20you%20can%20check%20out%20the%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%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy%20a%20Windows%20Hybrid%20Runbook%20Worker%3C%2FA%3E%20Microsoft%20article.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20correctly%20configured%20your%20HRW%2C%20proceed%20to%20include%20the%20PowerShell%20script%20listed%20above%20into%20a%20new%20runbook.%20I%20can%E2%80%99t%20stress%20this%20enough%3A%20%3CSTRONG%3E%3CEM%3ETEST!%2C%20TEST!%2C%20TEST!%3C%2FEM%3E%3C%2FSTRONG%3E%20this%20out%20before%20implementing%20in%20Production.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EImport%20the%20PowerShell%20runbook.%20Here%E2%80%99s%20an%20example%20of%20what%20this%20looks%20like%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ImportRunbook.png%22%20style%3D%22width%3A%20491px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222724i2757905E06BE4349%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ImportRunbook.png%22%20alt%3D%22ImportRunbook.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3ESchedule%20it%20or%20run%20it%20manually%20as%20required%20against%20the%20preferred%20hybrid%20worker%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-indent-padding-left-60px%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ScheduleRunbook.png%22%20style%3D%22width%3A%20643px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222722i8C97AFB975C6305E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ScheduleRunbook.png%22%20alt%3D%22ScheduleRunbook.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorBruno%20Gabrielli_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3COL%20start%3D%223%22%3E%0A%3CLI%3ETest!%20Test!%20Test!%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%E2%80%99s%20next%3F%20That%E2%80%99s%20all%20folks%20%E2%80%A6%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20reading%20and%20Happy%20flushing%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fhtml%2Fimages%2Femoticons%2Flaugh_40x40.gif%22%20alt%3D%22%3Alol%3A%22%20title%3D%22%3Alol%3A%22%20%2F%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDisclaimer%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20sample%20scripts%20are%20not%20supported%20under%20any%20Microsoft%20standard%20support%20program%20or%20service.%20The%20sample%20scripts%20are%20provided%20AS%20IS%20without%20warranty%20of%20any%20kind.%20Microsoft%20further%20disclaims%20all%20implied%20warranties%20including%2C%20without%20limitation%2C%20any%20implied%20warranties%20of%20merchantability%20or%20of%20fitness%20for%20a%20particular%20purpose.%20The%20entire%20risk%20arising%20out%20of%20the%20use%20or%20performance%20of%20the%20sample%20scripts%20and%20documentation%20remains%20with%20you.%20In%20no%20event%20shall%20Microsoft%2C%20its%20authors%2C%20or%20anyone%20else%20involved%20in%20the%20creation%2C%20production%2C%20or%20delivery%20of%20the%20scripts%20be%20liable%20for%20any%20damages%20whatsoever%20(including%2C%20without%20limitation%2C%20damages%20for%20loss%20of%20business%20profits%2C%20business%20interruption%2C%20loss%20of%20business%20information%2C%20or%20other%20pecuniary%20loss)%20arising%20out%20of%20the%20use%20of%20or%20inability%20to%20use%20the%20sample%20scripts%20or%20documentation%2C%20even%20if%20Microsoft%20has%20been%20advised%20of%20the%20possibility%20of%20such%20damages.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1723012%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20question%20of%20the%20day%20is%20how%20can%20we%20make%20sure%20our%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fagents-overview%23log-analytics-agent%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ELog%20Analytics%20agent%3C%2FA%3E%20(aka%20Microsoft%20Monitoring%20Agent%20(MMA))%20is%20always%20working%20properly%20to%20include%20an%20up%20to%20date%20configuration%3F%3C%2FP%3E%0A%3CP%3EHave%20you%20ever%20experienced%20a%20situation%20in%20which%20the%20MMA%20service%20was%20running%20but%20doing%20really%20nothing%3F%20Similar%20to%20a%20grey%20agent%20when%20referring%20to%20System%20Center%20Operations%20Manager%20(SCOM)%3F%3C%2FP%3E%0A%3CP%3EAccording%20to%20many%20online%20blogs%20and%20documentation%2C%20you%20have%20probably%20learned%20by%20now%20that%20flushing%20the%20MMA%20cache%20is%20quite%20easy%2C%26nbsp%3Bbut%20it%20can%20result%20in%20something%20boring%20when%20have%20to%20be%20repeated%20frequently%2C%20so%20why%20not%20leverage%20Azure%20Automation%3F%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%22ImportRunbook.png%22%20style%3D%22width%3A%20491px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224770i4C81DCE397D62C74%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ImportRunbook.png%22%20alt%3D%22ImportRunbook.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1723012%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBrunoGabrielli%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Greetings from Bruno :smile:

The question of the day is how can we make sure our Log Analytics agent (aka Microsoft Monitoring Agent (MMA)) is always working properly to include an up to date configuration?

Have you ever experienced a situation in which the MMA service was running but doing really nothing? Similar to a grey agent when referring to System Center Operations Manager (SCOM)?

 

Why flushing

There are several reasons why we’d want to flush the MMA cache. The most common being:

  • Heartbeat failure
  • Invalid configuration
  • System workflows failure
  • Network or authentication issues
  • Health service issues (service is not running)

Inevitably, it almost always comes down to your MMA(s) not working as expected.

If you’re curious to learn more about how and when to flush the MMA cache, take a look at the How and When to Clear the Cache Microsoft article for more details.

 

How to flush

According to many online blogs and documentation, you have probably learned by now that flushing the MMA cache is quite easy. In a nutshell, here is what that entails:

  1. Stop the Microsoft Monitoring Agent service (service name: HealthService).
  2. Delete (or rename if you prefer) the C:\Program Files\Microsoft Monitoring Agent\Agent\Health Service State folder.
  3. Start the Microsoft Monitoring Agent service.

The steps above can result in something boring when have to be repeated frequently, so why not leverage Azure Automation?

 

You can easily create an Automation Runbook that will do this for you. However, this operation could be a bit tricky. Since we need to manage resources on a guest OS in the local environment or possibly within 3rd party cloud environments, we’ll need to install and configure a few components on each machine. More specifically:

  1. The Microsoft Monitoring Agent itself.
  2. The Hybrid Runbook Worker (HRW).

In comparison to what we see in SCOM, where  flushing steps are executed as an agent task by the MMA,  we have the sandbox agent that is responsible thus making our effort easier.

 

Yessss, you got it … All you have to do is create an Azure Automation runbook that manages the flushing steps and that’s it.

 

Of course, this is just one use case. You could also decide to leverage other methods such as:

  • An Azure Automation runbook that call a scheduled task.
  • An Azure Automation runbook that picks the necessary components (i.e. scripts) from a storage account / share and copies it to the relevant computers.

In reference to the given scenario, here’s the script I will be using. Feel free to make any necessary change:

 

 

#Stopping Service
Write-Output "Stopping the 'Microsoft Monitoring Agent' service ..."
Stop-Service -name Healthservice -Force -Confirm:$false
Write-Output "The 'Microsoft Monitoring Agent' service has been succesfully stopped."

#Getting installation folder
$installationPath = Get-ItemProperty -Path Registry::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup" | Select-Object -expandproperty InstallDirectory
Write-Output "The 'Microsoft Monitoring Agent' is installed in the '$installationPath' folder"

#Removing Health Service State folder
Write-Output "Deleting the 'Health Service State' folder ..."
Remove-Item -LiteralPath "$installationPath\Health Service State" -Recurse:$true -Force -Confirm:$false
Write-Output "The folder 'Health Service State' as been succesfully deleted."

#Wait a bit before restarting the agent
Start-sleep -Seconds 10

#Starting service
Write-Output "Starting the 'Microsoft Monitoring Agent' service ..."
Start-Service -name Healthservice -Confirm:$false
Write-Output "The 'Microsoft Monitoring Agent' service has been succesfully started."

#Logging runbook completion
Write-Output "Runbook execution completed."

 

 

Keep in mind that the HRW depends on the Log Analytics agent which writes to an Azure Monitor Log Analytics workspace. The workspace is not only to monitor the machine, but also to download the components required for the Hybrid Runbook Worker.

 

I won’t get into details of deploying the HRW. For more information about the subject, you can check out the Deploy a Windows Hybrid Runbook Worker Microsoft article.

 

Once you have correctly configured your HRW, proceed to include the PowerShell script listed above into a new runbook. I can’t stress this enough: TEST!, TEST!, TEST! this out before implementing in Production.

 

  1. Import the PowerShell runbook. Here’s an example of what this looks like:

 

ImportRunbook.png

 

  1. Schedule it or run it manually as required against the preferred hybrid worker:

 

ScheduleRunbook.png

 
  1. Test! Test! Test!

 

What’s next? That’s all folks …

Thank you for reading and Happy flushing :lol:.

 

Disclaimer

The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.