Ready to get started?

Download a free trial of the Neo4J Data Provider to get started:

 Download Now

Learn more:

Neo4J Icon Neo4J ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Neo4J.

Automate Neo4J Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Neo4J data from PowerShell? This article demonstrates how to utilize the Neo4J Cmdlets for tasks like connecting to Neo4J data, automating operations, downloading data, and more.

The CData Cmdlets for Neo4J are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Neo4J.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to Neo4J, but also an SQL interface; this tutorial shows how to use both to retrieve Neo4J data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Neo4J. To access Neo4J data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Neo4J.

Once you have acquired the necessary connection properties, accessing Neo4J data in PowerShell can be enabled in three steps.

To connect to Neo4j, set the following connection properties:

  • Server: The server hosting the Neo4j instance.
  • Port: The port on which the Neo4j service is running. The provider connects to port 7474 by default.
  • User: The username of the user using the Neo4j instance.
  • Password: The password of the user using the Neo4j instance.

PowerShell

  1. Install the module:

    Install-Module Neo4jCmdlets
  2. Connect:

    $neo4j = Connect-Neo4j -Server "$Server" -Port "$Port" -User "$User" -Password "$Password"
  3. Search for and retrieve data:

    $categoryowner = "CData Software" $productcategory = Select-Neo4j -Connection $neo4j -Table "ProductCategory" -Where "CategoryOwner = `'$CategoryOwner`'" $productcategory

    You can also use the Invoke-Neo4j cmdlet to execute SQL commands:

    $productcategory = Invoke-Neo4j -Connection $neo4j -Query 'SELECT * FROM ProductCategory WHERE CategoryOwner = @CategoryOwner' -Params @{'@CategoryOwner'='CData Software'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Neo4J\lib\System.Data.CData.Neo4j.dll")
  2. Connect to Neo4J:

    $conn= New-Object System.Data.CData.Neo4j.Neo4jConnection("Server=localhost;Port=7474;User=my_user;Password=my_password;") $conn.Open()
  3. Instantiate the Neo4jDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT CategoryId, CategoryName from ProductCategory" $da= New-Object System.Data.CData.Neo4j.Neo4jDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.categoryid $_.categoryname }