Skip to content

secabstraction/PowerStash

Repository files navigation

PowerStash

######A PowerShell module for stashing all the things into Elastic.

Installation

PowerStash is packaged as a PowerShell module. You must import the module to use its functions.

  # Import the functions via the psd1 file:
  Import-Module PowerStash.psd1

Functions:

  New-ElasticClient             # Creates a client for interacting with Elastic.
  New-ConnectionPool            # Creates an Elasticsearch.Net connection pool.
  New-ConnectionConfiguration   # Creates a customizeable configuration for a client.
  New-BulkIndexRequest          # Creates a bulk request for faster indexing.
  Export-Elastic                # Indexes objects into Elastic.
  Invoke-PowerStash             # Runs an object producing script and indexes its output.
	

Client Configuration

By default, PowerStash uses http://localhost:9200 as the Uri for Elastic.

  # Default client:
  $Client = New-ElasticClient
      
  # Specific node client:
  $Client = New-ElasticClient -Node http://MyElasticUri:9200
  
  # Fully configured client:
  $Pool = New-ConnectionPool -Nodes ('http://node1:9200','http://node2:9200') -Sniffing
  $Config = New-ConnectionConfiguration -Pool $Pool
  $Config.SetProxy('http://proxy:8080','user','pass')
  $Client = New-ElasticClient -Configuration $Config

Basic Indexing

PowerStash asynchronously indexes object(s) and returns the results.

Elastic's response(s) to index requests, such as errors, are conatined in the results.

  # Exporting to a single-node instance:
  $Results = Export-Elastic -InputObject $MyObjects -Node http://MyElasticUri:9200
      
  # Exporting with a fully configured client:
  $Results = Export-Elastic -InputObject $MyObjects -Client $Client

Heavy-Lifting

Invoke-PowerStash can be used to produce objects in a separate runspace and asynchronously export them.

  Invoke-PowerStash -Scriptblock ${function:Get-Objects} -Parameters $Params -Client $Client

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published