Share via


PowerShell script to Remove Application Servers: Only Applicable to Application Server's added by PowerShell

I would like to take a moment to clarify a point about the PowerShell script to remove application servers (aka RemoveJEEAppServer.ps1) that was recently brought to my attention. This mechanism for removing application servers is only intended for use with application servers added via PowerShell (aka NewJEEAppServer.ps1). You cannot use this script to remove an instance that was discovered via the application server-specific Management Pack (for example see here for an example on WebLogic).  The reason is simple: the objects manipulated by the PowerShell script are different from those created during the other discoveries.

The quickest way to tell which type of discovery found an application server instance is to check the Disk Path property.  If the instance PowerShell discovered (aka the Universal Discovery method), then it will not have a disk path.  Since the PowerShell approach is done strictly via a HTTP call, this intrinsically makes sense.  Where the application server lives is inconsequential - all the PowerShell approach cares about is if there is a HTTP channel to communicate to BeanSpy.  So if the Disk Path property in the SCOM UI is blank, then that instance is a candidate for removal via PowerShell.

To remove an instance of an application server, the short version is that you cannot remove it.  What you can do is disable the discovery from running on that machine or remove the application server from disk.  The next discovery interval (~4 hours by default) will not find the machine on disk and remove it from the discovery inventory.  

FYI: How the SCOM discovery process works is every interval (in this case 4 hours) the discovery will run.  Assuming the same set of parameters are met, then the instance will continue to appear in the UI.  The regular MP discoveries depend on the path on disk.  As long as the files exist on disk, then the MP should continue to discover the object.  For more information about how the SCOM discovery process works, see https://social.technet.microsoft.com/wiki/contents/articles/14260.operations-manager-management-pack-authoring-discovery.aspx.