Skip to content →

Possible uses for PLEX modules

Here you have some possible samples that you may use as templates for your own purposes. In any case, the main goal of this post is give you an idea of what it is possible using PLEX modules.

The Samples or “Templates”

Remote log Distributed search using findstr.exe

"for /f `"tokens=*`" %i in ('dir /s /b *.log') do @findstr `"MyRegExPattern`" `"%i`"" | .\nmagent.ps1 -profile plex -cmd exec -src file -save

Remote log Distributed search using RSaR.exe. “RSaR” means “Regex Search and Rescue” and can be found at

"\\MyServer\MyReadOnlyShare\RSaR.exe *.log /s /i `"MyDotNetRegExPattern`"" | .\nmagent.ps1 -profile plex -cmd exec -src file -save

Remote log Distributed search using sed.exe. “sed” means “Stream Editor” and a version for Windows can be found at

"for /r c:\MyRemoteRootFolder %i in (*.log) do @\\MyServer\MyReadOnlyShare\sed.exe -i -T `"/MyRegExPattern/`" `"%i`"" | .\nmagent.ps1 -profile plex -cmd exec -src file -save

Massive Remote Configuration Changes using RSaR.exe.

"\\MyServer\MyReadOnlyShare\RSaR.exe *.ini /s /i `"Property=Value1`" /r=`"Property=Value2`"" | .\nmagent.ps1 -profile plex -cmd exec -src file -save

Massive Remote Configuration Changes using sed.exe.

"for /r c:\MyRemoteRootFolder %i in (*.properties) do @\\MyServer\MyReadOnlyShare\sed.exe -i -T `"s/Property=Value1/Property=Value2/g`" `"%i`"" | .\nmagent.ps1 -profile plex -cmd exec -src file -save

Remotely stop a Service for maintenance on your Production Systems:

"sc stop `"MyServiceName`"" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\MyProductionNodes.txt

Remotely creating a Service for a new Pre-production deployment:

"sc create `"MyServiceName`" binpath=`"C:\MyService\MyService.exe`" displayname=`"MyServiceName`"" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\MyPreProductionNodes.txt

Remotely forcing a predefined local Scheduled Job to run on your web servers. May be this could be Log Rotation, Application Pool recycle, … whatever:

"schtasks /run /tn `"MyTaskName`"" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\MyWebServers.txt

Forcing a System reboot for your servers in Data Center 1 after a regular Software Update. Everything will still run on their partner systems on Data Center 2.

"shutdown -r -f -t 0" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\DataCenter1.txt

Get rid of active Console Sessions forcing them to log off:

"shutdown -l -f -t 0" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\AllNodes.txt

Documenting the disk fragmentation state of your Production systems:

"defrag c: -a -v" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\AllProductionNodes.txt -save

Enforcing a Corporate Policy. Killing not allowed services on your development Linux machines:

"ps -ef | egrep `"MyRegExPattern`" | egrep -v `"egrep`" | kill -9" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\MyLinuxDevNodes.txt

Backing up the configuration of your Cisco devices:

"show config" | .\nmagent.ps1 -profile plex -cmd exec -src file .\settings\MyCiscoDevices.txt -save

… and, afterwards, persisting the collected configurations of your Cisco devices on the CMDB:

.\nmagent.ps1 -profile plex -cmd update -src session last

Important Notes

Follow the general rule you should use on every System, Tool or Situation: test, test, test. Specially before doing anything potentially dangerous.

On the examples I have use the -src file paramenter. Better results can be achieved with -src db parameter if you have placed a proper SQL filter on your Configuration Profile.

If you plan to run .NET assemblies from a Network Share you will have to deal with Code Access Security Policies. As a possible alternative, you can customize the PLEX module to allow it upload your .exe file on the remote node.

This is just the beginning. Future releases may bring up new options: PowerShell 2.0 Remoting, WinRM support, ScriptBlock injection and who knows…

… What it is really important is don't forget that this is only a way, a tool, a medium. What really matters is the use cases I can't imagine, but you do … ;-D. So, just in case you find something useful, just let me know. I would love to here your experience and achievements.


Creative Commons License
Except where otherwise noted, ThinkInBig by Carlos Veira Lorenzo is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Published in Automation IT Infrastructure Projects Service Management System Management