Skip to content

Instantly share code, notes, and snippets.

@rwilkes
Forked from jamessantiago/Powershell.csx
Created March 15, 2016 16:18
Show Gist options
  • Save rwilkes/aa4b16206e8e9481b183 to your computer and use it in GitHub Desktop.
Save rwilkes/aa4b16206e8e9481b183 to your computer and use it in GitHub Desktop.
MMBot script for use with the MMBot.Powershell package
//Notes:
//Requires the MMBot.Powershell nuget package
//Output objects must either support a ToString method or be a string to display properly
//It is recommended to use the PowershellModule script instead of this one to control what is executed
using MMBot.Powershell;
var robot = Require<Robot>();
robot.Respond(@"(ps|powershell) (.*)", msg =>
{
var command = msg.Match[2];
try
{
foreach (string result in robot.ExecutePowershellCommand(command))
{
msg.Send(result);
}
}
catch (Exception)
{
msg.Send("erm....issues, move along");
}
});
robot.AddHelp("mmbot powershell <command> - Executes a powershell command.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment