diff --git a/Elasticsearch.Powershell.sln b/Elasticsearch.Powershell.sln
new file mode 100644
index 0000000..91e577c
--- /dev/null
+++ b/Elasticsearch.Powershell.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25123.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elasticsearch.Powershell", "src\Elasticsearch.Powershell\Elasticsearch.Powershell.csproj", "{366D21C7-F569-4D6E-AC7A-8C27E61B54EF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elasticsearch.Powershell.Tests", "src\Elasticsearch.Powershell.Tests\Elasticsearch.Powershell.Tests.csproj", "{34B3DFEE-6900-4310-8534-BFABAAA77FB8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {366D21C7-F569-4D6E-AC7A-8C27E61B54EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {366D21C7-F569-4D6E-AC7A-8C27E61B54EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {366D21C7-F569-4D6E-AC7A-8C27E61B54EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {366D21C7-F569-4D6E-AC7A-8C27E61B54EF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {34B3DFEE-6900-4310-8534-BFABAAA77FB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {34B3DFEE-6900-4310-8534-BFABAAA77FB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {34B3DFEE-6900-4310-8534-BFABAAA77FB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {34B3DFEE-6900-4310-8534-BFABAAA77FB8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/Elasticsearch.Powershell.Tests/ElasticIndicesHealthTests.cs b/src/Elasticsearch.Powershell.Tests/ElasticIndicesHealthTests.cs
new file mode 100644
index 0000000..9b24016
--- /dev/null
+++ b/src/Elasticsearch.Powershell.Tests/ElasticIndicesHealthTests.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Nest;
+using Xunit;
+
+namespace Elasticsearch.Powershell.Tests
+{
+ public class ElasticIndicesHealthTests
+ {
+ [Fact]
+ public void Test()
+ {
+ var cmdlet = new HealtCmdLet.ElasticClusterHealth();
+ var enumerator = cmdlet.Invoke().GetEnumerator();
+
+ Assert.True(enumerator.MoveNext());
+ }
+
+ [Fact]
+ public void Test2()
+ {
+ var cmdlet = new HealtCmdLet.ElasticIndicesHealth();
+ var enumerator = cmdlet.Invoke().GetEnumerator();
+
+ Assert.True(enumerator.MoveNext());
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell.Tests/ElasticSearchTests.cs b/src/Elasticsearch.Powershell.Tests/ElasticSearchTests.cs
new file mode 100644
index 0000000..1482d69
--- /dev/null
+++ b/src/Elasticsearch.Powershell.Tests/ElasticSearchTests.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Elasticsearch.Powershell.Tests
+{
+ public class ElasticSearchTests
+ {
+ [Fact]
+ public void Test()
+ {
+ var cmdlet = new ElastichSearch();
+ cmdlet.Fields = new[] { "EventID" };
+ var enumerator = cmdlet.Invoke().GetEnumerator();
+
+ Assert.True(enumerator.MoveNext());
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell.Tests/Elasticsearch.Powershell.Tests.csproj b/src/Elasticsearch.Powershell.Tests/Elasticsearch.Powershell.Tests.csproj
new file mode 100644
index 0000000..a9b2ec2
--- /dev/null
+++ b/src/Elasticsearch.Powershell.Tests/Elasticsearch.Powershell.Tests.csproj
@@ -0,0 +1,104 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ {34B3DFEE-6900-4310-8534-BFABAAA77FB8}
+ Library
+ Properties
+ Elasticsearch.Powershell.Tests
+ Elasticsearch.Powershell.Tests
+ v4.5
+ 512
+
+
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ ..\..\packages\Elasticsearch.Net.5.0.0-alpha2\lib\net45\Elasticsearch.Net.dll
+ True
+
+
+ ..\..\packages\NEST.5.0.0-alpha2\lib\net45\Nest.dll
+ True
+
+
+ ..\..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+
+
+
+
+
+ ..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll
+ True
+
+
+ ..\..\packages\xunit.assert.2.2.0-beta1-build3239\lib\dotnet\xunit.assert.dll
+ True
+
+
+ ..\..\packages\xunit.extensibility.core.2.2.0-beta1-build3239\lib\dotnet\xunit.core.dll
+ True
+
+
+ ..\..\packages\xunit.extensibility.execution.2.2.0-beta1-build3239\lib\net45\xunit.execution.desktop.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+ {366d21c7-f569-4d6e-ac7a-8c27e61b54ef}
+ Elasticsearch.Powershell
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Elasticsearch.Powershell.Tests/Properties/AssemblyInfo.cs b/src/Elasticsearch.Powershell.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d3bceec
--- /dev/null
+++ b/src/Elasticsearch.Powershell.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Elasticsearch.Powershell.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Elasticsearch.Powershell.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("34b3dfee-6900-4310-8534-bfabaaa77fb8")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Elasticsearch.Powershell.Tests/packages.config b/src/Elasticsearch.Powershell.Tests/packages.config
new file mode 100644
index 0000000..12a0267
--- /dev/null
+++ b/src/Elasticsearch.Powershell.Tests/packages.config
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Elasticsearch.Powershell/ElasticCluster.cs b/src/Elasticsearch.Powershell/ElasticCluster.cs
new file mode 100644
index 0000000..dea64b9
--- /dev/null
+++ b/src/Elasticsearch.Powershell/ElasticCluster.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using Nest;
+
+namespace Elasticsearch.Powershell
+{
+ [Cmdlet(VerbsCommon.Get, "ElasticCluster")]
+ public class ElasticCluster : ElasticCmdlet
+ {
+ protected override void ProcessRecord()
+ {
+ var health = this.Client.ClusterHealth();
+ this.CheckResponse(health);
+
+ WriteObject(new Types.Cluster
+ {
+ ConnectionSettings = this.Client.ConnectionSettings,
+ ActivePrimaryShards = health.ActivePrimaryShards,
+ ActiveShards = health.ActiveShards,
+ Name = health.ClusterName,
+ InitializingShards = health.InitializingShards,
+ NumberOfDataNodes = health.NumberOfDataNodes,
+ NumberOfNodes = health.NumberOfNodes,
+ NumberOfPendingTasks = health.NumberOfPendingTasks,
+ RelocatingShards = health.RelocatingShards,
+ Status = health.Status,
+ UnassignedShards = health.UnassignedShards
+ });
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/ElasticCmdLet.cs b/src/Elasticsearch.Powershell/ElasticCmdLet.cs
new file mode 100644
index 0000000..c9de150
--- /dev/null
+++ b/src/Elasticsearch.Powershell/ElasticCmdLet.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using Elasticsearch.Net;
+using Nest;
+
+namespace Elasticsearch.Powershell
+{
+ public class ElasticCmdlet : Cmdlet
+ {
+ private ElasticClient _client;
+ private IConnectionSettingsValues _connectionSettings;
+
+ public ElasticCmdlet()
+ {
+ this.Nodes = new[] { "http://localhost:9200" };
+ }
+
+ [Parameter(Position = 0, Mandatory = false, HelpMessage = "The cluster node(s) urls (ex. http://localhost:9200)")]
+ public string[] Nodes { get; set; }
+
+ protected IElasticClient Client
+ {
+ get
+ {
+ if (_client != null)
+ return _client;
+
+ return _client = new ElasticClient(this.ConnectionSettings);
+ }
+ }
+
+ protected IConnectionSettingsValues ConnectionSettings
+ {
+ get
+ {
+ if (_connectionSettings != null)
+ return _connectionSettings;
+
+ var pool = new StaticConnectionPool(this.Nodes.Select(GetNodeUri));
+ return _connectionSettings = new ConnectionSettings(pool);
+ }
+ set
+ {
+ _connectionSettings = value;
+ }
+ }
+
+ protected override void EndProcessing()
+ {
+ _client = null;
+ }
+
+ protected void CheckResponse(IResponse response)
+ {
+ WriteVerbose(response.DebugInformation);
+
+ if (response.OriginalException != null)
+ {
+ var exception = response.OriginalException;
+ var first = exception;
+
+ while(exception != null)
+ {
+ first = exception;
+ WriteVerbose("Error: " + exception.Message);
+ exception = exception.InnerException;
+ }
+
+ throw first;
+ }
+ }
+
+ private static Uri GetNodeUri(string node)
+ {
+ return new Uri(GetNodeAddress(node));
+ }
+
+ private static string GetNodeAddress(string node)
+ {
+ if (node.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase))
+ return node;
+
+ if (node.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
+ return node;
+
+ return "http://" + node;
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/ElasticNode.cs b/src/Elasticsearch.Powershell/ElasticNode.cs
new file mode 100644
index 0000000..6fed1c8
--- /dev/null
+++ b/src/Elasticsearch.Powershell/ElasticNode.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Management.Automation;
+
+namespace Elasticsearch.Powershell
+{
+ [Cmdlet(VerbsCommon.Get, "ElasticNode")]
+ public class ElasticNode : ElasticCmdlet
+ {
+ [Parameter(ValueFromPipeline = true)]
+ public Types.Cluster InputObject { get; set; }
+
+ protected override void ProcessRecord()
+ {
+ if (this.InputObject != null)
+ this.ConnectionSettings = this.InputObject.ConnectionSettings;
+
+ var nodes = this.Client.NodesInfo();
+ this.CheckResponse(nodes);
+
+ foreach (var node in nodes.Nodes.Values)
+ WriteObject(node);
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/ElasticSnapshot.cs b/src/Elasticsearch.Powershell/ElasticSnapshot.cs
new file mode 100644
index 0000000..5bd10b8
--- /dev/null
+++ b/src/Elasticsearch.Powershell/ElasticSnapshot.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using System.Text;
+using System.Threading.Tasks;
+using Nest;
+
+namespace Elasticsearch.Powershell
+{
+ [Cmdlet(VerbsCommon.New, "ElasticSnapshot")]
+ public class ElasticSnapshot : ElasticCmdlet
+ {
+ [Parameter(Position = 1, Mandatory = false, HelpMessage = "")]
+ public string Name { get; set; }
+
+ [Parameter(Position = 2, Mandatory = false, HelpMessage = "")]
+ public string Repository { get; set; }
+
+ protected override void ProcessRecord()
+ {
+ var snap = this.Client.Snapshot(new Nest.Name(this.Repository), new Nest.Name(this.Name));
+ CheckResponse(snap);
+
+ WriteObject(snap.Snapshot);
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/ElastichSearch.cs b/src/Elasticsearch.Powershell/ElastichSearch.cs
new file mode 100644
index 0000000..f79e009
--- /dev/null
+++ b/src/Elasticsearch.Powershell/ElastichSearch.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Management.Automation;
+using System.Text;
+using System.Threading.Tasks;
+using Nest;
+
+namespace Elasticsearch.Powershell
+{
+ [Cmdlet(VerbsCommon.Search, "Elastic")]
+ public class ElastichSearch : ElasticCmdlet
+ {
+ public ElastichSearch()
+ {
+ this.Size = 100;
+ }
+
+ [Parameter(Position = 1, Mandatory = false, HelpMessage = "The elasticsearch query")]
+ public string Query { get; set; }
+
+ [Parameter(Position = 2, Mandatory = false, HelpMessage = "One or more index name(s). You can use the wildcard '*' in the name.")]
+ public string[] Index { get; set; }
+
+ [Parameter(Position = 3, Mandatory = false, HelpMessage = "The fields to return. If not specified, all fields will be returned")]
+ public string[] Fields { get; set; }
+
+ [Parameter(Position = 4, Mandatory = false, HelpMessage = "Number of records to return (default 100)")]
+ public int Size { get; set; }
+
+ private Indices GetIndices()
+ {
+ if (this.Index == null || this.Index.Length == 0)
+ return Indices.All;
+
+ return Indices.Parse(String.Join(",", this.Index));
+ }
+
+ private static string[] GetFields(string[] fields)
+ {
+ if (fields == null || fields.Length == 0)
+ return null;
+
+ if (fields.Length == 1)
+ fields = fields[0].Split(',');
+
+ fields = fields.Select(f => f.Trim())
+ .Where(f => !String.IsNullOrWhiteSpace(f))
+ .ToArray();
+
+ if (fields.Length == 0)
+ return null;
+
+ return fields;
+ }
+
+ protected override void ProcessRecord()
+ {
+ var request = new SearchRequest(this.GetIndices())
+ {
+ Size = this.Size
+ };
+
+ if (!String.IsNullOrWhiteSpace(this.Query))
+ {
+ request.Query = new QueryStringQuery
+ {
+ Query = this.Query
+ };
+ }
+
+ var include = GetFields(this.Fields);
+ if(include != null)
+ request.Source = new SourceFilter { Include = include };
+
+ var search = this.Client.Search(request);
+ this.CheckResponse(search);
+
+ foreach (var item in search.Documents)
+ WriteObject(item.ToPSObject());
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/Elasticsearch.Powershell.csproj b/src/Elasticsearch.Powershell/Elasticsearch.Powershell.csproj
new file mode 100644
index 0000000..0ece216
--- /dev/null
+++ b/src/Elasticsearch.Powershell/Elasticsearch.Powershell.csproj
@@ -0,0 +1,88 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {366D21C7-F569-4D6E-AC7A-8C27E61B54EF}
+ Library
+ Properties
+ Elasticsearch.Powershell
+ Elasticsearch.Powershell
+ v4.5
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ ..\..\packages\Elasticsearch.Net.5.0.0-alpha2\lib\net45\Elasticsearch.Net.dll
+ True
+
+
+ ..\..\packages\NEST.5.0.0-alpha2\lib\net45\Nest.dll
+ True
+
+
+ ..\..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+
+
+
+ False
+ ..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Elasticsearch.Powershell/ElasticsearchPowershell.psd1 b/src/Elasticsearch.Powershell/ElasticsearchPowershell.psd1
new file mode 100644
index 0000000..8f860e0
Binary files /dev/null and b/src/Elasticsearch.Powershell/ElasticsearchPowershell.psd1 differ
diff --git a/src/Elasticsearch.Powershell/Extensions.cs b/src/Elasticsearch.Powershell/Extensions.cs
new file mode 100644
index 0000000..f0206c2
--- /dev/null
+++ b/src/Elasticsearch.Powershell/Extensions.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Management.Automation;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Elasticsearch.Powershell
+{
+ internal static class Extensions
+ {
+ public static PSObject ToPSObject(this IDictionary dictionary)
+ {
+ var record = new PSObject();
+
+ foreach (var field in dictionary)
+ {
+ record.Properties.Add(new PSNoteProperty(field.Key, field.Value));
+ }
+
+ return record;
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/HealtCmdLet/ElasticClusterHealth.cs b/src/Elasticsearch.Powershell/HealtCmdLet/ElasticClusterHealth.cs
new file mode 100644
index 0000000..3f999c0
--- /dev/null
+++ b/src/Elasticsearch.Powershell/HealtCmdLet/ElasticClusterHealth.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Management.Automation;
+
+namespace Elasticsearch.Powershell.HealtCmdLet
+{
+ [Cmdlet(VerbsCommon.Get, "ElasticClusterHealth")]
+ public class ElasticClusterHealth : ElasticCmdlet
+ {
+ protected override void ProcessRecord()
+ {
+ var health = this.Client.ClusterHealth();
+ this.CheckResponse(health);
+
+ WriteObject(new PSObject(new
+ {
+ health.ActivePrimaryShards,
+ health.ActiveShards,
+ health.ClusterName,
+ health.InitializingShards,
+ health.NumberOfDataNodes,
+ health.NumberOfNodes,
+ health.NumberOfPendingTasks,
+ health.RelocatingShards,
+ health.UnassignedShards,
+ health.Status
+ }));
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/HealtCmdLet/ElasticIndicesHealth.cs b/src/Elasticsearch.Powershell/HealtCmdLet/ElasticIndicesHealth.cs
new file mode 100644
index 0000000..4069b13
--- /dev/null
+++ b/src/Elasticsearch.Powershell/HealtCmdLet/ElasticIndicesHealth.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Management.Automation;
+
+namespace Elasticsearch.Powershell.HealtCmdLet
+{
+ [Cmdlet(VerbsCommon.Get, "ElasticIndicesHealth")]
+ public class ElasticIndicesHealth : ElasticCmdlet
+ {
+ protected override void ProcessRecord()
+ {
+ var healt = this.Client.ClusterHealth(h => h.AllIndices());
+ this.CheckResponse(healt);
+
+ if (healt.Indices?.Values == null)
+ return;
+
+ foreach(var index in healt.Indices.Values)
+ {
+ WriteObject(new PSObject(new
+ {
+ index.ActivePrimaryShards,
+ index.ActiveShards,
+ index.InitializingShards,
+ index.NumberOfReplicas,
+ index.NumberOfShards,
+ index.RelocatingShards,
+ index.Status,
+ index.UnassignedShards
+ }));
+ }
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/IndexCmdLets/ElasticGetIndex.cs b/src/Elasticsearch.Powershell/IndexCmdLets/ElasticGetIndex.cs
new file mode 100644
index 0000000..cd926a4
--- /dev/null
+++ b/src/Elasticsearch.Powershell/IndexCmdLets/ElasticGetIndex.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Management.Automation;
+using Nest;
+
+namespace Elasticsearch.Powershell.IndexCmdLets
+{
+ [Cmdlet(VerbsCommon.Get, "ElasticIndex")]
+ public class ElasticGetIndex : ElasticCmdlet
+ {
+ [Parameter(Position = 1, Mandatory = false, HelpMessage = "One or more index name(s). You can use the wildcard '*' in the name.")]
+ public string[] Index { get; set; }
+
+ private Indices GetIndices()
+ {
+ if (this.Index == null || this.Index.Length == 0)
+ return Indices.All;
+
+ return Indices.Parse(String.Join(",", this.Index));
+ }
+
+ protected override void ProcessRecord()
+ {
+ var indices = this.GetIndices();
+ var cat = this.Client.CatIndices(new CatIndicesRequest(indices));
+ this.CheckResponse(cat);
+
+ foreach (var index in cat.Records)
+ WriteObject(new Types.Index(index));
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/IndexCmdLets/ElasticNewIndex.cs b/src/Elasticsearch.Powershell/IndexCmdLets/ElasticNewIndex.cs
new file mode 100644
index 0000000..b979c59
--- /dev/null
+++ b/src/Elasticsearch.Powershell/IndexCmdLets/ElasticNewIndex.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using System.Text;
+using System.Threading.Tasks;
+using Nest;
+
+namespace Elasticsearch.Powershell.IndexCmdLet
+{
+ [Cmdlet(VerbsCommon.New, "ElasticIndex")]
+ public class ElasticNewIndex : ElasticCmdlet
+ {
+ [Parameter(Position = 1, Mandatory = true, HelpMessage = "The name of the new index to create")]
+ public string Index { get; set; }
+
+ protected override void ProcessRecord()
+ {
+ var index = new IndexName { Name = this.Index };
+
+ var create = this.Client.CreateIndex(index);
+ this.CheckResponse(create);
+
+ var cat = this.Client.CatIndices(new CatIndicesRequest(index));
+ this.CheckResponse(cat);
+
+ WriteObject(new Types.Index(cat.Records.First()));
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/IndexCmdLets/ElasticRemoveIndex.cs b/src/Elasticsearch.Powershell/IndexCmdLets/ElasticRemoveIndex.cs
new file mode 100644
index 0000000..7050416
--- /dev/null
+++ b/src/Elasticsearch.Powershell/IndexCmdLets/ElasticRemoveIndex.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Linq;
+using System.Management.Automation;
+using Nest;
+
+namespace Elasticsearch.Powershell.IndexCmdLet
+{
+ [Cmdlet(VerbsCommon.Remove, "ElasticIndex")]
+ public class ElasticRemoveIndex : ElasticCmdlet
+ {
+ [Parameter(Position = 1, Mandatory = false, HelpMessage = "One or more index name. You can use the wildcard '*' in the name.")]
+ public string[] Index { get; set; }
+
+ [Parameter(ValueFromPipeline = true)]
+ public Types.Index[] InputObject { get; set; }
+
+ private Indices GetIndices()
+ {
+ if (this.InputObject != null)
+ return Indices.Parse(String.Join(",", this.InputObject.Select(i => i.Name)));
+
+ if (this.Index == null || this.Index.Length == 0)
+ return null;
+
+ return Indices.Parse(String.Join(",", this.Index));
+ }
+
+ protected override void ProcessRecord()
+ {
+ var indices = this.GetIndices();
+ if (indices == null)
+ return;
+
+ var delete = this.Client.DeleteIndex(indices);
+ this.CheckResponse(delete);
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/Properties/AssemblyInfo.cs b/src/Elasticsearch.Powershell/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..2d126cb
--- /dev/null
+++ b/src/Elasticsearch.Powershell/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Elasticsearch.Powershell")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Elasticsearch.Powershell")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("366d21c7-f569-4d6e-ac7a-8c27e61b54ef")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/Elasticsearch.Powershell/RepositoryCmdLets/ElasticGetRepository.cs b/src/Elasticsearch.Powershell/RepositoryCmdLets/ElasticGetRepository.cs
new file mode 100644
index 0000000..52f38db
--- /dev/null
+++ b/src/Elasticsearch.Powershell/RepositoryCmdLets/ElasticGetRepository.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using System.Text;
+using System.Threading.Tasks;
+using Nest;
+
+namespace Elasticsearch.Powershell.RepositoryCmdLets
+{
+ public class ElasticGetRepository : ElasticCmdlet
+ {
+ [Parameter(Position = 1, Mandatory = false, HelpMessage = "One or more index name(s). You can use the wildcard '*' in the name.")]
+ public string[] Repository { get; set; }
+
+ private IGetRepositoryRequest GetRequest(GetRepositoryDescriptor descriptor)
+ {
+ if (this.Repository == null || this.Repository.Length == 0)
+ return new GetRepositoryRequest();
+
+ return new GetRepositoryRequest(Names.Parse(String.Join(",", this.Repository)));
+ }
+
+ protected override void ProcessRecord()
+ {
+ var response = this.Client.GetRepository(this.GetRequest);
+ CheckResponse(response);
+
+ foreach(var repo in response.Repositories)
+ {
+ WriteObject(repo.Value);
+ }
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/Types/Cluster.cs b/src/Elasticsearch.Powershell/Types/Cluster.cs
new file mode 100644
index 0000000..e943d5b
--- /dev/null
+++ b/src/Elasticsearch.Powershell/Types/Cluster.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Nest;
+
+namespace Elasticsearch.Powershell.Types
+{
+ public class Cluster
+ {
+ public int ActivePrimaryShards { get; set; }
+ public int ActiveShards { get; set; }
+ public string Name { get; set; }
+ public int InitializingShards { get; set; }
+ public int NumberOfDataNodes { get; set; }
+ public int NumberOfNodes { get; set; }
+ public int NumberOfPendingTasks { get; set; }
+ public int RelocatingShards { get; set; }
+ public int UnassignedShards { get; set; }
+ public string Status { get; set; }
+ internal IConnectionSettingsValues ConnectionSettings { get; set; }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/Types/Index.cs b/src/Elasticsearch.Powershell/Types/Index.cs
new file mode 100644
index 0000000..47b426c
--- /dev/null
+++ b/src/Elasticsearch.Powershell/Types/Index.cs
@@ -0,0 +1,46 @@
+using System;
+using Nest;
+
+namespace Elasticsearch.Powershell.Types
+{
+ public class Index
+ {
+ public Index()
+ {
+ }
+
+ internal Index(CatIndicesRecord index)
+ {
+ this.DocsCount = long.Parse(index.DocsCount);
+ this.DocsDeleted = long.Parse(index.DocsDeleted);
+ this.Health = index.Health;
+ this.Name = index.Index;
+ this.Primary = index.Primary;
+ this.PrimaryStoreSize = index.PrimaryStoreSize;
+ this.Replica = index.Replica;
+ this.Status = index.Status;
+ this.StoreSize = index.StoreSize;
+ this.TotalMemory = index.TotalMemory;
+ }
+
+ public long DocsCount { get; set; }
+
+ public long DocsDeleted { get; set; }
+
+ public string Health { get; set; }
+
+ public string Name { get; set; }
+
+ public string Primary { get; set; }
+
+ public string PrimaryStoreSize { get; set; }
+
+ public string Replica { get; set; }
+
+ public string Status { get; set; }
+
+ public string StoreSize { get; set; }
+
+ public string TotalMemory { get; set; }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/Types/Node.cs b/src/Elasticsearch.Powershell/Types/Node.cs
new file mode 100644
index 0000000..f4c771a
--- /dev/null
+++ b/src/Elasticsearch.Powershell/Types/Node.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Nest;
+
+namespace Elasticsearch.Powershell.Types
+{
+ public class Node
+ {
+ public Node()
+ {
+ }
+
+ internal Node(NodeInfo info)
+ {
+ this.Name = info.Name;
+ this.Address = new Uri("http://" + info.HttpAddress);
+ this.Version = info.Version;
+ }
+
+ public string Name { get; set; }
+
+ public Uri Address { get; set; }
+
+ public string Version { get; set; }
+
+ public override string ToString()
+ {
+ return this.Address.ToString();
+ }
+ }
+}
diff --git a/src/Elasticsearch.Powershell/packages.config b/src/Elasticsearch.Powershell/packages.config
new file mode 100644
index 0000000..aea5b33
--- /dev/null
+++ b/src/Elasticsearch.Powershell/packages.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Elasticsearch.Powershell/test.ps1 b/src/Elasticsearch.Powershell/test.ps1
new file mode 100644
index 0000000..d0ea46a
--- /dev/null
+++ b/src/Elasticsearch.Powershell/test.ps1
@@ -0,0 +1,32 @@
+Import-Module ".\ElasticsearchPowershell.psd1"
+$nodes = @(
+ "http://localhost:9200"
+)
+
+# Get-ElasticCluster -Verbose
+
+# Get-ElasticNode
+
+Get-ElasticCluster | Get-ElasticNode
+
+#Get-ElasticClusterHealth "localhost:9200" -Verbose
+
+#Get-ElasticIndicesHealth
+
+#Get-ElasticIndex -Index ".kibana,logstash-2016.06.18"
+
+#Get-ElasticIndex -Index @(".kibana", "logstash-2016.06.18")
+
+# Get-ElasticIndex -Index "logstash-*" | Remove-ElasticIndex
+
+# Remove-ElasticIndex -Index "logstash-*"
+
+# New-ElasticIndex -Index "test1234"
+
+#Search-Elastic -Index "logstash-*" | Where-Object { $_.EventID -eq 4002 }
+
+#Search-Elastic -Index "logstash-*" -Query "EventID: 7036" -Size 2 -Verbose
+
+#Search-Elastic -Nodes $nodes -Query "EventID: 7036" -Fields @("Hostname", "EventID", "Version") -Verbose
+
+#Search-Elastic -Nodes $nodes -Query "EventID: 7036" -Fields "Hostname,EventID" -Verbose
diff --git a/tests/ElasticsearchPowershell.tests.ps1 b/tests/ElasticsearchPowershell.tests.ps1
new file mode 100644
index 0000000..e81572f
--- /dev/null
+++ b/tests/ElasticsearchPowershell.tests.ps1
@@ -0,0 +1,13 @@
+#
+# This is a PowerShell Unit Test file.
+# You need a unit test framework such as Pester to run PowerShell Unit tests.
+# You can download Pester from http://go.microsoft.com/fwlink/?LinkID=534084
+#
+
+Describe "Get-Function" {
+ Context "Function Exists" {
+ It "Should Return" {
+
+ }
+ }
+}
\ No newline at end of file