{"id":18244386,"url":"https://github.com/dataplat/dbatools.library","last_synced_at":"2026-05-01T19:00:43.437Z","repository":{"id":61692148,"uuid":"547281305","full_name":"dataplat/dbatools.library","owner":"dataplat","description":"dbatools smo library builder","archived":false,"fork":false,"pushed_at":"2026-02-18T20:24:28.000Z","size":10216,"stargazers_count":11,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-19T01:17:42.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dataplat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["potatoqualitee","Stuart-Moore","sanderstad","jpomfret"]}},"created_at":"2022-10-07T12:29:59.000Z","updated_at":"2026-02-05T12:32:47.000Z","dependencies_parsed_at":"2024-03-11T11:28:21.773Z","dependency_job_id":"2704772b-c359-47f8-9aa4-5fe6d46632d1","html_url":"https://github.com/dataplat/dbatools.library","commit_stats":null,"previous_names":[],"tags_count":188,"template":false,"template_full_name":null,"purl":"pkg:github/dataplat/dbatools.library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools.library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools.library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools.library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools.library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataplat","download_url":"https://codeload.github.com/dataplat/dbatools.library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2Fdbatools.library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32508912,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T09:16:30.616Z","updated_at":"2026-05-01T19:00:43.417Z","avatar_url":"https://github.com/dataplat.png","language":"C#","funding_links":["https://github.com/sponsors/potatoqualitee","https://github.com/sponsors/Stuart-Moore","https://github.com/sponsors/sanderstad","https://github.com/sponsors/jpomfret"],"categories":[],"sub_categories":[],"readme":"# dbatools.library\n\n[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/dbatools.library)](https://www.powershellgallery.com/packages/dbatools.library)\n[![NuGet - Dataplat.Dbatools.Csv](https://img.shields.io/nuget/v/Dataplat.Dbatools.Csv.svg?label=nuget%20-%20Csv)](https://www.nuget.org/packages/Dataplat.Dbatools.Csv)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nThe library that powers [dbatools](https://dbatools.io), the community module for SQL Server professionals.\n\n## Overview\n\ndbatools.library is a .NET library that provides the core functionality for the dbatools PowerShell module. It includes:\n\n- SQL Server Management Objects (SMO) integration\n- Microsoft.Data.SqlClient for SQL Server connectivity\n- DacFx for database deployment operations\n- Extended Events (XEvent) processing capabilities\n- **High-performance CSV library** built for database workflows (also available as [standalone NuGet package](https://dataplat.dbatools.io/csv))\n- Multi-framework support (.NET Framework 4.7.2 and .NET 8.0)\n\nThis library enables dbatools to work seamlessly across Windows PowerShell 5.1 and PowerShell 7+ on Windows, macOS, and Linux.\n\n## Standalone NuGet Packages\n\n### Dataplat.Dbatools.Csv\n\n[![NuGet](https://img.shields.io/nuget/v/Dataplat.Dbatools.Csv.svg)](https://www.nuget.org/packages/Dataplat.Dbatools.Csv)\n\n**The CSV library built for SQL Server.** High-performance CSV reader and writer optimized for database import workflows:\n\n- **Native IDataReader** - Stream directly to SqlBulkCopy with zero intermediate allocations\n- **6x faster than LumenWorks** for typical SqlBulkCopy patterns\n- **Built-in compression** - GZip, Deflate, Brotli, ZLib with decompression bomb protection\n- **Progress \u0026 cancellation** - Monitor large imports with callbacks, cancel with CancellationToken\n- **Real-world data handling** - Lenient parsing, smart quotes, duplicate headers, field mismatches\n\n```bash\ndotnet add package Dataplat.Dbatools.Csv\n```\n\n**Resources:**\n- [Landing page](https://dataplat.dbatools.io/csv) - Quick overview and benchmarks\n- [Full documentation](project/Dataplat.Dbatools.Csv/README.md) - Complete API reference\n- [Migration guide](project/Dataplat.Dbatools.Csv/MIGRATING-FROM-LUMENWORKS.md) - For LumenWorks users\n\n## Installation\n\nInstall from the PowerShell Gallery:\n\n```powershell\n# Recommended: Install for all users (requires admin/sudo)\nInstall-Module dbatools.library -Scope AllUsers\n\n# Or install for current user only\nInstall-Module dbatools.library -Scope CurrentUser\n```\n\n## Handling DLL Conflicts with SqlServer Module\n\nIf you need to use both the SqlServer module and dbatools.library in the same session, you may encounter DLL version conflicts. dbatools.library provides the `-AvoidConflicts` parameter to automatically skip loading assemblies that are already loaded by another module.\n\n### Usage\n\nImport the SqlServer module first, then import dbatools.library **directly** with `-AvoidConflicts`:\n\n```powershell\n# Import SqlServer module first\nImport-Module SqlServer\n\n# Then import dbatools.library with -AvoidConflicts\n# IMPORTANT: Use -ArgumentList $true (NOT a hashtable)\nImport-Module dbatools.library -ArgumentList $true\n```\n\n\u003e **Note:** You must import `dbatools.library` directly, not via the `dbatools` module. The `-ArgumentList` parameter cannot be passed through module dependencies. If you need to use the full `dbatools` module with SqlServer, import `dbatools.library` first with `-ArgumentList $true`, then import `dbatools`.\n\nWhen `-AvoidConflicts` is enabled, dbatools.library will:\n- Check if each assembly is already loaded in the current session\n- Skip loading any assemblies that are already present (including Microsoft.Data.SqlClient)\n- Load only the assemblies that are missing\n\n### Examples\n\n**Basic usage with SqlServer module:**\n```powershell\nImport-Module SqlServer\nImport-Module dbatools.library -ArgumentList $true\n```\n\n**Using with the full dbatools module:**\n```powershell\nImport-Module SqlServer\nImport-Module dbatools.library -ArgumentList $true  # Load library first with AvoidConflicts\nImport-Module dbatools                              # Then load dbatools (will use already-loaded library)\n```\n\n**See what's being skipped with -Verbose:**\n```powershell\nImport-Module SqlServer\nImport-Module dbatools.library -ArgumentList $true -Verbose\n# Output will show: \"Skipping Microsoft.Data.SqlClient.dll - already loaded\" etc.\n```\n\n**Without AvoidConflicts (default behavior):**\n```powershell\n# Loads all assemblies, may cause conflicts if SqlServer module is already loaded\nImport-Module dbatools.library\n```\n\n### Common Mistakes\n\n❌ **Wrong:** Using a hashtable for ArgumentList\n```powershell\nImport-Module dbatools.library -ArgumentList @{AvoidConflicts = $true}  # This will NOT work\n```\n\n✅ **Correct:** Using a boolean value\n```powershell\nImport-Module dbatools.library -ArgumentList $true  # This works correctly\n```\n\n### ⚠️ Important: PowerShell Core + Credentials Issue\n\n**If you plan to use SQL Server credentials with PowerShell Core (pwsh), you MUST install to AllUsers scope or grant appropriate permissions.**\n\n#### The Issue\n\nWhen using `-SqlCredential` with PowerShell Core, you may encounter this error:\n\n```\nunable to load DLL 'Microsoft.Data.SqlClient.SNI.dll'\n```\n\n#### Root Cause\n\nThis is a **PowerShell Core + Microsoft.Data.SqlClient architectural limitation**, not a bug in dbatools.library:\n\n1. **Credential Impersonation**: When credentials are passed to SQL Server connections, the .NET runtime performs thread-level impersonation using those credentials.\n\n2. **DLL Access Under Impersonation**: During impersonation, `Microsoft.Data.SqlClient` tries to load its native dependency `Microsoft.Data.SqlClient.SNI.dll`, but file system access occurs under the **impersonated credential's security context**, not your current user's context.\n\n3. **Permission Denied**: The impersonated account often lacks read permissions to the module files in your local profile directory (e.g., `C:\\Users\\\u003cuser\u003e\\Documents\\PowerShell\\Modules\\`), causing the DLL load to fail.\n\n#### Why Windows PowerShell 5.1 Works\n\n- Uses `System.Data.SqlClient` which is available in the Global Assembly Cache (GAC)\n- Different assembly loading behavior that doesn't trigger the same impersonation/access pattern\n- The native SNI.dll is already loaded system-wide\n\n#### Solutions\n\n**Option 1: Install to AllUsers Scope (Recommended)**\n\n```powershell\n# Uninstall any existing CurrentUser installation first\nUninstall-Module dbatools.library -Force\nUninstall-Module dbatools -Force\n\n# Install to AllUsers scope (requires admin on Windows, sudo on Linux/macOS)\nInstall-Module dbatools.library -Scope AllUsers\nInstall-Module dbatools -Scope AllUsers\n```\n\nThis places the module in `C:\\Program Files\\PowerShell\\Modules\\` (Windows) or `/usr/local/share/powershell/Modules` (Linux/macOS), which typically has broader read permissions.\n\n**Option 2: Grant Permissions (Windows)**\n\nIf you cannot use AllUsers scope, grant the credential account read access to your PowerShell modules folder:\n\n```powershell\n$modulePath = \"$env:USERPROFILE\\Documents\\PowerShell\\Modules\"\nicacls $modulePath /grant \"DOMAIN\\User:(OI)(CI)R\" /T\n```\n\n**Option 3: Use Windows PowerShell 5.1**\n\nIf neither option above works for your environment, use Windows PowerShell instead of PowerShell Core for credential-based connections:\n\n```powershell\n# From Windows PowerShell 5.1\nImport-Module dbatools\nConnect-DbaInstance -SqlInstance server -SqlCredential $cred\n```\n\n#### Additional Notes\n\n- Commands like `Get-DbaDiskSpace -Credential` work fine because they use WinRM/PowerShell Remoting, not SQL Server authentication\n- This issue affects any PowerShell Core module using Microsoft.Data.SqlClient with credentials\n- Related to [PowerShell Issue #11616](https://github.com/PowerShell/PowerShell/issues/11616)\n\nFor more details, see [Issue #28](https://github.com/dataplat/dbatools.library/issues/28).\n\n## Development\n\n### Prerequisites\n\n- .NET SDK 8.0 or later\n- .NET Framework 4.7.2 Developer Pack (Windows only)\n- PowerShell 7.2+ or Windows PowerShell 5.1\n- Git\n\n### Building\n\n```bash\n# Clone the repository\ngit clone https://github.com/dataplat/dbatools.library.git\ncd dbatools.library\n\n# Build the library\ndotnet build project/dbatools.sln\n\n# Or build for specific configuration\ndotnet build project/dbatools.sln -c Release\n```\n\nThe compiled assemblies will be output to `artifacts/lib/`.\n\n### Multi-Framework Support\n\nThe library targets both:\n- **.NET Framework 4.7.2**: For Windows PowerShell 5.1 compatibility\n- **.NET 8.0**: For PowerShell 7+ cross-platform support\n\n### Project Structure\n\n```\ndbatools.library/\n├── project/\n│   ├── dbatools/              # Main C# library project\n│   │   └── Csv/               # CSV reader/writer source\n│   ├── Dataplat.Dbatools.Csv/ # Standalone CSV NuGet package\n│   ├── dbatools.Tests/        # Unit tests\n│   └── dbatools.sln           # Solution file\n├── build/                     # Build scripts\n├── var/                       # Runtime dependencies\n├── dbatools.library.psm1      # PowerShell module script\n├── dbatools.library.psd1      # PowerShell module manifest\n└── README.md\n```\n\n### Testing\n\n```bash\n# Run tests\ndotnet test project/dbatools.Tests/dbatools.Tests.csproj\n```\n\n### Importing for Development\n\nTo use your local development version:\n\n```powershell\n# Import the module from your local clone\nImport-Module /path/to/dbatools.library/dbatools.library.psd1 -Force\n\n# Verify the version and path\nGet-Module dbatools.library | Select-Object Name, Version, Path\n```\n\n## Key Dependencies\n\nThis library includes several major SQL Server components:\n\n| Package | Version | Purpose |\n|---------|---------|---------|\n| Microsoft.Data.SqlClient | 6.0.2 | SQL Server connectivity |\n| Microsoft.SqlServer.SqlManagementObjects | 172.76.0 | SQL Server Management Objects (SMO) |\n| Microsoft.SqlServer.DacFx | 170.0.94 | Data-tier Application Framework |\n| Microsoft.AnalysisServices | 19.101.1 | Analysis Services management |\n| Microsoft.SqlServer.XEvent.XELite | 2024.2.5.1 | Extended Events processing |\n\n### Standalone Packages\n\n| Package | Purpose |\n|---------|---------|\n| [Dataplat.Dbatools.Csv](https://dataplat.dbatools.io/csv) | High-performance CSV library for database workflows |\n\n## Contributing\n\nContributions are welcome! This library is primarily maintained by the dbatools team.\n\n### Reporting Issues\n\n- For bugs specific to this library, open an issue in this repository\n- For dbatools-related issues, use the [dbatools repository](https://github.com/dataplat/dbatools)\n- For the DLL loading issue with credentials, see [Issue #28](https://github.com/dataplat/dbatools.library/issues/28)\n\n### Pull Requests\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/your-feature`)\n3. Make your changes\n4. Add tests if applicable\n5. Ensure the build succeeds\n6. Commit your changes (`git commit -m 'Add some feature'`)\n7. Push to the branch (`git push origin feature/your-feature`)\n8. Open a Pull Request\n\n## Resources\n\n- **dbatools Website**: https://dbatools.io\n- **dbatools Documentation**: https://docs.dbatools.io\n- **dbatools Repository**: https://github.com/dataplat/dbatools\n- **Community Slack**: https://dbatools.io/slack\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplat%2Fdbatools.library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataplat%2Fdbatools.library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplat%2Fdbatools.library/lists"}