![]() |
VOOZH | about |
This guide explains everything you need to get started with the MongoDB PowerShell Cmdlets. You'll learn how to install the cmdlets, configure your first connection, run queries, and explore next steps for working with MongoDB data in PowerShell.
Accessing and integrating live data from MongoDB has never been easier with CData. Customers rely on CData connectivity to:
MongoDB's flexibility means that it can be used as a transactional, operational, or analytical database. That means CData customers use our solutions to integrate their business data with MongoDB or integrate their MongoDB data with their data warehouse (or both). Customers also leverage our live connectivity options to analyze and report on MongoDB directly from their preferred tools, like Power BI and Tableau.
For more details on MongoDB use case and how CData enhances your MongoDB experience, check out our blog post: The Top 10 Real-World MongoDB Use Cases You Should Know in 2024.
CData PowerShell Cmdlets run anywhere PowerShell runs.
CData Cmdlets are delivered through the PowerShell Gallery, ensuring a simple and consistent installation process across platforms.
Install-Module MongoDBCmdlets -Repository PSGallery -Force
This command:
To verify installation:
Get-Module -ListAvailable "*MongoDB*"
The cmdlets support both trial and fully licensed activation.
Trial activation is automatic - no key is required. Once installed, you can begin using the cmdlets immediately.
If you have purchased a full license, you will receive a product key from the CData Orders Team.
Run the following command:
Set-ModuleLicense ""
You should see a confirmation message indicating successful activation.
Can I use my license on multiple machines?
Depending on your subscription tier. Refer to your order confirmation or contact [email protected].
I lost my license key. What do I do?
Email [email protected] with your order number to have it resent.
Can I transfer my license to another machine?
Submit a license transfer request here: https://www.cdata.com/lic/transfer/.
Where can I manage my license?
Visit the CData Customer Portal: https://portal.cdata.com/.
Once the module is installed and licensed, you can establish a connection to MongoDB using the
Connect-MongoDB cmdlet
After obtaining the needed connection properties, accessing MongoDB data in PowerShell and preparing for replication consists of four basic steps.
Set the Server, Database, User, and Password connection properties to connect to MongoDB. To access MongoDB collections as tables you can use automatic schema discovery or write your own schema definitions. Schemas are defined in .rsd files, which have a simple format. You can also execute free-form queries that are not tied to the schema.
Install the module:
Install-Module MongoDBCmdlets
Connect to MongoDB:
$mongodb = Connect-MongoDB -Server $Server -Port $Port -Database $Database -User $User -Password $Password
Once connected, you can query data using standard SQL like commands.
Example Query:
$results = Select-MongoDB ` -Connection $conn ` -Table "restaurants" ` -Columns "borough,cuisine" ` -Where "borough != ''"
Display the results:
$results
You have now successfully accessed MongoDB data from PowerShell!
Solution: Verify username, password, and security token. For OAuth applications, you may need to authorize CData in your application's security settings. Contact [email protected] for authorization assistance.
Solution: Confirm firewall settings and outbound access. Most cloud applications use port 443.
Solution: Ensure the module is installed-
Get-Module -ListAvailable "*MongoDB*"
Solution:
For additional connection troubleshooting, contact [email protected] with your specific error message.
Now that you have installed, licensed, and configured the PowerShell Cmdlets, here are some scenarios you can use to explore:
| PowerShell | Article Title |
|---|---|
| Piping Cmdlets | How to pipe MongoDB Data to CSV in PowerShell |
| Replication | PowerShell Scripting to Replicate MongoDB Data to MySQLl |
If you need assistance:
Not always.
Install-Module MongoDBCmdlets -Scope CurrentUser
CData PowerShell Cmdlets are delivered through the PowerShell Gallery. Installation is performed via:
Install-Module MongoDBCmdlets -Repository PSGallery -Force
Create separate connection objects-each with different authentication properties:
$conn1 = Connect-MongoDB -User User1 -Password Pwd1
$conn2 = Connect-MongoDB -User User2 -Password Pwd2
Cmdlets do not use ODBC DSNs. All connection properties are passed directly in
Connect-MongoDB
Many cmdlets support proxy properties such as:
Refer to the data-source-specific Help documentation.
Common causes:
Try:
Contact [email protected] for query optimization assistance.
Enable module logging with:
Set-ModuleLogging -Path "C:\logs\cdata.log" -Verbosity 3Upload the log file securely when working with CData Support.
Most cloud applications (Salesforce, HubSpot, Dynamics, Google APIs, etc.) use: HTTPS (443)
If your source requires additional ports, check its specific documentation or contact [email protected].
Install PowerShell 7 in the container and install the module:
pwsh -Command "Install-Module MongoDBCmdlets -Force"Then authenticate normally.
Each cmdlet includes a Help documentation set installed locally and available online: https://www.cdata.com/powershell/.
CData releases major annual updates plus incremental updates throughout the year. Check your customer portal or contact [email protected] for version availability.
Every Cmdlet includes examples in the Help documentation, plus online examples for many services: https://www.cdata.com/powershell/. Examples include:
For questions not covered in this FAQ, [email protected].
Download a free trial of the MongoDB Cmdlets to get started:
Download NowLearn more:
👁 MongoDB IconAn easy-to-use set of PowerShell Cmdlets offering real-time access to MongoDB data. The Cmdlets allow users to easily read, write, update, and delete live data - just like working with SQL server.