bin/dbatools-index.json
[
{ "CommandName": "Export-DbaAvailabilityGroup", "Description": "Exports SQL Server Availability Groups creation scripts to a T-SQL file. This is a function that is not available in SSMS.", "Tags": [ "Hadr", "HA", "AG", "AvailabilityGroup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. SQL Server 2012 and above supported.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The Availability Group(s) to export - this list is auto-populated from the server. If unspecified, all logins will be processed.", "", false, "false", "" ], [ "ExcludeAvailabilityGroup", "The Availability Group(s) to exclude - this list is auto-populated from the server.", "", false, "false", "" ], [ "Path", "The directory name where the output files will be written. A sub directory with the format \u0027ServerName$InstanceName\u0027 will be created. A T-SQL scripts named \u0027AGName.sql\u0027 will be created under this \r\nsubdirectory for each scripted Availability Group.", "OutputLocation,FilePath", false, "false", "\"$([Environment]::GetFolderPath(\"MyDocuments\"))\\SqlAgExport\"" ], [ "NoClobber", "Do not overwrite existing export files.", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "Silent", false, "false", "False" ], [ "WhatIf", "Shows you what it\u0027d output if you were to run the command", "wi", false, "false", "" ], [ "Confirm", "Confirms each step/line of output", "cf", false, "false", "" ] ], "Alias": "", "Author": "Chris Sommer (@cjsommer), cjsommer.com", "Synopsis": "Exports SQL Server Availability Groups to a T-SQL file.", "Name": "Export-DbaAvailabilityGroup", "Links": "https://dbatools.io/Export-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2012\nExports all Availability Groups from SQL server \"sql2012\". Output scripts are written to the Documents\\SqlAgExports directory by default.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2012 -Path C:\\temp\\availability_group_exports\nExports all Availability Groups from SQL server \"sql2012\". Output scripts are written to the C:\\temp\\availability_group_exports directory.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2012 -Path \u0027C:\\dir with spaces\\availability_group_exports\u0027 -AvailabilityGroups AG1,AG2\nExports Availability Groups AG1 and AG2 from SQL server \"sql2012\". Output scripts are written to the C:\\dir with spaces\\availability_group_exports directory.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2014 -Path C:\\temp\\availability_group_exports -NoClobber\nExports all Availability Groups from SQL server \"sql2014\". Output scripts are written to the C:\\temp\\availability_group_exports directory. If the export file already exists it will not be overwritten.", "Syntax": "Export-DbaAvailabilityGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cObject[]\u003e] [[-ExcludeAvailabilityGroup] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [-NoClobber] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaCmsRegServer", "Description": "Exports registered servers and registered server groups to file", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaCmsRegServer, Get-DbaCmsRegServerGroup, CSVs and other objects.\nIf importing from CSV or other object, a column named ServerName is required. Optional columns include Name, Description and Group.", "", false, "true (ByValue)", "" ], [ "Path", "The path to the exported file. If no path is specified, one will be created.", "", false, "false", "" ], [ "CredentialPersistenceType", "Used to specify how the login and passwords are persisted. Valid values include None, PersistLoginName and PersistLoginNameAndPassword.", "", false, "false", "None" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "Export-DbaRegisteredServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports registered servers and registered server groups to file", "Name": "Export-DbaCmsRegServer", "Links": "https://dbatools.io/Export-DbaCmsRegServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaCmsRegServer -SqlInstance sql2008\nExports all Registered Server and Registered Server Groups on sql2008 to an automatically generated file name in the current directory\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaCmsRegServer -SqlInstance sql2008 -Group hr\\Seattle -Path C:\\temp\\Seattle.xml\nExports all Registered Server and Registered Server Groups with the Seattle group within the HR group on sql2008 to C:\\temp\\Seattle.xml\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2008, sql2012 | Export-DbaCmsRegServer\nExports all registered servers on sql2008 and sql2012. Warning - each one will have its own individual file. Consider piping groups.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sql2008, sql2012 | Export-DbaCmsRegServer\nExports all registered servers on sql2008 and sql2012, organized by group.", "Syntax": "Export-DbaCmsRegServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [[-CredentialPersistenceType] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaCredential", "Description": "Exports credentials INCLUDING PASSWORDS, unless specified otherwise, to sql file.\n\nRequires remote Windows access if exporting the password.", "Tags": "Credential", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Identity", "The credentials to export. If unspecified, all credentials will be exported.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Credential", "Login to the target OS using alternative credentials. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "The path to the exported sql file.", "", false, "false", "" ], [ "ExcludePassword", "Exports the SQL credential without any sensitive information.", "", false, "false", "False" ], [ "Append", "Append to Path", "", false, "false", "False" ], [ "InputObject", "Allow credentials to be piped in from Get-DbaCredential", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports credentials INCLUDING PASSWORDS, unless specified otherwise, to sql file.", "Name": "Export-DbaCredential", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaCredential -SqlInstance sql2017 -Path C:\\temp\\cred.sql\nExports credentials, including passwords, from sql2017 to the file C:\\temp\\cred.sql", "Syntax": "Export-DbaCredential [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Identity] \u003cString[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-ExcludePassword] [-Append] [[-InputObject] \u003cCredential[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaDacPackage", "Description": "Using SQLPackage, export a dacpac from an instance of SQL Server.\n\nNote - Extract from SQL Server is notoriously flaky - for example if you have three part references to external databases it will not work.\n\nFor help with the extract action parameters and properties, refer to https://msdn.microsoft.com/en-us/library/hh550080(v=vs.103).aspx", "Tags": [ "Migration", "Database", "Dacpac" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using alternative logins instead Integrated, accepts Credential object created by Get-Credential", "Credential", false, "false", "" ], [ "Database", "The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "AllUserDatabases", "Run command against all user databases", "", false, "false", "False" ], [ "Path", "The directory where the .dacpac files will be exported to. Defaults to documents.", "", false, "false", "\"$home\\Documents\"" ], [ "ExtendedParameters", "Optional parameters used to extract the DACPAC. More information can be found at\r\nhttps://msdn.microsoft.com/en-us/library/hh550080.aspx", "", false, "false", "" ], [ "ExtendedProperties", "Optional properties used to extract the DACPAC. More information can be found at\r\nhttps://msdn.microsoft.com/en-us/library/hh550080.aspx", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "Export-DbaDacpac", "Author": "Richie lee (@richiebzzzt)", "Synopsis": "Exports a dacpac from a server.", "Name": "Export-DbaDacPackage", "Links": "https://dbatools.io/Export-DbaDacPackage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaDacPackage -SqlInstance sql2016 -Database SharePoint_Config\nExports the dacpac for SharePoint_Config on sql2016 to $home\\Documents\\SharePoint_Config.dacpac\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$moreprops = \"/p:VerifyExtraction=$true /p:CommandTimeOut=10\"\nPS C:\\\u003e Export-DbaDacPackage -SqlInstance sql2016 -Database SharePoint_Config -Path C:\\temp -ExtendedProperties $moreprops\nSets the CommandTimeout to 10 then extracts the dacpac for SharePoint_Config on sql2016 to C:\\temp\\SharePoint_Config.dacpac then verifies extraction.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eExport-DbaDacPackage -SqlInstance sql2016 -AllUserDatabases -ExcludeDatabase \"DBMaintenance\",\"DBMonitoring\" C:\\temp\nExports dacpac packages for all USER databases, excluding \"DBMaintenance\" \u0026 \"DBMonitoring\", on sql2016 and saves them to C:\\temp\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$moreparams = \"/OverwriteFiles:$true /Quiet:$true\"\nPS C:\\\u003e Export-DbaDacPackage -SqlInstance sql2016 -Database SharePoint_Config -Path C:\\temp -ExtendedParameters $moreparams\nUsing extended parameters to over-write the files and performs the extraction in quiet mode.", "Syntax": "Export-DbaDacPackage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-AllUserDatabases] [[-Path] \u003cString\u003e] [[-ExtendedParameters] \u003cString\u003e] [[-ExtendedProperties] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaDiagnosticQuery", "Description": "The default output format of Invoke-DbaDiagnosticQuery is a custom object. It can also output to CSV and Excel.\nHowever, CSV output can generate a lot of files and Excel output depends on the ImportExcel module by Doug Finke (https://github.com/dfinke/ImportExcel)\nExport-DbaDiagnosticQuery can be used to convert from the default export type to the other available export types.", "Tags": "Query", "Params": [ [ "InputObject", "Specifies the objects to convert", "", true, "true (ByValue)", "" ], [ "ConvertTo", "Specifies the output type. Valid choices are Excel and CSV. CSV is the default.", "", false, "false", "Csv" ], [ "Path", "Specifies the path to the output files.", "", false, "false", "[Environment]::GetFolderPath(\"mydocuments\")" ], [ "Suffix", "Suffix for the filename. It\u0027s datetime by default.", "", false, "false", "\"$(Get-Date -format \u0027yyyyMMddHHmmssms\u0027)\"" ], [ "NoPlanExport", "Use this switch to suppress exporting of .sqlplan files", "", false, "false", "False" ], [ "NoQueryExport", "Use this switch to suppress exporting of .sql files", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "Silent", false, "false", "False" ] ], "Alias": "", "Author": "Andre Kamman (@AndreKamman), http://clouddba.io", "Synopsis": "Export-DbaDiagnosticQuery can convert output generated by Invoke-DbaDiagnosticQuery to CSV or Excel", "Name": "Export-DbaDiagnosticQuery", "Links": "https://dbatools.io/Export-DbaDiagnosticQuery", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -SqlInstance sql2016 | Export-DbaDiagnosticQuery -Path c:\\temp\nConverts output from Invoke-DbaDiagnosticQuery to multiple CSV files\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$output = Invoke-DbaDiagnosticQuery -SqlInstance sql2016\nPS C:\\\u003e Export-DbaDiagnosticQuery -InputObject $output -ConvertTo Excel\nConverts output from Invoke-DbaDiagnosticQuery to Excel worksheet(s) in the Documents folder", "Syntax": "Export-DbaDiagnosticQuery [-InputObject] \u003cObject[]\u003e [[-ConvertTo] \u003cString\u003e] [[-Path] \u003cFileInfo\u003e] [[-Suffix] \u003cString\u003e] [-NoPlanExport] [-NoQueryExport] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaExecutionPlan", "Description": "Exports execution plans to disk. Can pipe from Get-DbaExecutionPlan\n\nThanks to\nhttps://www.simple-talk.com/sql/t-sql-programming/dmvs-for-query-plan-metadata/\nand\nhttp://www.scarydba.com/2017/02/13/export-plans-cache-sqlplan-file/\nfor the idea and query.", "Tags": [ "Performance", "ExecutionPlan" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "", false, "false", "" ], [ "Database", "The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "Path", "The directory where all of the sqlxml files will be exported", "", true, "false", "" ], [ "SinceCreation", "Datetime object used to narrow the results to a date", "", false, "false", "" ], [ "SinceLastExecution", "Datetime object used to narrow the results to a date", "", false, "false", "" ], [ "PipedObject", "Internal parameter", "", true, "true (ByValue)", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "Silent", false, "false", "False" ], [ "WhatIf", "Shows what would happen if the command were to run. No actions are actually performed.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before executing any changing operations within the command.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports execution plans to disk.", "Name": "Export-DbaExecutionPlan", "Links": "https://dbatools.io/Export-DbaExecutionPlan", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaExecutionPlan -SqlInstance sqlserver2014a -Path C:\\Temp\nExports all execution plans for sqlserver2014a. Files saved in to C:\\Temp\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaExecutionPlan -SqlInstance sqlserver2014a -Database db1, db2 -SinceLastExecution \u00272016-07-01 10:47:00\u0027 -Path C:\\Temp\nExports all execution plans for databases db1 and db2 on sqlserver2014a since July 1, 2016 at 10:47 AM. Files saved in to C:\\Temp\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a | Export-DbaExecutionPlan -Path C:\\Temp\nGets all execution plans for sqlserver2014a. Using Pipeline exports them all to C:\\Temp\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a | Export-DbaExecutionPlan -Path C:\\Temp -WhatIf\nGets all execution plans for sqlserver2014a. Then shows what would happen if the results where piped to Export-DbaExecutionPlan", "Syntax": "Export-DbaExecutionPlan [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nExport-DbaExecutionPlan -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -Path \u003cString\u003e [-SinceCreation \u003cDateTime\u003e] [-SinceLastExecution \u003cDateTime\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nExport-DbaExecutionPlan [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -Path \u003cString\u003e -PipedObject \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaInstance", "Description": "Export-DbaInstance consolidates most of the export scripts in dbatools into one command.\n\nThis is useful when you\u0027re looking to Export entire instances. It less flexible than using the underlying functions.\nThink of it as an easy button. Unless an -Exclude is specified, it exports:\n\nAll databases.\nAll logins.\nAll database mail objects.\nAll credentials.\nAll objects within the Job Server (SQL Agent).\nAll linked servers.\nAll groups and servers within Central Management Server.\nAll SQL Server configuration objects (everything in sp_configure).\nAll user objects in system databases.\nAll system triggers.\nAll system backup devices.\nAll Audits.\nAll Endpoints.\nAll Extended Events.\nAll Policy Management objects.\nAll Resource Governor objects.\nAll Server Audit Specifications.\nAll Custom Errors (User Defined Messages).\nAll Server Roles.\nAll Availability Groups.", "Tags": "Export", "Params": [ [ "SqlInstance", "The target SQL Server instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Credential", "Alternative Windows credentials for exporting Linked Servers and Credentials. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "The path to the export file", "", false, "false", "" ], [ "NoRecovery", "If this switch is used, databases will be left in the No Recovery state to enable further backups to be added.", "", false, "false", "False" ], [ "IncludeDbMasterKey", "Exports the db master key then logs into the server to copy it to the $Path", "", false, "false", "False" ], [ "Exclude", "Exclude one or more objects to export\nDatabases\r\nLogins\r\nAgentServer\r\nCredentials\r\nLinkedServers\r\nSpConfigure\r\nCentralManagementServer\r\nDatabaseMail\r\nSysDbUserObjects\r\nSystemTriggers\r\nBackupDevices\r\nAudits\r\nEndpoints\r\nExtendedEvents\r\nPolicyManagement\r\nResourceGovernor\r\nServerAuditSpecifications\r\nCustomErrors\r\nServerRoles\r\nAvailabilityGroups\r\nReplicationSettings", "", false, "false", "" ], [ "BatchSeparator", "Batch separator for scripting output. \"GO\" by default.", "", false, "false", "GO" ], [ "ScriptingOption", "Add scripting options to scripting output for all objects except Registered Servers and Extended Events.", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports SQL Server *ALL* databases, logins, database mail profiles/accounts, credentials, SQL Agent objects, linked servers,\nCentral Management Server objects, server configuration settings (sp_configure), user objects in systems databases,\nsystem triggers and backup devices from one SQL Server to another.\n\nFor more granular control, please use one of the -Exclude parameters and use the other functions available within the dbatools module.", "Name": "Export-DbaInstance", "Links": "https://dbatools.io/Export-DbaInstance", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaInstance -SqlInstance sqlserver\\instance\nAll databases, logins, job objects and sp_configure options will be exported from\r\nsqlserver\\instance to an automatically generated folder name in Documents.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaInstance -SqlInstance sqlcluster -Exclude Databases, Logins -Path C:\\dr\\sqlcluster\nExports everything but logins and database restore scripts to C:\\dr\\sqlcluster", "Syntax": "Export-DbaInstance [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-NoRecovery] [-IncludeDbMasterKey] [[-Exclude] \u003cString[]\u003e] [[-BatchSeparator] \u003cString\u003e] [[-ScriptingOption] \u003cScriptingOptions\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaLinkedServer", "Description": "Exports linked servers INCLUDING PASSWORDS, unless specified otherwise, to sql file.\n\nRequires remote Windows access if exporting the password.", "Tags": "LinkedServer", "Params": [ [ "SqlInstance", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2005 or higher.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "LinkedServer", "The linked server(s) to export. If unspecified, all linked servers will be processed.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative linked servers. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Credential", "Login to the target OS using alternative linked servers. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "The path to the exported sql file.", "", false, "false", "" ], [ "ExcludePassword", "Exports the linked server without any sensitive information.", "", false, "false", "False" ], [ "Append", "Append to Path", "", false, "false", "False" ], [ "InputObject", "Allow credentials to be piped in from Get-DbaLinkedServer", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports linked servers INCLUDING PASSWORDS, unless specified otherwise, to sql file.", "Name": "Export-DbaLinkedServer", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaLinkedServer -SqlInstance sql2017 -Path C:\\temp\\ls.sql\nExports the linked servers, including passwords, from sql2017 to the file C:\\temp\\ls.sql\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaLinkedServer -SqlInstance sql2017 -Path C:\\temp\\ls.sql -ExcludePassword\nExports the linked servers, without passwords, from sql2017 to the file C:\\temp\\ls.sql", "Syntax": "Export-DbaLinkedServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-LinkedServer] \u003cString[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-ExcludePassword] [-Append] [[-InputObject] \u003cLinkedServer[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaLogin", "Description": "Exports Windows and SQL Logins to a T-SQL file. Export includes login, SID, password, default database, default language, server permissions, server roles, db permissions, db roles.", "Tags": [ "Export", "Login" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. SQL Server 2000 and above supported.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "Login", "The login(s) to process. Options for this list are auto-populated from the server. If unspecified, all logins will be processed.", "", false, "false", "" ], [ "ExcludeLogin", "The login(s) to exclude. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Database", "The database(s) to process. Options for this list are auto-populated from the server. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "Path", "The file to write to.", "OutFile,FilePath,FileName", false, "false", "" ], [ "NoClobber", "If this switch is enabled, a file already existing at the path specified by Path will not be overwritten.", "NoOverwrite", false, "false", "False" ], [ "Append", "If this switch is enabled, content will be appended to a file already existing at the path specified by Path. If the file does not exist, it will be created.", "", false, "false", "False" ], [ "NoDatabases", "If this switch is enabled, mappings for databases will not be exported.", "", false, "false", "False" ], [ "NoJobs", "If this switch is enabled, Agent job ownership will not be exported.", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "Silent", false, "false", "False" ], [ "ExcludeGoBatchSeparator", "If specified, will NOT script the \u0027GO\u0027 batch separator.", "", false, "false", "False" ], [ "DestinationVersion", "To say to which version the script should be generated. If not specified will use instance major version.", "", false, "false", "" ], [ "WhatIf", "If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.", "wi", false, "false", "" ], [ "Confirm", "If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.", "cf", false, "false", "" ] ], "Alias": "Export-SqlLogin", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports Windows and SQL Logins to a T-SQL file. Export includes login, SID, password, default database, default language, server permissions, server roles, db permissions, db roles.", "Name": "Export-DbaLogin", "Links": "https://dbatools.io/Export-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaLogin -SqlInstance sql2005 -Path C:\\temp\\sql2005-logins.sql\nExports the logins for SQL Server \"sql2005\" and writes them to the file \"C:\\temp\\sql2005-logins.sql\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2014a -Exclude realcajun -SqlCredential $scred -Path C:\\temp\\logins.sql -Append\nAuthenticates to sqlserver2014a using SQL Authentication. Exports all logins except for realcajun to C:\\temp\\logins.sql, and appends to the file if it exists. If not, the file will be created.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2014a -Login realcajun, netnerds -Path C:\\temp\\logins.sql\nExports ONLY logins netnerds and realcajun FROM sqlserver2014a to the file C:\\temp\\logins.sql\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2014a -Login realcajun, netnerds -Database HR, Accounting\nExports ONLY logins netnerds and realcajun FROM sqlserver2014a with the permissions on databases HR and Accounting\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2008 -Login realcajun, netnerds -Path C:\\temp\\login.sql -ExcludeGoBatchSeparator\nExports ONLY logins netnerds and realcajun FROM sqlserver2008 server, to the C:\\temp\\login.sql file without the \u0027GO\u0027 batch separator.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2008 -Login realcajun -Path C:\\temp\\users.sql -DestinationVersion SQLServer2016\nExports login realcajun from sqlsever2008 to the file C:\\temp\\users.sql with syntax to run on SQL Server 2016", "Syntax": "Export-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cObject[]\u003e] [[-ExcludeLogin] \u003cObject[]\u003e] [[-Database] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [-NoClobber] [-Append] [-NoDatabases] [-NoJobs] [-EnableException] [-ExcludeGoBatchSeparator] [[-DestinationVersion] \u003cString\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaPfDataCollectorSetTemplate", "Description": "Exports a Data Collector Set XML Template from Get-DbaPfDataCollectorSet. Exports to \"$home\\Documents\\Performance Monitor Templates\" by default.", "Tags": [ "Performance", "DataCollector" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative credentials. To use:\n$cred = Get-Credential, then pass $cred object to the -Credential parameter.", "", false, "false", "" ], [ "CollectorSet", "The name of the collector set(s) to export.", "DataCollectorSet", false, "false", "" ], [ "Path", "The path to export the file. Can be .xml or directory.", "", false, "false", "\"$home\\Documents\\Performance Monitor Templates\"" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSetTemplate via the pipeline.", "", false, "true (ByValue)", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports a new Data Collector Set XML Template.", "Name": "Export-DbaPfDataCollectorSetTemplate", "Links": "https://dbatools.io/Export-DbaPfDataCollectorSetTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Path C:\\temp\\pf\nExports all data collector sets from to the C:\\temp\\pf folder.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet ComputerName sql2017 -CollectorSet \u0027System Correlation\u0027 | Export-DbaPfDataCollectorSetTemplate -Path C:\\temp\nExports the \u0027System Correlation\u0027 data collector set from sql2017 to C:\\temp.", "Syntax": "Export-DbaPfDataCollectorSetTemplate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-Path] \u003cString\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaRepServerSetting", "Description": "Exports replication server settings to file.", "Tags": "Replication", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "Specifies the path to a file which will contain the output.", "", false, "false", "" ], [ "ScriptOption", "Not real sure how to use this yet", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaRepServer", "", false, "true (ByValue)", "" ], [ "Encoding", "Specifies the file encoding. The default is UTF8.\nValid values are:\r\n-- ASCII: Uses the encoding for the ASCII (7-bit) character set.\r\n-- BigEndianUnicode: Encodes in UTF-16 format using the big-endian byte order.\r\n-- Byte: Encodes a set of characters into a sequence of bytes.\r\n-- String: Uses the encoding type for a string.\r\n-- Unicode: Encodes in UTF-16 format using the little-endian byte order.\r\n-- UTF7: Encodes in UTF-7 format.\r\n-- UTF8: Encodes in UTF-8 format.\r\n-- Unknown: The encoding type is unknown or invalid. The data can be treated as binary.", "", false, "false", "UTF8" ], [ "Passthru", "Output script to console", "", false, "false", "False" ], [ "NoClobber", "Do not overwrite file", "", false, "false", "False" ], [ "Append", "Append to file", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports replication server settings to file.", "Name": "Export-DbaRepServerSetting", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaRepServerSetting -SqlInstance sql2017 -Path C:\\temp\\replication.sql\nExports the replication settings on sql2017 to the file C:\\temp\\replication.sql\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaRepServer -SqlInstance sql2017 | Export-DbaRepServerSettings -Path C:\\temp\\replication.sql\nExports the replication settings on sql2017 to the file C:\\temp\\replication.sql", "Syntax": "Export-DbaRepServerSetting [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [[-ScriptOption] \u003cObject[]\u003e] [[-InputObject] \u003cReplicationServer[]\u003e] [[-Encoding] \u003cString\u003e] [-Passthru] [-NoClobber] [-Append] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaScript", "Description": "Exports scripts from SQL Management Objects", "Tags": [ "Migration", "Backup", "Export" ], "Params": [ [ "InputObject", "A SQL Management Object such as the one returned from Get-DbaLogin", "", true, "true (ByValue)", "" ], [ "ScriptingOptionsObject", "An SMO Scripting Object that can be used to customize the output - see New-DbaScriptingOption", "ScriptingOptionObject", false, "false", "" ], [ "Path", "The output filename and location. If no path is specified, one will be created. If the file already exists, the output will be appended.", "", false, "false", "" ], [ "Encoding", "Specifies the file encoding. The default is UTF8.\nValid values are:\r\n-- ASCII: Uses the encoding for the ASCII (7-bit) character set.\r\n-- BigEndianUnicode: Encodes in UTF-16 format using the big-endian byte order.\r\n-- Byte: Encodes a set of characters into a sequence of bytes.\r\n-- String: Uses the encoding type for a string.\r\n-- Unicode: Encodes in UTF-16 format using the little-endian byte order.\r\n-- UTF7: Encodes in UTF-7 format.\r\n-- UTF8: Encodes in UTF-8 format.\r\n-- Unknown: The encoding type is unknown or invalid. The data can be treated as binary.", "", false, "false", "UTF8" ], [ "BatchSeparator", "Specifies the Batch Separator to use. Default is None", "", false, "false", "" ], [ "NoPrefix", "Do not include a Prefix", "", false, "false", "False" ], [ "Passthru", "Output script to console", "", false, "false", "False" ], [ "NoClobber", "Do not overwrite file", "", false, "false", "False" ], [ "Append", "Append to file", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "Silent", false, "false", "False" ], [ "WhatIf", "Shows what would happen if the command were to run. No actions are actually performed", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before executing any changing operations within the command", "cf", false, "false", "" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports scripts from SQL Management Objects (SMO)", "Name": "Export-DbaScript", "Links": "https://dbatools.io/Export-DbaScript", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 | Export-DbaScript\nExports all jobs on the SQL Server sql2016 instance using a trusted connection - automatically determines filename as .\\sql2016-Job-Export-date.sql\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 | Export-DbaScript -Path C:\\temp\\export.sql -Append\nExports all jobs on the SQL Server sql2016 instance using a trusted connection - Will append the output to the file C:\\temp\\export.sql if it already exists\r\nScript does not include Batch Separator and will not compile\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql2016 -Database MyDatabase -Table \u0027dbo.Table1\u0027, \u0027dbo.Table2\u0027 -SqlCredential sqladmin | Export-DbaScript -Path C:\\temp\\export.sql\nExports only script for \u0027dbo.Table1\u0027 and \u0027dbo.Table2\u0027 in MyDatabase to C:temp\\export.sql and uses the SQL login \"sqladmin\" to login to sql2016\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 -Job syspolicy_purge_history, \u0027Hourly Log Backups\u0027 -SqlCredential sqladmin | Export-DbaScript -Path C:\\temp\\export.sql -NoPrefix\nExports only syspolicy_purge_history and \u0027Hourly Log Backups\u0027 to C:temp\\export.sql and uses the SQL login \"sqladmin\" to login to sql2016\r\nSuppress the output of a Prefix\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$options = New-DbaScriptingOption\nPS C:\\\u003e $options.ScriptSchema = $true\r\nPS C:\\\u003e $options.IncludeDatabaseContext = $true\r\nPS C:\\\u003e $options.IncludeHeaders = $false\r\nPS C:\\\u003e $Options.NoCommandTerminator = $false\r\nPS C:\\\u003e $Options.ScriptBatchTerminator = $true\r\nPS C:\\\u003e $Options.AnsiFile = $true\r\nPS C:\\\u003e Get-DbaAgentJob -SqlInstance sql2016 -Job syspolicy_purge_history, \u0027Hourly Log Backups\u0027 -SqlCredential sqladmin | Export-DbaScript -Path C:\\temp\\export.sql -ScriptingOptionsObject $options\nExports only syspolicy_purge_history and \u0027Hourly Log Backups\u0027 to C:temp\\export.sql and uses the SQL login \"sqladmin\" to login to sql2016\r\nAppends a batch separator at end of each script.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2014 | Export-DbaScript -Passthru | ForEach-Object { $_.Replace(\u0027sql2014\u0027,\u0027sql2016\u0027) } | Set-Content -Path C:\\temp\\export.sql\nExports jobs and replaces all instances of the servername \"sql2014\" with \"sql2016\" then writes to C:\\temp\\export.sql\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$options = New-DbaScriptingOption\nPS C:\\\u003e $options.ScriptSchema = $true\r\nPS C:\\\u003e $options.IncludeDatabaseContext = $true\r\nPS C:\\\u003e $options.IncludeHeaders = $false\r\nPS C:\\\u003e $Options.NoCommandTerminator = $false\r\nPS C:\\\u003e $Options.ScriptBatchTerminator = $true\r\nPS C:\\\u003e $Options.AnsiFile = $true\r\nPS C:\\\u003e $Databases = Get-DbaDatabase -SqlInstance sql2016 -ExcludeDatabase master, model, msdb, tempdb\r\nPS C:\\\u003e foreach ($db in $Databases) {\r\n\u003e\u003e Export-DbaScript -InputObject $db -Path C:\\temp\\export.sql -Append -Encoding UTF8 -ScriptingOptionsObject $options -NoPrefix\r\n\u003e\u003e }\nExports Script for each database on sql2016 excluding system databases\r\nUses Scripting options to ensure Batch Terminator is set\r\nWill append the output to the file C:\\temp\\export.sql if it already exists", "Syntax": "Export-DbaScript [-InputObject] \u003cObject[]\u003e [[-ScriptingOptionsObject] \u003cScriptingOptions\u003e] [[-Path] \u003cString\u003e] [[-Encoding] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [-NoPrefix] [-Passthru] [-NoClobber] [-Append] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaSpConfigure", "Description": "Exports advanced sp_configure global configuration options to sql file.", "Tags": [ "SpConfig", "Configure", "Configuration" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input.\r\nYou must have sysadmin access if needs to set \u0027show advanced options\u0027 to 1 and server version must be SQL Server version 2005 or higher.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "Specifies the path to a file which will contain the sp_configure queries necessary to replicate the configuration settings on another instance. This file is suitable for input into \r\nImport-DbaSPConfigure.\r\nIf not specified will output to My Documents folder with default name of ServerName-MMDDYYYYhhmmss-sp_configure.sql\r\nIf a directory is passed then uses default name of ServerName-MMDDYYYYhhmmss-sp_configure.sql", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "Export-SqlSpConfigure", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports advanced sp_configure global configuration options to sql file.", "Name": "Export-DbaSpConfigure", "Links": "https://dbatools.io/Export-DbaSpConfigure", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaSpConfigure -SqlInstance sourceserver\nExports the SPConfigure settings on sourceserver. As no Path was defined outputs to My Documents folder with default name format of Servername-MMDDYYYYhhmmss-sp_configure.sql\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaSpConfigure -SqlInstance sourceserver -Path C:\\temp\nExports the SPConfigure settings on sourceserver to the directory C:\\temp using the default name format\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Export-DbaSpConfigure -SqlInstance sourceserver -SqlCredential $cred -Path C:\\temp\\sp_configure.sql\nExports the SPConfigure settings on sourceserver to the file C:\\temp\\sp_configure.sql. Uses SQL Authentication to connect. Will require SysAdmin rights if needs to set \u0027show advanced options\u0027\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027Server1\u0027, \u0027Server2\u0027 | Export-DbaSpConfigure -Path C:\\temp\\configure.sql\nExports the SPConfigure settings for Server1 and Server2 using pipeline. As more than 1 Server adds prefix of Servername and date to the file name and saves to file like \r\nC:\\temp\\Servername-MMDDYYYYhhmmss-configure.sql", "Syntax": "Export-DbaSpConfigure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaUser", "Description": "Exports users creation and its permissions to a T-SQL file or host. Export includes user, create and add to role(s), database level permissions, object level permissions.", "Tags": [ "User", "Export" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. SQL Server 2000 and above supported.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using alternative credentials\n$scred = Get-Credential, then pass $scred object to the -SqlCredential parameter\nWindows Authentication will be used if SqlCredential is not specified", "Credential", false, "false", "" ], [ "Database", "The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "User", "Export only the specified database user(s). If not specified will export all users from the database(s)", "", false, "false", "" ], [ "DestinationVersion", "To say to which version the script should be generated. If not specified will use database compatibility level", "", false, "false", "" ], [ "Path", "Specifies the full path of a file to write the script to.", "OutFile,FilePath,FileName", false, "false", "" ], [ "NoClobber", "Do not overwrite file", "NoOverwrite", false, "false", "False" ], [ "Append", "Append to file", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "Silent", false, "false", "False" ], [ "ScriptingOptionsObject", "A Microsoft.SqlServer.Management.Smo.ScriptingOptions object with the options that you want to use to generate the t-sql script.\r\nYou can use the NEw-DbaScriptingOption to generate it.", "", false, "false", "" ], [ "ExcludeGoBatchSeparator", "If specified, will NOT script the \u0027GO\u0027 batch separator.", "", false, "false", "False" ] ], "Alias": "Export-SqlUser", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Exports users creation and its permissions to a T-SQL file or host.", "Name": "Export-DbaUser", "Links": "https://dbatools.io/Export-DbaUser", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaUser -SqlInstance sql2005 -Path C:\\temp\\sql2005-users.sql\nExports SQL for the users in server \"sql2005\" and writes them to the file \"C:\\temp\\sql2005-users.sql\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2014a $scred -Path C:\\temp\\users.sql -Append\nAuthenticates to sqlserver2014a using SQL Authentication. Exports all users to C:\\temp\\users.sql, and appends to the file if it exists. If not, the file will be created.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2014a -User User1, User2 -Path C:\\temp\\users.sql\nExports ONLY users User1 and User2 from sqlsever2014a to the file C:\\temp\\users.sql\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2008 -User User1 -Path C:\\temp\\users.sql -DestinationVersion SQLServer2016\nExports user User1 from sqlsever2008 to the file C:\\temp\\users.sql with syntax to run on SQL Server 2016\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2008 -Database db1,db2 -Path C:\\temp\\users.sql\nExports ONLY users from db1 and db2 database on sqlserver2008 server, to the C:\\temp\\users.sql file.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$options = New-DbaScriptingOption\nPS C:\\\u003e $options.ScriptDrops = $false\r\nPS C:\\\u003e $options.WithDependencies = $true\r\nPS C:\\\u003e Export-DbaUser -SqlInstance sqlserver2008 -Database db1,db2 -Path C:\\temp\\users.sql -ScriptingOptionsObject $options\nExports ONLY users from db1 and db2 database on sqlserver2008 server, to the C:\\temp\\users.sql file.\r\nIt will not script drops but will script dependencies.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2008 -Database db1,db2 -Path C:\\temp\\users.sql -ExcludeGoBatchSeparator\nExports ONLY users from db1 and db2 database on sqlserver2008 server, to the C:\\temp\\users.sql file without the \u0027GO\u0027 batch separator.", "Syntax": "Export-DbaUser [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-User] \u003cObject[]\u003e] [[-DestinationVersion] \u003cString\u003e] [[-Path] \u003cString\u003e] [-NoClobber] [-Append] [-EnableException] [[-ScriptingOptionsObject] \u003cScriptingOptions\u003e] [-ExcludeGoBatchSeparator] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaXECsv", "Description": "Exports Extended Events to a CSV file.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "InputObject", "Allows Piping", "FullName", true, "true (ByValue)", "" ], [ "Path", "Specifies the InputObject to the output CSV file", "", true, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Gianluca Sartori (@spaghettidba)", "Synopsis": "Exports Extended Events to a CSV file.", "Name": "Export-DbaXECsv", "Links": "https://dbatools.io/Export-DbaXECsv", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-ChildItem -Path C:\\temp\\sample.xel | Export-DbaXECsv -Path c:\\temp\\sample.csv\nWrites Extended Events data to the file \"C:\\temp\\events.csv\".\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2014 -Session deadlocks | Export-DbaXECsv -Path c:\\temp\\events.csv\nWrites Extended Events data to the file \"C:\\temp\\events.csv\".", "Syntax": "Export-DbaXECsv [-InputObject] \u003cObject[]\u003e [-Path] \u003cString\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Export-DbaXESessionTemplate", "Description": "Exports an XESession XML Template either from the Target SQL Server or XE Session(s) output by Get-DbaXESession. Exports to \"$home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates\" by default", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "The Name of the session(s) to export.", "", false, "false", "" ], [ "Path", "The path to export the file into. Can be .xml or directory.", "", false, "false", "\"$home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates\"" ], [ "InputObject", "Specifies an XE Session output by Get-DbaXESession.", "", false, "true (ByValue)", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.\r\nThis avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because it basically disables advanced scripting.\r\nUsing this switch turns this \"nice by default\" feature off and enables you to catch exceptions with your own try/catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports an XESession XML Template using XE Session(s) output by Get-DbaXESession", "Name": "Export-DbaXESessionTemplate", "Links": "https://dbatools.io/Export-DbaXESessionTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExport-DbaXESessionTemplate -SqlInstance sql2017 -Path C:\\temp\\xe\nExports an XESession XML Template for all Extended Event Sessions on sql2017 to the C:\\temp\\xe folder.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 -Session system_health | Export-DbaXESessionTemplate -Path C:\\temp\\xe\nGets the system_health Extended Events Session from sql2017 and then exports as an XESession XML Template to C:\\temp\\xe", "Syntax": "Export-DbaXESessionTemplate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Session] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [[-InputObject] \u003cSession[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" } ] |