bin/dbatools-index.json
[
{ "CommandName": "Add-DbaAgDatabase", "Description": "Adds a database to an availability group on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The availability group where the databases will be added.", "", true, "false", "" ], [ "Database", "The database or databases to add.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase, Get-DbaDbSharePoint and more.", "", 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" ], [ "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": "Adds a database to an availability group on a SQL Server instance.", "Name": "Add-DbaAgDatabase", "Links": "https://dbatools.io/Add-DbaAgDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaAgDatabase -SqlInstance sql2017a -AvailabilityGroup ag1 -Database db1, db2 -Confirm\nAdds db1 and db2 to ag1 on sql2017a. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017a | Out-GridView -Passthru | Add-DbaAgDatabase -AvailabilityGroup ag1\nAdds selected databases from sql2017a to ag1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbSharePoint -SqlInstance sqlcluster | Add-DbaAgDatabase -AvailabilityGroup SharePoint\nAdds SharePoint databases as found in SharePoint_Config on sqlcluster to ag1 on sqlcluster\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbSharePoint -SqlInstance sqlcluster -ConfigDatabase SharePoint_Config_2019 | Add-DbaAgDatabase -AvailabilityGroup SharePoint\nAdds SharePoint databases as found in SharePoint_Config_2019 on sqlcluster to ag1 on sqlcluster", "Syntax": "Add-DbaAgDatabase [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-AvailabilityGroup] \u003cString\u003e [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaAgListener", "Description": "Adds a listener to an availability group on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The Availability Group to which a listener will be bestowed upon.", "", false, "false", "" ], [ "IPAddress", "Sets the IP address of the availability group listener.", "", false, "false", "" ], [ "SubnetMask", "Sets the subnet IP mask of the availability group listener. Defaults to 255.255.255.0.", "", false, "false", "255.255.255.0" ], [ "Port", "Sets the port number used to communicate with the availability group. Defaults to 1433.", "", false, "false", "1433" ], [ "Dhcp", "Indicates whether the listener uses DHCP.", "", false, "false", "False" ], [ "Passthru", "Don\u0027t create the listener, just pass thru an object that can be further customized before creation.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup", "", 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" ], [ "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": "Adds a listener to an availability group on a SQL Server instance.", "Name": "Add-DbaAgListener", "Links": "https://dbatools.io/Add-DbaAgListener", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaAgListener -SqlInstance sql2017 -AvailabilityGroup SharePoint -IPAddress 10.0.20.20\nCreates a listener on 10.0.20.20 port 1433 for the SharePoint availability group on sql2017.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2017 -AvailabilityGroup availabilitygroup1 | Add-DbaAgListener -Dhcp\nCreates a listener on port 1433 with a dynamic IP for the group1 availability group on sql2017.", "Syntax": "Add-DbaAgListener [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-IPAddress] \u003cIPAddress\u003e] [[-SubnetMask] \u003cIPAddress\u003e] [[-Port] \u003cInt32\u003e] [-Dhcp] [-Passthru] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaAgReplica", "Description": "Adds a replica to an availability group on a SQL Server instance.\n\nAutomatically creates a database mirroring endpoint if required.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The Availability Group to which a replica will be bestowed upon.", "", false, "false", "" ], [ "Name", "The name of the replica. Defaults to the SQL Server instance name.", "", false, "false", "" ], [ "AvailabilityMode", "Sets the availability mode of the availability group replica. Options are: AsynchronousCommit and SynchronousCommit. SynchronousCommit is default.", "", false, "false", "SynchronousCommit" ], [ "FailoverMode", "Sets the failover mode of the availability group replica. Options are Automatic and Manual. Automatic is default.", "", false, "false", "Automatic" ], [ "BackupPriority", "Sets the backup priority availability group replica. Default is 50.", "", false, "false", "50" ], [ "ConnectionModeInPrimaryRole", "Specifies the connection intent modes of an Availability Replica in primary role. AllowAllConnections by default.", "", false, "false", "AllowAllConnections" ], [ "ConnectionModeInSecondaryRole", "Specifies the connection modes of an Availability Replica in secondary role. AllowAllConnections by default.", "", false, "false", "AllowAllConnections" ], [ "SeedingMode", "Specifies how the secondary replica will be initially seeded.\nAutomatic enables direct seeding. This method will seed the secondary replica over the network. This method does not require you to backup and restore a copy of the primary database on the replica.\nManual requires you to create a backup of the database on the primary replica and manually restore that backup on the secondary replica.", "", false, "false", "Automatic" ], [ "Endpoint", "By default, this command will attempt to find a DatabaseMirror endpoint. If one does not exist, it will create it.\nIf an endpoint must be created, the name \"hadr_endpoint\" will be used. If an alternative is preferred, use Endpoint.", "", false, "false", "" ], [ "Passthru", "Don\u0027t create the replica, just pass thru an object that can be further customized before creation.", "", false, "false", "False" ], [ "ReadonlyRoutingConnectionUrl", "Sets the read only routing connection url for the availability replica.", "", false, "false", "" ], [ "Certificate", "Specifies that the endpoint is to authenticate the connection using the certificate specified by certificate_name to establish identity for authorization.\nThe far endpoint must have a certificate with the public key matching the private key of the specified certificate.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup.", "", 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" ], [ "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": "Adds a replica to an availability group on a SQL Server instance.", "Name": "Add-DbaAgReplica", "Links": "https://dbatools.io/Add-DbaAgReplica", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2017a -AvailabilityGroup SharePoint | Add-DbaAgReplica -SqlInstance sql2017b\nAdds sql2017b to the SharePoint availability group on sql2017a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2017a -AvailabilityGroup SharePoint | Add-DbaAgReplica -SqlInstance sql2017b -FailoverMode Manual\nAdds sql2017b to the SharePoint availability group on sql2017a with a manual failover mode.", "Syntax": "Add-DbaAgReplica [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString\u003e] [[-Name] \u003cString\u003e] [[-AvailabilityMode] \u003cString\u003e] [[-FailoverMode] \u003cString\u003e] [[-BackupPriority] \u003cInt32\u003e] [[-ConnectionModeInPrimaryRole] \u003cString\u003e] [[-ConnectionModeInSecondaryRole] \u003cString\u003e] [[-SeedingMode] \u003cString\u003e] [[-Endpoint] \u003cString\u003e] [-Passthru] [[-ReadonlyRoutingConnectionUrl] \u003cString\u003e] [[-Certificate] \u003cString\u003e] [[-InputObject] \u003cAvailabilityGroup\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaCmsRegServer", "Description": "Adds registered servers to SQL Server Central Management Server (CMS). If you need more flexiblity, look into Import-DbaCmsRegServer which\naccepts multiple kinds of input and allows you to add reg servers from different CMSes.", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "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", "" ], [ "ServerName", "Server Name is the actual SQL instance name (labeled Server Name)", "", true, "false", "" ], [ "Name", "Name is basically the nickname in SSMS CMS interface (labeled Registered Server Name)", "", false, "false", "$ServerName" ], [ "Description", "Adds a description for the registered server", "", false, "false", "" ], [ "Group", "Adds the registered server to a specific group.", "", false, "false", "" ], [ "InputObject", "Allows the piping of a registered server group", "", false, "true (ByValue)", "" ], [ "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" ], [ "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": "Add-DbaRegisteredServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds registered servers to SQL Server Central Management Server (CMS)", "Name": "Add-DbaCmsRegServer", "Links": "https://dbatools.io/Add-DbaCmsRegServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaCmsRegServer -SqlInstance sql2008 -ServerName sql01\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, the name \"sql01\" will be visible.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eAdd-DbaCmsRegServer -SqlInstance sql2008 -ServerName sql01 -Name \"The 2008 Clustered Instance\" -Description \"HR\u0027s Dedicated SharePoint instance\"\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, \"The 2008 Clustered Instance\" will be visible.\r\nClearly this is hard to explain ;)\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eAdd-DbaCmsRegServer -SqlInstance sql2008 -ServerName sql01 -Group hr\\Seattle\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, the name \"sql01\" will be visible within the Seattle group which is in the hr group.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sql2008 -Group hr\\Seattle | Add-DbaCmsRegServer -ServerName sql01111\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, the name \"sql01\" will be visible within the Seattle group which is in the hr group.", "Syntax": "Add-DbaCmsRegServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-ServerName] \u003cString\u003e [[-Name] \u003cString\u003e] [[-Description] \u003cString\u003e] [[-Group] \u003cObject\u003e] [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaCmsRegServerGroup", "Description": "Adds registered server groups to SQL Server Central Management Server (CMS). If you need more flexibility, look into Import-DbaCmsRegServer which accepts multiple kinds of input and allows you to add reg servers and groups from different CMS.", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "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", "" ], [ "Name", "The name of the registered server group", "", true, "false", "" ], [ "Description", "The description for the registered server group", "", false, "false", "" ], [ "Group", "The SQL Server Central Management Server group. If no groups are specified, the new group will be created at the root.", "", false, "false", "" ], [ "InputObject", "Allows results from Get-DbaCmsRegServerGroup to be piped in", "", false, "true (ByValue)", "" ], [ "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" ], [ "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": "Add-DbaRegisteredServerGroup", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds registered server groups to SQL Server Central Management Server (CMS)", "Name": "Add-DbaCmsRegServerGroup", "Links": "https://dbatools.io/Add-DbaCmsRegServerGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaCmsRegServerGroup -SqlInstance sql2012 -Name HR\nCreates a registered server group called HR, in the root of sql2012\u0027s CMS\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eAdd-DbaCmsRegServerGroup -SqlInstance sql2012, sql2014 -Name sub-folder -Group HR\nCreates a registered server group on sql2012 and sql2014 called sub-folder within the HR group\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sql2012, sql2014 -Group HR | Add-DbaCmsRegServerGroup -Name sub-folder\nCreates a registered server group on sql2012 and sql2014 called sub-folder within the HR group of each server", "Syntax": "Add-DbaCmsRegServerGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString\u003e [[-Description] \u003cString\u003e] [[-Group] \u003cString\u003e] [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaComputerCertificate", "Description": "Adds a computer certificate from a local or remote computer.", "Tags": "Certificate", "Params": [ [ "ComputerName", "The target SQL Server instance or instances. Defaults to localhost.", "ServerInstance,SqlServer,SqlInstance", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative credentials.", "", false, "false", "" ], [ "Password", "The password for the certificate, if it is password protected.", "", false, "false", "" ], [ "Certificate", "The target certificate object.", "", false, "true (ByValue)", "" ], [ "Path", "The local path to the target certificate object.", "", false, "false", "" ], [ "Store", "Certificate store. Default is LocalMachine.", "", false, "false", "LocalMachine" ], [ "Folder", "Certificate folder. Default is My (Personal).", "", false, "false", "My" ], [ "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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds a computer certificate - useful for older systems.", "Name": "Add-DbaComputerCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaComputerCertificate -ComputerName Server1 -Path C:\\temp\\cert.cer\nAdds the local C:\\temp\\cert.cer to the remote server Server1 in LocalMachine\\My (Personal).\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eAdd-DbaComputerCertificate -Path C:\\temp\\cert.cer\nAdds the local C:\\temp\\cert.cer to the local computer\u0027s LocalMachine\\My (Personal) certificate store.", "Syntax": "Add-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Password] \u003cSecureString\u003e] [[-Certificate] \u003cX509Certificate2[]\u003e] [[-Path] \u003cString\u003e] [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaDbMirrorMonitor", "Description": "Creates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on the server instance.\n\nBasically executes sp_dbmmonitoraddmonitoring.", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", "", 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" ], [ "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": "Creates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on the server instance.", "Name": "Add-DbaDbMirrorMonitor", "Links": "https://dbatools.io/Add-DbaDbMirrorMonitor", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaDbMirrorMonitor -SqlInstance sql2008, sql2012\nCreates a database mirroring monitor job that periodically updates the mirroring status for every mirrored database on sql2008 and sql2012.", "Syntax": "Add-DbaDbMirrorMonitor [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Add-DbaPfDataCollectorCounter", "Description": "Adds a Performance Data Collector Counter.", "Tags": "PerfMon", "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 Collector Set name.", "DataCollectorSet", false, "false", "" ], [ "Collector", "The Collector name.", "DataCollector", false, "false", "" ], [ "Counter", "The Counter name. This must be in the form of \u0027\\Processor(_Total)\\% Processor Time\u0027.", "Name", true, "true (ByPropertyName)", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollector 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds a Performance Data Collector Counter.", "Name": "Add-DbaPfDataCollectorCounter", "Links": "https://dbatools.io/Add-DbaPfDataCollectorCounter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eAdd-DbaPfDataCollectorCounter -ComputerName sql2017 -CollectorSet \u0027System Correlation\u0027 -Collector DataCollector01 -Counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027\nAdds the \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 counter within the DataCollector01 collector within the System Correlation collector set on sql2017.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollector | Out-GridView -PassThru | Add-DbaPfDataCollectorCounter -Counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 -Confirm\nAllows you to select which Data Collector you\u0027d like to add the counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 on localhost and prompts for confirmation.", "Syntax": "Add-DbaPfDataCollectorCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [-Counter] \u003cObject[]\u003e [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Backup-DbaDatabase", "Description": "Performs a backup of a specified type of 1 or more databases on a single SQL Server Instance. These backups may be Full, Differential or Transaction log backups.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "SqlInstance", "The SQL Server instance hosting the databases to be backed up.", "", true, "false", "" ], [ "SqlCredential", "Credentials to connect to the SQL Server instance if the calling user does not have permission.", "", 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", "" ], [ "BackupDirectory", "Path in which to place the backup files. If not specified, the backups will be placed in the default backup location for SqlInstance.\r\nIf multiple paths are specified, the backups will be striped across these locations. This will overwrite the FileCount option.\nIf the path does not exist, Sql Server will attempt to create it. Folders are created by the Sql Instance, and checks will be made for write permissions.\nFile Names with be suffixed with x-of-y to enable identifying striped sets, where y is the number of files in the set and x ranges from 1 to y.", "", false, "false", "" ], [ "BackupFileName", "The name of the file to backup to. This is only accepted for single database backups.\r\nIf no name is specified then the backup files will be named DatabaseName_yyyyMMddHHmm (i.e. \"Database1_201714022131\") with the appropriate extension.\nIf the same name is used repeatedly, SQL Server will add backups to the same file at an incrementing position.\nSQL Server needs permissions to write to the specified location. Path names are based on the SQL Server (C:\\ is the C drive on the SQL Server, not the machine running the script).\nPassing in NUL as the BackupFileName will backup to the NUL: device", "", false, "false", "" ], [ "ReplaceInName", "If this switch is set, the following list of strings will be replaced in the BackupFileName and BackupDirectory strings:\r\n instancename - will be replaced with the instance Name\r\n servername - will be replaced with the server name\r\n dbname - will be replaced with the database name\r\n timestamp - will be replaced with the timestamp (either the default, or the format provided)\r\n backuptype - will be replaced with Full, Log or Differential as appropriate", "", false, "false", "False" ], [ "CopyOnly", "If this switch is enabled, CopyOnly backups will be taken. By default function performs a normal backup, these backups interfere with the restore chain of the database. CopyOnly backups will not \r\ninterfere with the restore chain of the database.\nFor more details please refer to this MSDN article - https://msdn.microsoft.com/en-us/library/ms191495.aspx", "", false, "false", "False" ], [ "Type", "The type of SQL Server backup to perform. Accepted values are \"Full\", \"Log\", \"Differential\", \"Diff\", \"Database\"", "", false, "false", "Database" ], [ "InputObject", "Internal parameter", "", true, "true (ByValue)", "" ], [ "CreateFolder", "If this switch is enabled, each database will be backed up into a separate folder on each of the paths specified by BackupDirectory.", "", false, "false", "False" ], [ "FileCount", "This is the number of striped copies of the backups you wish to create. This value is overwritten if you specify multiple Backup Directories.", "", false, "false", "0" ], [ "CompressBackup", "If this switch is enabled, the function will try to perform a compressed backup if supported by the version and edition of SQL Server. Otherwise, this function will use the server(s) default setting \r\nfor compression.", "", false, "false", "False" ], [ "Checksum", "If this switch is enabled, the backup checksum will be calculated.", "", false, "false", "False" ], [ "Verify", "If this switch is enabled, the backup will be verified by running a RESTORE VERIFYONLY against the SqlInstance", "", false, "false", "False" ], [ "MaxTransferSize", "Sets the size of the unit of transfer. Values must be a multiple of 64kb.", "", false, "false", "0" ], [ "BlockSize", "Specifies the block size to use. Must be one of 0.5KB, 1KB, 2KB, 4KB, 8KB, 16KB, 32KB or 64KB. This can be specified in bytes.\r\nRefer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail", "", false, "false", "0" ], [ "BufferCount", "Number of I/O buffers to use to perform the operation.\r\nRefer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail", "", false, "false", "0" ], [ "AzureBaseUrl", "The URL to the base container of an Azure Storage account to write backups to.\nIf specified, the only other parameters than can be used are \"NoCopyOnly\", \"Type\", \"CompressBackup\", \"Checksum\", \"Verify\", \"AzureCredential\", \"CreateFolder\".", "", false, "false", "" ], [ "AzureCredential", "The name of the credential on the SQL instance that can write to the AzureBaseUrl, only needed if using Storage access keys\r\nIf using SAS credentials, the command will look for a credential with a name matching the AzureBaseUrl", "", false, "false", "" ], [ "NoRecovery", "This is passed in to perform a tail log backup if needed", "", false, "false", "False" ], [ "BuildPath", "By default this command will not attempt to create missing paths, this switch will change the behaviour so that it will", "", false, "false", "False" ], [ "WithFormat", "Formats the media as the first step of the backup operation. NOTE: This will set Initialize and SkipTapeHeader to $true.", "", false, "false", "False" ], [ "Initialize", "Initializes the media as part of the backup operation.", "", false, "false", "False" ], [ "SkipTapeHeader", "Initializes the media as part of the backup operation.", "", false, "false", "False" ], [ "TimeStampFormat", "By default the command timestamps backups using the format yyyyMMddHHmm. Using this parameter this can be overridden. The timestamp format should be defined using the Get-Date formats, illegal \r\nformats will cause an error to be thrown", "", false, "false", "" ], [ "IgnoreFileChecks", "This switch stops the function from checking for the validity of paths. This can be useful if SQL Server only has read access to the backup area.\r\nNote, that as we cannot check the path you may well end up with errors.", "", false, "false", "False" ], [ "OutputScriptOnly", "Switch causes only the T-SQL script for the backup to be generated. Will not create any paths if they do not exist", "", 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", "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": "", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Backup one or more SQL Sever databases from a single SQL Server SqlInstance.", "Name": "Backup-DbaDatabase", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance Server1 -Database HR, Finance\nThis will perform a full database backup on the databases HR and Finance on SQL Server Instance Server1 to Server1 default backup directory.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance sql2016 -BackupDirectory C:\\temp -Database AdventureWorks2014 -Type Full\nBacks up AdventureWorks2014 to sql2016 C:\\temp folder.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance sql2016 -AzureBaseUrl https://dbatoolsaz.blob.core.windows.net/azbackups/ -AzureCredential dbatoolscred -Type Full -CreateFolder\nPerforms a full backup of all databases on the sql2016 instance to their own containers under the https://dbatoolsaz.blob.core.windows.net/azbackups/ container on Azure blog storage using the sql \r\ncredential \"dbatoolscred\" registered on the sql2016 instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance sql2016 -AzureBaseUrl https://dbatoolsaz.blob.core.windows.net/azbackups/ -Type Full\nPerforms a full backup of all databases on the sql2016 instance to the https://dbatoolsaz.blob.core.windows.net/azbackups/ container on Azure blog storage using the Shared Access Signature sql \r\ncredential \"https://dbatoolsaz.blob.core.windows.net/azbackups\" registered on the sql2016 instance.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eBackup-Dbadatabase -SqlInstance Server1\\Prod -Database db1 -BackupDirectory \\\\filestore\\backups\\servername\\instancename\\dbname\\backuptype -Type Full -ReplaceInName\nPerforms a full backup of db1 into the folder \\\\filestore\\backups\\server1\\prod\\db1\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eBackup-Dbadatabase -SqlInstance Server1\\Prod -BackupDirectory \\\\filestore\\backups\\servername\\instancename\\dbname\\backuptype -BackupFileName dbname-backuptype-timestamp.trn -Type Log \r\n-ReplaceInName\nPerforms a log backup for every database. For the database db1 this would results in backup files in \\\\filestore\\backups\\server1\\prod\\db1\\Log\\db1-log-31102018.trn\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance Sql2017 -Database master -BackupFileName NUL\nPerforms a backup of master, but sends the output to the NUL device (ie; throws it away)", "Syntax": "Backup-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-BackupDirectory \u003cString[]\u003e] [-BackupFileName \u003cString\u003e] [-ReplaceInName] [-CopyOnly] [-Type \u003cString\u003e] [-CreateFolder] [-FileCount \u003cInt32\u003e] [-CompressBackup] [-Checksum] [-Verify] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-AzureBaseUrl \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-NoRecovery] [-BuildPath] [-WithFormat] [-Initialize] [-SkipTapeHeader] [-TimeStampFormat \u003cString\u003e] [-IgnoreFileChecks] [-OutputScriptOnly] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\nBackup-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-BackupDirectory \u003cString[]\u003e] [-BackupFileName \u003cString\u003e] [-ReplaceInName] [-CopyOnly] [-Type \u003cString\u003e] [-CreateFolder] [-FileCount \u003cInt32\u003e] [-CompressBackup] [-Checksum] [-Verify] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-AzureBaseUrl \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-NoRecovery] [-BuildPath] [-WithFormat] [-Initialize] [-SkipTapeHeader] [-TimeStampFormat \u003cString\u003e] [-IgnoreFileChecks] [-OutputScriptOnly] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nBackup-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-BackupDirectory \u003cString[]\u003e] [-BackupFileName \u003cString\u003e] [-ReplaceInName] [-CopyOnly] [-Type \u003cString\u003e] -InputObject \u003cObject[]\u003e [-CreateFolder] [-FileCount \u003cInt32\u003e] [-CompressBackup] [-Checksum] [-Verify] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-AzureBaseUrl \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-NoRecovery] [-BuildPath] [-WithFormat] [-Initialize] [-SkipTapeHeader] [-TimeStampFormat \u003cString\u003e] [-IgnoreFileChecks] [-OutputScriptOnly] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Backup-DbaDbCertificate", "Description": "Exports database certificates from SQL Server using SMO and outputs the .cer and .pvk files.", "Tags": [ "Migration", "Certificate" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Certificate", "Exports certificate that matches the name(s).", "", false, "false", "" ], [ "Database", "Exports the encryptor for specific database(s).", "", false, "false", "" ], [ "ExcludeDatabase", "Database(s) to skip when exporting encryptors.", "", false, "false", "" ], [ "EncryptionPassword", "A string value that specifies the system path to encrypt the private key.", "", false, "false", "" ], [ "DecryptionPassword", "A string value that specifies the system path to decrypt the private key.", "", false, "false", "" ], [ "Path", "The path to output the files to. The path is relative to the SQL Server itself. If no path is specified, the default data directory will be used.", "", false, "false", "" ], [ "Suffix", "The suffix of the filename of the exported certificate.", "", false, "false", "\"$(Get-Date -format \u0027yyyyMMddHHmmssms\u0027)\"" ], [ "InputObject", "Enables piping from Get-DbaDbCertificate", "", 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.", "Silent", false, "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": "Backup-DbaDatabaseCertificate", "Author": "Jess Pomfret (@jpomfret)", "Synopsis": "Exports database certificates from SQL Server using SMO.", "Name": "Backup-DbaDbCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1\nExports all the certificates on the specified SQL Server to the default data path for the instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Backup-DbaDbCertificate -SqlInstance Server1 -SqlCredential $cred\nConnects using sqladmin credential and exports all the certificates on the specified SQL Server to the default data path for the instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Certificate Certificate1\nExports only the certificate named Certificate1 on the specified SQL Server to the default data path for the instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Database AdventureWorks\nExports only the certificates for AdventureWorks on the specified SQL Server to the default data path for the instance.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -ExcludeDatabase AdventureWorks\nExports all certificates except those for AdventureWorks on the specified SQL Server to the default data path for the instance.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates -EncryptionPassword (ConvertTo-SecureString -force -AsPlainText GoodPass1234!!)\nExports all the certificates and private keys on the specified SQL Server.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$EncryptionPassword = ConvertTo-SecureString -AsPlainText \"GoodPass1234!!\" -force\nPS C:\\\u003e $DecryptionPassword = ConvertTo-SecureString -AsPlainText \"Password4567!!\" -force\r\nPS C:\\\u003e Backup-DbaDbCertificate -SqlInstance Server1 -EncryptionPassword $EncryptionPassword -DecryptionPassword $DecryptionPassword\nExports all the certificates on the specified SQL Server using the supplied DecryptionPassword, since an EncryptionPassword is specified private keys are also exported.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates\nExports all certificates on the specified SQL Server to the specified path.\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Suffix DbaTools\nExports all certificates on the specified SQL Server to the specified path, appends DbaTools to the end of the filenames.\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance sql2016 | Backup-DbaDbCertificate\nExports all certificates found on sql2016 to the default data directory.", "Syntax": "Backup-DbaDbCertificate [-SqlCredential \u003cPSCredential\u003e] [-EncryptionPassword \u003cSecureString\u003e] [-DecryptionPassword \u003cSecureString\u003e] [-Path \u003cFileInfo\u003e] [-Suffix \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nBackup-DbaDbCertificate -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Certificate \u003cObject[]\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-EncryptionPassword \u003cSecureString\u003e] [-DecryptionPassword \u003cSecureString\u003e] [-Path \u003cFileInfo\u003e] [-Suffix \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nBackup-DbaDbCertificate [-SqlCredential \u003cPSCredential\u003e] [-EncryptionPassword \u003cSecureString\u003e] [-DecryptionPassword \u003cSecureString\u003e] [-Path \u003cFileInfo\u003e] [-Suffix \u003cString\u003e] [-InputObject \u003cCertificate[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Backup-DbaDbMasterKey", "Description": "Backs up specified database master key.", "Tags": [ "Certificate", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials.", "", false, "false", "" ], [ "Credential", "Pass a credential object for the password", "", false, "false", "" ], [ "Database", "Backup master key from specific database(s).", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server.", "", false, "false", "" ], [ "Password", "The password to encrypt the exported key. This must be a SecureString.", "", false, "false", "" ], [ "Path", "The directory to export the key. If no path is specified, the default backup directory for the instance will be used.", "", false, "false", "" ], [ "InputObject", "Database object piped in from Get-DbaDatabase", "", 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" ], [ "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": "Backup-DbaDatabaseMasterKey", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Backs up specified database master key.", "Name": "Backup-DbaDbMasterKey", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eBackup-DbaDbMasterKey -SqlInstance server1\\sql2016\n```\r\nComputerName : SERVER1\r\nInstanceName : SQL2016\r\nSqlInstance : SERVER1\\SQL2016\r\nDatabase : master\r\nFilename : E:\\MSSQL13.SQL2016\\MSSQL\\Backup\\server1$sql2016-master-20170614162311.key\r\nStatus : Success\r\n```\nPrompts for export password, then logs into server1\\sql2016 with Windows credentials then backs up all database keys to the default backup directory.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eBackup-DbaDbMasterKey -SqlInstance Server1 -Database db1 -Path \\\\nas\\sqlbackups\\keys\nLogs into sql2016 with Windows credentials then backs up db1\u0027s keys to the \\\\nas\\sqlbackups\\keys directory.", "Syntax": "Backup-DbaDbMasterKey [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Password] \u003cSecureString\u003e] [[-Path] \u003cString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Clear-DbaConnectionPool", "Description": "This command resets (or empties) the connection pool.\n\nIf there are connections in use at the time of the call, they are marked appropriately and will be discarded (instead of being returned to the pool) when Close() is called on them.\n\nRef: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.clearallpools(v=vs.110).aspx", "Tags": "Connection", "Params": [ [ "ComputerName", "Target computer(s). If no computer name is specified, the local computer is targeted.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Alternate credential object to use for accessing the target computer(s).", "", 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": "Clear-DbaSqlConnectionPool", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Resets (or empties) the connection pool.", "Name": "Clear-DbaConnectionPool", "Links": "https://dbatools.io/Clear-DbaConnectionPool", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eClear-DbaConnectionPool\nClears all local connection pools.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eClear-DbaConnectionPool -ComputerName workstation27\nClears all connection pools on workstation27.", "Syntax": "Clear-DbaConnectionPool [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Clear-DbaLatchStatistics", "Description": "Reset the aggregated statistics - basically just executes DBCC SQLPERF (N\u0027sys.dm_os_latch_stats\u0027, CLEAR)", "Tags": [ "LatchStatistic", "Waits" ], "Params": [ [ "SqlInstance", "Allows you to specify a comma separated list of servers to query.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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", "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": "", "Author": "Patrick Flynn (@sqllensman)", "Synopsis": "Clears Latch Statistics", "Name": "Clear-DbaLatchStatistics", "Links": "https://dbatools.io/Clear-DbaLatchStatistics", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eClear-DbaLatchStatistics -SqlInstance sql2008, sqlserver2012\nAfter confirmation, clears latch statistics on servers sql2008 and sqlserver2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eClear-DbaLatchStatistics -SqlInstance sql2008, sqlserver2012 -Confirm:$false\nClears latch statistics on servers sql2008 and sqlserver2012, without prompting\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sql2008\u0027,\u0027sqlserver2012\u0027 | Clear-DbaLatchStatistics\nAfter confirmation, clears latch statistics on servers sql2008 and sqlserver2012\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Clear-DbaLatchStatistics -SqlInstance sql2008 -SqlCredential $cred\nConnects using sqladmin credential and clears latch statistics on servers sql2008 and sqlserver2012", "Syntax": "Clear-DbaLatchStatistics [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Clear-DbaPlanCache", "Description": "Checks ad-hoc and prepared plan cache for each database, if over 100 MBs removes from the cache.\n\nThis command automates that process.\n\nReferences: https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/", "Tags": "Memory", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Threshold", "Memory used threshold.", "", false, "false", "100" ], [ "InputObject", "Enables results to be piped in from Get-DbaPlanCache.", "", 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" ], [ "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": "", "Author": "Tracy Boggiano, databasesuperhero.com", "Synopsis": "Removes ad-hoc and prepared plan caches is single use plans are over defined threshold.", "Name": "Clear-DbaPlanCache", "Links": "https://dbatools.io/Clear-DbaPlanCache", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eClear-DbaPlanCache -SqlInstance sql2017 -Threshold 200\nLogs into the SQL Server instance \"sql2017\" and removes plan caches if over 200 MB.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eClear-DbaPlanCache -SqlInstance sql2017 -SqlCredential sqladmin\nLogs into the SQL instance using the SQL Login \u0027sqladmin\u0027 and then Windows instance as \u0027ad\\sqldba\u0027\r\nand removes if Threshold over 100 MB.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaInstance -ComputerName localhost | Get-DbaPlanCache | Clear-DbaPlanCache -Threshold 200\nScans localhost for instances using the browser service, traverses all instances and gets the plan cache for each, clears them out if they are above 200 MB.", "Syntax": "Clear-DbaPlanCache [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Threshold] \u003cInt32\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Clear-DbaWaitStatistics", "Description": "Reset the aggregated statistics - basically just executes DBCC SQLPERF (N\u0027sys.dm_os_wait_stats\u0027, CLEAR)", "Tags": [ "WaitStatistic", "Waits" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl)", "Synopsis": "Clears wait statistics", "Name": "Clear-DbaWaitStatistics", "Links": "https://dbatools.io/Clear-DbaWaitStatistics", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eClear-DbaWaitStatistics -SqlInstance sql2008, sqlserver2012\nAfter confirmation, clears wait stats on servers sql2008 and sqlserver2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eClear-DbaWaitStatistics -SqlInstance sql2008, sqlserver2012 -Confirm:$false\nClears wait stats on servers sql2008 and sqlserver2012, without prompting", "Syntax": "Clear-DbaWaitStatistics [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Connect-DbaInstance", "Description": "This command is robust because it initializes properties that do not cause enumeration by default. It also supports both Windows and SQL Server authentication methods, and detects which to use based upon the provided credentials.\n\nBy default, this command also sets the connection\u0027s ApplicationName property to \"dbatools PowerShell module - dbatools.io - custom connection\". If you\u0027re doing anything that requires profiling, you can look for this client name.\n\nAlternatively, you can pass in whichever client name you\u0027d like using the -ClientName parameter. There are a ton of other parameters for you to explore as well.\n\nSee https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx\nand https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnectionstringbuilder.aspx,\nand https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx\n\nTo execute SQL commands, you can use $server.ConnectionContext.ExecuteReader($sql) or $server.Databases[\u0027master\u0027].ExecuteNonQuery($sql)", "Tags": [ "Connect", "Connection" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Credential", "Credential object used to connect to the SQL Server Instance as a different user. This can be a Windows or SQL Server account. Windows users are determined by the existence of a backslash, so if you \r\nare intending to use an alternative Windows connection instead of a SQL login, ensure it contains a backslash.", "SqlCredential", false, "false", "" ], [ "Database", "The database(s) to process. This list is auto-populated from the server.", "", false, "false", "" ], [ "AccessToken", "Gets or sets the access token for the connection.", "", false, "false", "" ], [ "ApplicationIntent", "Declares the application workload type when connecting to a server.\nValid values are \"ReadOnly\" and \"ReadWrite\".", "", false, "false", "" ], [ "BatchSeparator", "A string to separate groups of SQL statements being executed. By default, this is \"GO\".", "", false, "false", "" ], [ "ClientName", "By default, this command sets the client\u0027s ApplicationName property to \"dbatools PowerShell module - dbatools.io - custom connection\" if you\u0027re doing anything that requires profiling, you can look \r\nfor this client name. Using -ClientName allows you to set your own custom client application name.", "", false, "false", "dbatools PowerShell module - dbatools.io - custom connection" ], [ "ConnectTimeout", "The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.\nValid values are integers between 0 and 2147483647.\nWhen opening a connection to a Azure SQL Database, set the connection timeout to 30 seconds.", "", false, "false", "([Sqlcollaborative.Dbatools.Connection.ConnectionHost]::SqlConnectionTimeout)" ], [ "EncryptConnection", "If this switch is enabled, SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed.\nFor more information, see Connection String Syntax. https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax\nBeginning in .NET Framework 4.5, when TrustServerCertificate is false and Encrypt is true, the server name (or IP address) in a SQL Server SSL certificate must exactly match the server name (or IP \r\naddress) specified in the connection string. Otherwise, the connection attempt will fail. For information about support for certificates whose subject starts with a wildcard character (*), see \r\nAccepted wildcards used by server certificates for server authentication. https://support.microsoft.com/en-us/help/258858/accepted-wildcards-used-by-server-certificates-for-server-authenticati", "", false, "false", "False" ], [ "FailoverPartner", "The name of the failover partner server where database mirroring is configured.\nIf the value of this key is \"\" (an empty string), then Initial Catalog must be present in the connection string, and its value must not be \"\".\nThe server name can be 128 characters or less.\nIf you specify a failover partner but the failover partner server is not configured for database mirroring and the primary server (specified with the Server keyword) is not available, then the \r\nconnection will fail.\nIf you specify a failover partner and the primary server is not configured for database mirroring, the connection to the primary server (specified with the Server keyword) will succeed if the primary \r\nserver is available.", "", false, "false", "" ], [ "IsActiveDirectoryUniversalAuth", "If this switch is enabled, the connection will be configured to use Azure Active Directory authentication.", "", false, "false", "False" ], [ "LockTimeout", "Sets the time in seconds required for the connection to time out when the current transaction is locked.", "", false, "false", "0" ], [ "MaxPoolSize", "Sets the maximum number of connections allowed in the connection pool for this specific connection string.", "", false, "false", "0" ], [ "MinPoolSize", "Sets the minimum number of connections allowed in the connection pool for this specific connection string.", "", false, "false", "0" ], [ "MultipleActiveResultSets", "If this switch is enabled, an application can maintain multiple active result sets (MARS).\nIf this switch is not enabled, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection.", "", false, "false", "False" ], [ "MultiSubnetFailover", "If this switch is enabled, and your application is connecting to an AlwaysOn availability group (AG) on different subnets, detection of and connection to the currently active server will be faster. \r\nFor more information about SqlClient support for Always On Availability Groups, see \r\nhttps://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/sqlclient-support-for-high-availability-disaster-recovery", "", false, "false", "False" ], [ "NetworkProtocol", "Explicitly sets the network protocol used to connect to the server.\nValid values are \"TcpIp\",\"NamedPipes\",\"Multiprotocol\",\"AppleTalk\",\"BanyanVines\",\"Via\",\"SharedMemory\" and \"NWLinkIpxSpx\"", "", false, "false", "" ], [ "NonPooledConnection", "If this switch is enabled, a non-pooled connection will be requested.", "", false, "false", "False" ], [ "PacketSize", "Sets the size in bytes of the network packets used to communicate with an instance of SQL Server. Must match at server.", "", false, "false", "0" ], [ "PooledConnectionLifetime", "When a connection is returned to the pool, its creation time is compared with the current time and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection \r\nLifetime. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.\nA value of zero (0) causes pooled connections to have the maximum connection timeout.", "", false, "false", "0" ], [ "SqlExecutionModes", "The SqlExecutionModes enumeration contains values that are used to specify whether the commands sent to the referenced connection to the server are executed immediately or saved in a buffer.\nValid values include \"CaptureSql\", \"ExecuteAndCaptureSql\" and \"ExecuteSql\".", "", false, "false", "" ], [ "StatementTimeout", "Sets the number of seconds a statement is given to run before failing with a timeout error.", "", false, "false", "0" ], [ "TrustServerCertificate", "When this switch is enabled, the channel will be encrypted while bypassing walking the certificate chain to validate trust.", "", false, "false", "False" ], [ "WorkstationId", "Sets the name of the workstation connecting to SQL Server.", "", false, "false", "" ], [ "AppendConnectionString", "Appends to the current connection string. Note that you cannot pass authentication information using this method. Use -SqlInstance and optionally -SqlCredential to set authentication information.", "", false, "false", "" ], [ "SqlConnectionOnly", "Instead of returning a rich SMO server object, this command will only return a SqlConnection object when setting this switch.", "", false, "false", "False" ] ], "Alias": "Connect-DbaServer,Get-DbaInstance", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a robust SMO SQL Server object.", "Name": "Connect-DbaInstance", "Links": "https://dbatools.io/Connect-DbaInstance", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eConnect-DbaInstance -SqlInstance sql2014\nCreates an SMO Server object that connects using Windows Authentication\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\nPS C:\\\u003e Connect-DbaInstance -SqlInstance sql2014 -Credential $wincred\nCreates an SMO Server object that connects using alternative Windows credentials\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$sqlcred = Get-Credential sqladmin\nPS C:\\\u003e $server = Connect-DbaInstance -SqlInstance sql2014 -Credential $sqlcred\nLogin to sql2014 as SQL login sqladmin.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$server = Connect-DbaInstance -SqlInstance sql2014 -ClientName \"my connection\"\nCreates an SMO Server object that connects using Windows Authentication and uses the client name \"my connection\". So when you open up profiler or use extended events, you can search for \"my \r\nconnection\".\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$server = Connect-DbaInstance -SqlInstance sql2014 -AppendConnectionString \"Packet Size=4096;AttachDbFilename=C:\\MyFolder\\MyDataFile.mdf;User Instance=true;\"\nCreates an SMO Server object that connects to sql2014 using Windows Authentication, then it sets the packet size (this can also be done via -PacketSize) and other connection attributes.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$server = Connect-DbaInstance -SqlInstance sql2014 -NetworkProtocol TcpIp -MultiSubnetFailover\nCreates an SMO Server object that connects using Windows Authentication that uses TCP/IP and has MultiSubnetFailover enabled.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$server = Connect-DbaInstance sql2016 -ApplicationIntent ReadOnly\nConnects with ReadOnly ApplicationIntent.", "Syntax": "Connect-DbaInstance [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-AccessToken] \u003cString\u003e] [[-ApplicationIntent] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [[-ClientName] \u003cString\u003e] [[-ConnectTimeout] \u003cInt32\u003e] [-EncryptConnection] [[-FailoverPartner] \u003cString\u003e] [-IsActiveDirectoryUniversalAuth] [[-LockTimeout] \u003cInt32\u003e] [[-MaxPoolSize] \u003cInt32\u003e] [[-MinPoolSize] \u003cInt32\u003e] [-MultipleActiveResultSets] [-MultiSubnetFailover] [[-NetworkProtocol] \u003cString\u003e] [-NonPooledConnection] [[-PacketSize] \u003cInt32\u003e] [[-PooledConnectionLifetime] \u003cInt32\u003e] \r\n[[-SqlExecutionModes] \u003cString\u003e] [[-StatementTimeout] \u003cInt32\u003e] [-TrustServerCertificate] [[-WorkstationId] \u003cString\u003e] [[-AppendConnectionString] \u003cString\u003e] [-SqlConnectionOnly] [\u003cCommonParameters\u003e]" }, { "CommandName": "ConvertTo-DbaDataTable", "Description": "Creates a DataTable based on an object\u0027s properties. This allows you to easily write to SQL Server tables.\n\nThanks to Chad Miller, this is based on his script. https://gallery.technet.microsoft.com/scriptcenter/4208a159-a52e-4b99-83d4-8048468d29dd\n\nIf the attempt to convert to data table fails, try the -Raw parameter for less accurate datatype detection.", "Tags": [ "DataTable", "Table", "Data" ], "Params": [ [ "InputObject", "The object to transform into a DataTable.", "", true, "true (ByValue)", "" ], [ "TimeSpanType", "Specifies the type to convert TimeSpan objects into. Default is \u0027TotalMilliseconds\u0027. Valid options are: \u0027Ticks\u0027, \u0027TotalDays\u0027, \u0027TotalHours\u0027, \u0027TotalMinutes\u0027, \u0027TotalSeconds\u0027, \u0027TotalMilliseconds\u0027, and \r\n\u0027String\u0027.", "", false, "false", "TotalMilliseconds" ], [ "SizeType", "Specifies the type to convert DbaSize objects to. Default is \u0027Int64\u0027. Valid options are \u0027Int32\u0027, \u0027Int64\u0027, and \u0027String\u0027.", "", false, "false", "Int64" ], [ "IgnoreNull", "If this switch is enabled, objects with null values will be ignored (empty rows will be added by default).", "", false, "false", "False" ], [ "Raw", "If this switch is enabled, the DataTable will be created with strings. No attempt will be made to parse/determine data types.", "", 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": "Out-DbaDataTable", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a DataTable for an object.", "Name": "ConvertTo-DbaDataTable", "Links": "https://dbatools.io/ConvertTo-DbaDataTable", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-Service | ConvertTo-DbaDataTable\nCreates a DataTable from the output of Get-Service.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eConvertTo-DbaDataTable -InputObject $csv.cheesetypes\nCreates a DataTable from the CSV object $csv.cheesetypes.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$dblist | ConvertTo-DbaDataTable\nCreates a DataTable from the $dblist object passed in via pipeline.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-Process | ConvertTo-DbaDataTable -TimeSpanType TotalSeconds\nCreates a DataTable with the running processes and converts any TimeSpan property to TotalSeconds.", "Syntax": "ConvertTo-DbaDataTable [-InputObject] \u003cPSObject[]\u003e [[-TimeSpanType] \u003cString\u003e] [-SizeType \u003cString\u003e] [-IgnoreNull] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "ConvertTo-DbaTimeline", "Description": "This function accepts input as pipeline from the following dbatools functions:\nGet-DbaAgentJobHistory\nGet-DbaBackupHistory\n(more to come...)\nAnd generates Bootstrap based, HTML file with Google Chart Timeline", "Tags": "Chart", "Params": [ [ "InputObject", "Pipe input, must an output from the above functions.", "", 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.", "", false, "false", "False" ] ], "Alias": "", "Author": "Marcin Gminski (@marcingminski)", "Synopsis": "Converts InputObject to a html timeline using Google Chart", "Name": "ConvertTo-DbaTimeline", "Links": "https://dbatools.io/ConvertTo-DbaTimeline", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql-1 -StartDate \u00272018-08-13 00:00\u0027 -EndDate \u00272018-08-13 23:59\u0027 -NoJobSteps | ConvertTo-DbaTimeline | Out-File C:\\temp\\DbaAgentJobHistory.html -Encoding \r\nASCII\nCreates an output file containing a pretty timeline for all of the agent job history results for sql-1 the whole day of 2018-08-13\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlcm | Get-DbaBackupHistory -Since \u00272018-08-13 00:00\u0027 | ConvertTo-DbaTimeline | Out-File C:\\temp\\DbaBackupHistory.html -Encoding ASCII\nCreates an output file containing a pretty timeline for the agent job history since 2018-08-13 for all of the registered servers on sqlcm\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$messageParameters = @{\n\u003e\u003e Subject = \"Backup history for sql2017 and sql2016\"\r\n\u003e\u003e Body = Get-DbaBackupHistory -SqlInstance sql2017, sql2016 -Since \u00272018-08-13 00:00\u0027 | ConvertTo-DbaTimeline\r\n\u003e\u003e From = \"dba@ad.local\"\r\n\u003e\u003e To = \"dba@ad.local\"\r\n\u003e\u003e SmtpServer = \"smtp.ad.local\"\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Send-MailMessage @messageParameters -BodyAsHtml\nSends an email to dba@ad.local with the results of Get-DbaBackupHistory. Note that viewing these reports may not be supported in all email clients.", "Syntax": "ConvertTo-DbaTimeline [-InputObject] \u003cObject[]\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "ConvertTo-DbaXESession", "Description": "Uses a slightly modified version of sp_SQLskills_ConvertTraceToExtendedEvents.sql to convert Traces to Extended Events.\n\nT-SQL code by: Jonathan M. Kehayias, SQLskills.com. T-SQL can be found in this module directory and at\nhttps://www.sqlskills.com/blogs/jonathan/converting-sql-trace-to-extended-events-in-sql-server-2012/", "Tags": [ "Trace", "ExtendedEvent" ], "Params": [ [ "InputObject", "Specifies a Trace object output by Get-DbaTrace.", "", true, "true (ByValue)", "" ], [ "Name", "The name of the Trace to convert. If the name exists, characters will be appended to it.", "", true, "false", "" ], [ "OutputScriptOnly", "Outputs the T-SQL script to create the XE session and does not execute it.", "", 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": "Uses a slightly modified version of sp_SQLskills_ConvertTraceToExtendedEvents.sql to convert Traces to Extended Events.", "Name": "ConvertTo-DbaXESession", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2017, sql2012 | Where Id -eq 2 | ConvertTo-DbaXESession -Name \u0027Test\u0027\nConverts Trace with ID 2 to a Session named Test on SQL Server instances named sql2017 and sql2012 and creates the Session on each respective server.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2014 | Out-GridView -PassThru | ConvertTo-DbaXESession -Name \u0027Test\u0027 | Start-DbaXESession\nConverts selected traces on sql2014 to sessions, creates the session, and starts it.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2014 | Where Id -eq 1 | ConvertTo-DbaXESession -Name \u0027Test\u0027 -OutputScriptOnly\nConverts trace ID 1 on sql2014 to an Extended Event and outputs the resulting T-SQL.", "Syntax": "ConvertTo-DbaXESession [-InputObject] \u003cObject[]\u003e [-Name] \u003cString\u003e [-OutputScriptOnly] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentAlert", "Description": "By default, all alerts are copied. The -Alert parameter is auto-populated for command-line completion and can be used to copy only specific alerts.\n\nIf the alert already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Agent" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Alert", "The alert(s) to process. This list is auto-populated from the server. If unspecified, all alerts will be processed.", "", false, "false", "" ], [ "ExcludeAlert", "The alert(s) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "IncludeDefaults", "Copy SQL Agent defaults such as FailSafeEmailAddress, ForwardingServer, and PagerSubjectTemplate.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, the Alert will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlAlert", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaAgentAlert migrates alerts from one SQL Server to another.", "Name": "Copy-DbaAgentAlert", "Links": "https://dbatools.io/Copy-DbaAgentAlert", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster\nCopies all alerts from sqlserver2014a to sqlcluster using Windows credentials. If alerts with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster -Alert PSAlert -SourceSqlCredential $cred -Force\nCopies a only the alert named PSAlert from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If an alert with the same name exists on \r\nsqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaAgentAlert [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Alert] \u003cObject[]\u003e] [[-ExcludeAlert] \u003cObject[]\u003e] [-IncludeDefaults] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentCategory", "Description": "By default, all SQL Agent categories for Jobs, Operators and Alerts are copied.\n\nThe -OperatorCategories parameter is auto-populated for command-line completion and can be used to copy only specific operator categories.\nThe -AgentCategories parameter is auto-populated for command-line completion and can be used to copy only specific agent categories.\nThe -JobCategories parameter is auto-populated for command-line completion and can be used to copy only specific job categories.\n\nIf the category already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Agent" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "CategoryType", "Specifies the Category Type to migrate. Valid options are \"Job\", \"Alert\" and \"Operator\". When CategoryType is specified, all categories from the selected type will be migrated. For granular \r\nmigrations, use the three parameters below.", "", false, "false", "" ], [ "JobCategory", "This parameter is auto-populated for command-line completion and can be used to copy only specific job categories.", "", false, "false", "" ], [ "AgentCategory", "This parameter is auto-populated for command-line completion and can be used to copy only specific agent categories.", "", false, "false", "" ], [ "OperatorCategory", "This parameter is auto-populated for command-line completion and can be used to copy only specific operator categories.", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Category will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlAgentCategory", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaAgentCategory migrates SQL Agent categories from one SQL Server to another. This is similar to sp_add_category.\n\nhttps://msdn.microsoft.com/en-us/library/ms181597.aspx", "Name": "Copy-DbaAgentCategory", "Links": "https://dbatools.io/Copy-DbaAgentCategory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentCategory -Source sqlserver2014a -Destination sqlcluster\nCopies all operator categories from sqlserver2014a to sqlcluster using Windows authentication. If operator categories with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentCategory -Source sqlserver2014a -Destination sqlcluster -OperatorCategory PSOperator -SourceSqlCredential $cred -Force\nCopies a single operator category, the PSOperator operator category from sqlserver2014a to sqlcluster using SQL credentials to authenticate to sqlserver2014a and Windows credentials for sqlcluster. \r\nIf an operator category with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaAgentCategory -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaAgentCategory -Source \u003cDbaInstanceParameter\u003e [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-JobCategory \u003cString[]\u003e] [-AgentCategory \u003cString[]\u003e] [-OperatorCategory \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nCopy-DbaAgentCategory -Source \u003cDbaInstanceParameter\u003e [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-CategoryType \u003cString[]\u003e] [-JobCategory \u003cString[]\u003e] [-AgentCategory \u003cString[]\u003e] [-OperatorCategory \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentJob", "Description": "By default, all jobs are copied. The -Job parameter is auto-populated for command-line completion and can be used to copy only specific jobs.\n\nIf the job already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Agent", "Job" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Job", "The job(s) to process. This list is auto-populated from the server. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "DisableOnSource", "If this switch is enabled, the job will be disabled on the source server.", "", false, "false", "False" ], [ "DisableOnDestination", "If this switch is enabled, the newly migrated job will be disabled on the destination server.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, the Job will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlJob", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaAgentJob migrates jobs from one SQL Server to another.", "Name": "Copy-DbaAgentJob", "Links": "https://dbatools.io/Copy-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentJob -Source sqlserver2014a -Destination sqlcluster\nCopies all jobs from sqlserver2014a to sqlcluster, using Windows credentials. If jobs with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentJob -Source sqlserver2014a -Destination sqlcluster -Job PSJob -SourceSqlCredential $cred -Force\nCopies a single job, the PSJob job from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a job with the same name exists on \r\nsqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaAgentJob -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaAgentJob [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [[-ExcludeJob] \u003cObject[]\u003e] [-DisableOnSource] [-DisableOnDestination] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentOperator", "Description": "By default, all operators are copied. The -Operators parameter is auto-populated for command-line completion and can be used to copy only specific operators.\n\nIf the associated credentials for the operator do not exist on the destination, it will be skipped. If the operator already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Agent", "Operator" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Operator", "The operator(s) to process. This list is auto-populated from the server. If unspecified, all operators will be processed.", "", false, "false", "" ], [ "ExcludeOperator", "The operators(s) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Operator will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlOperator", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaAgentOperator migrates operators from one SQL Server to another.", "Name": "Copy-DbaAgentOperator", "Links": "https://dbatools.io/Copy-DbaAgentOperator", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentOperator -Source sqlserver2014a -Destination sqlcluster\nCopies all operators from sqlserver2014a to sqlcluster using Windows credentials. If operators with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentOperator -Source sqlserver2014a -Destination sqlcluster -Operator PSOperator -SourceSqlCredential $cred -Force\nCopies only the PSOperator operator from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If an operator with the same name exists on \r\nsqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaAgentOperator -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaAgentOperator [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Operator] \u003cObject[]\u003e] [[-ExcludeOperator] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentProxyAccount", "Description": "By default, all proxy accounts are copied. The -ProxyAccounts parameter is auto-populated for command-line completion and can be used to copy only specific proxy accounts.\n\nIf the associated credential for the account does not exist on the destination, it will be skipped. If the proxy account already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Agent" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "ProxyAccount", "Only migrate specific proxy accounts", "", false, "false", "" ], [ "ExcludeProxyAccount", "Migrate all proxy accounts except the ones explicitly excluded", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Operator will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlProxyAccount", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaAgentProxyAccount migrates proxy accounts from one SQL Server to another.", "Name": "Copy-DbaAgentProxyAccount", "Links": "https://dbatools.io/Copy-DbaAgentProxyAccount", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentProxyAccount -Source sqlserver2014a -Destination sqlcluster\nCopies all proxy accounts from sqlserver2014a to sqlcluster using Windows credentials. If proxy accounts with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentProxyAccount -Source sqlserver2014a -Destination sqlcluster -ProxyAccount PSProxy -SourceSqlCredential $cred -Force\nCopies only the PSProxy proxy account from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a proxy account with the same name exists \r\non sqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaAgentProxyAccount -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaAgentProxyAccount [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ProxyAccount] \u003cString[]\u003e] [[-ExcludeProxyAccount] \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentServer", "Description": "A wrapper function that calls the associated Copy command for each of the object types seen in SSMS under SQL Server Agent. This also copies all of the the SQL Agent properties (job history max rows, DBMail profile name, etc.).\n\nYou must have sysadmin access and server version must be SQL Server version 2000 or greater.", "Tags": [ "Migration", "SqlServerAgent", "SqlAgent" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DisableJobsOnDestination", "If this switch is enabled, the jobs will be disabled on Destination after copying.", "", false, "false", "False" ], [ "DisableJobsOnSource", "If this switch is enabled, the jobs will be disabled on Source after copying.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, existing objects on Destination with matching names from Source will be dropped, then copied.", "", 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", "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": "Copy-DbaSqlServerAgent,Copy-SqlServerAgent", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy SQL Server Agent from one server to another.", "Name": "Copy-DbaAgentServer", "Links": "https://dbatools.io/Copy-DbaAgentServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentServer -Source sqlserver2014a -Destination sqlcluster\nCopies all job server objects from sqlserver2014a to sqlcluster using Windows credentials for authentication. If job objects with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentServer -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nCopies all job objects from sqlserver2014a to sqlcluster using SQL credentials to authentication to sqlserver2014a and Windows credentials to authenticate to sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaAgentServer -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.", "Syntax": "Copy-DbaAgentServer [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-DisableJobsOnDestination] [-DisableJobsOnSource] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaAgentSharedSchedule", "Description": "All shared job schedules are copied.\n\nIf the associated credential for the account does not exist on the destination, it will be skipped. If the shared job schedule already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Agent" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Operator will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlSharedSchedule", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaAgentSharedSchedule migrates shared job schedules from one SQL Server to another.", "Name": "Copy-DbaAgentSharedSchedule", "Links": "https://dbatools.io/Copy-DbaAgentSharedSchedule", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaAgentSharedSchedule -Source sqlserver2014a -Destination sqlcluster\nCopies all shared job schedules from sqlserver2014a to sqlcluster using Windows credentials. If shared job schedules with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaAgentSharedSchedule -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaAgentSharedSchedule [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaBackupDevice", "Description": "Backups are migrated using Admin shares. If the destination directory does not exist, SQL Server\u0027s default backup directory will be used.\n\nIf a backup device with same name exists on destination, it will not be dropped and recreated unless -Force is used.", "Tags": [ "Migration", "Backup" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "BackupDevice", "BackupDevice to be copied. Auto-populated list of devices. If not provided all BackupDevice(s) will be copied.", "", false, "false", "" ], [ "Force", "If this switch is enabled, backup device(s) will be dropped and recreated if they already exists on destination.", "", 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", "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": "Copy-SqlBackupDevice", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copies backup devices one by one. Copies both SQL code and the backup file itself.", "Name": "Copy-DbaBackupDevice", "Links": "https://dbatools.io/Copy-DbaBackupDevice", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaBackupDevice -Source sqlserver2014a -Destination sqlcluster\nCopies all server backup devices from sqlserver2014a to sqlcluster using Windows credentials. If backup devices with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaBackupDevice -Source sqlserver2014a -Destination sqlcluster -BackupDevice backup01 -SourceSqlCredential $cred -Force\nCopies only the backup device named backup01 from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a backup device with the same \r\nname exists on sqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaBackupDevice -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaBackupDevice [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-BackupDevice] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaCentralManagementServer", "Description": "Copy-DbaCentralManagementServer copies all groups, subgroups, and server instances from one SQL Server to another.", "Tags": "Migration", "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "CMSGroup", "This is an auto-populated array that contains your Central Management Server top-level groups on Source. You can specify one, many or none.\nIf CMSGroup is not specified, all groups in your Central Management Server will be copied.", "", false, "false", "" ], [ "SwitchServerName", "If this switch is enabled, all instance names will be changed from Source to Destination.\nCentral Management Server does not allow you to add a shared registered server with the same name as the Configuration Server.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, group(s) will be dropped and recreated if they already exists on destination.", "", 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", "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": "Copy-SqlCentralManagementServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates SQL Server Central Management groups and server instances from one SQL Server to another.", "Name": "Copy-DbaCentralManagementServer", "Links": "https://dbatools.io/Copy-DbaCentralManagementServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaCentralManagementServer -Source sqlserver2014a -Destination sqlcluster\nAll groups, subgroups, and server instances are copied from sqlserver2014a CMS to sqlcluster CMS.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaCentralManagementServer -Source sqlserver2014a -Destination sqlcluster -CMSGroup Group1,Group3\nTop-level groups Group1 and Group3 along with their subgroups and server instances are copied from sqlserver to sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaCentralManagementServer -Source sqlserver2014a -Destination sqlcluster -CMSGroup Group1,Group3 -SwitchServerName -SourceSqlCredential $SourceSqlCredential -DestinationSqlCredential \r\n$DestinationSqlCredential\nTop-level groups Group1 and Group3 along with their subgroups and server instances are copied from sqlserver to sqlcluster. When adding sql instances to sqlcluster, if the server name of the \r\nmigrating instance is \"sqlcluster\", it will be switched to \"sqlserver\".\nIf SwitchServerName is not specified, \"sqlcluster\" will be skipped.", "Syntax": "Copy-DbaCentralManagementServer [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-CMSGroup] \u003cObject[]\u003e] [-SwitchServerName] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaCredential", "Description": "By using password decryption techniques provided by Antti Rantasaari (NetSPI, 2014), this script migrates SQL Server Credentials from one server to another while maintaining username and password.\n\nCredit: https://blog.netspi.com/decrypting-mssql-database-link-server-passwords/", "Tags": [ "WSMan", "Migration" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Credential", "This command requires access to the Windows OS via PowerShell remoting. Use this credential to connect to Windows using alternative credentials.", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "Only include specific names\r\nNote: if spaces exist in the credential name, you will have to type \"\" or \u0027\u0027 around it.", "", false, "false", "" ], [ "ExcludeName", "Excluded credential names", "", false, "false", "" ], [ "Identity", "Only include specific identities\r\nNote: if spaces exist in the credential identity, you will have to type \"\" or \u0027\u0027 around it.", "CredentialIdentity", false, "false", "" ], [ "ExcludeIdentity", "Excluded identities", "ExcludeCredentialIdentity", false, "false", "" ], [ "Force", "If this switch is enabled, the Credential will be dropped and recreated if it already exists on Destination.", "", 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", "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": "Copy-SqlCredential", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaCredential migrates SQL Server Credentials from one SQL Server to another while maintaining Credential passwords.", "Name": "Copy-DbaCredential", "Links": "https://dbatools.io/Copy-DbaCredential", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaCredential -Source sqlserver2014a -Destination sqlcluster\nCopies all SQL Server Credentials on sqlserver2014a to sqlcluster. If Credentials exist on destination, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaCredential -Source sqlserver2014a -Destination sqlcluster -Name \"PowerShell Proxy Account\" -Force\nCopies over one SQL Server Credential (PowerShell Proxy Account) from sqlserver to sqlcluster. If the Credential already exists on the destination, it will be dropped and recreated.", "Syntax": "Copy-DbaCredential [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-ExcludeName] \u003cString[]\u003e] [[-Identity] \u003cString[]\u003e] [[-ExcludeIdentity] \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaCustomError", "Description": "By default, all custom errors are copied. The -CustomError parameter is auto-populated for command-line completion and can be used to copy only specific custom errors.\n\nIf the custom error already exists on the destination, it will be skipped unless -Force is used. The us_english version must be created first. If you drop the us_english version, all the other languages will be dropped for that specific ID as well.", "Tags": [ "Migration", "CustomError" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "CustomError", "The custom error(s) to process. This list is auto-populated from the server. If unspecified, all custom errors will be processed.", "", false, "false", "" ], [ "ExcludeCustomError", "The custom error(s) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "Force", "If this switch is enabled, the custom error will be dropped and recreated if it already exists on Destination.", "", 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", "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": "Copy-SqlCustomError", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaCustomError migrates custom errors (user defined messages), by the custom error ID, from one SQL Server to another.", "Name": "Copy-DbaCustomError", "Links": "https://dbatools.io/Copy-DbaCustomError", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -Destination sqlcluster\nCopies all server custom errors from sqlserver2014a to sqlcluster using Windows credentials. If custom errors with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -SourceSqlCredential $scred -Destination sqlcluster -DestinationSqlCredential $dcred -CustomError 60000 -Force\nCopies only the custom error with ID number 60000 from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a custom error with the same \r\nname exists on sqlcluster, it will be updated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -Destination sqlcluster -ExcludeCustomError 60000 -Force\nCopies all the custom errors found on sqlserver2014a except the custom error with ID number 60000 to sqlcluster. If a custom error with the same name exists on sqlcluster, it will be updated because \r\n-Force was used.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaCustomError [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-CustomError] \u003cObject[]\u003e] [[-ExcludeCustomError] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaDatabase", "Description": "This script provides the ability to migrate databases using detach/copy/attach or backup/restore. This script works with named instances, clusters and SQL Server Express Edition.\n\nBy default, databases will be migrated to the destination SQL Server\u0027s default data and log directories. You can override this by specifying -ReuseSourceFolderStructure. Filestreams and filegroups are also migrated. Safety is emphasized.", "Tags": [ "Migration", "Backup", "Restore" ], "Params": [ [ "Source", "Source SQL Server.", "", false, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You may specify multiple servers.\nNote that when using -BackupRestore with multiple servers, the backup will only be performed once and backups will be deleted at the end (if you didn\u0027t specify -NoBackupCleanup).\nWhen using -DetachAttach with multiple servers, -Reattach must be specified.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Migrates only specified databases. This list is auto-populated from the server for tab completion. Multiple databases may be specified as a collection.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Excludes specified databases when performing -AllDatabases migrations. This list is auto-populated from the Source for tab completion.", "", false, "false", "" ], [ "AllDatabases", "If this switch is enabled, all user databases will be migrated. System and support databases will not be migrated. Requires -BackupRestore or -DetachAttach.", "All", false, "false", "False" ], [ "BackupRestore", "If this switch is enabled, the copy-only backup and restore method will be used to migrate the database(s). This method requires that you specify -SharedPath in a valid UNC format (\\\\server\\share).\nBackups will be immediately deleted after use unless -NoBackupCleanup is specified.", "", true, "false", "False" ], [ "SharedPath", "Specifies the network location for the backup files. The SQL Server service accounts must have read/write permission on this path.", "", false, "false", "" ], [ "WithReplace", "If this switch is enabled, the restore is executed with WITH REPLACE.", "", false, "false", "False" ], [ "NoRecovery", "If this switch is enabled, the restore is executed with WITH NORECOVERY. Ideal for staging.", "", false, "false", "False" ], [ "NoBackupCleanup", "If this switch is enabled, backups generated by this cmdlet will not be deleted after they are restored. The default behavior is to delete these backups.", "", false, "false", "False" ], [ "NumberFiles", "Number of files to split the backup. Default is 3.", "", false, "false", "3" ], [ "DetachAttach", "If this switch is enabled, the detach/copy/attach method is used to perform database migrations. No files are deleted on Source. If Destination attachment fails, the Source database will be \r\nreattached. File copies are performed over administrative shares (\\\\server\\x$\\mssql) using BITS. If a database is being mirrored, the mirror will be broken prior to migration.", "", true, "false", "False" ], [ "Reattach", "If this switch is enabled, all databases are reattached to Source after DetachAttach migration.", "", false, "false", "False" ], [ "SetSourceReadOnly", "If this switch is enabled, all migrated databases are set to ReadOnly on Source prior to detach/attach \u0026 backup/restore.\nIf -Reattach is used, databases are set to read-only after reattaching.", "", false, "false", "False" ], [ "ReuseSourceFolderStructure", "If this switch is enabled, databases will be migrated to a data and log directory structure on Destination mirroring that used on Source. By default, the default data and log directories for \r\nDestination will be used when the databases are migrated.\nThe structure on Source will be kept exactly, so consider this if you\u0027re migrating between different versions and use part of Microsoft\u0027s default Sql structure (MSSql12.INSTANCE, etc)\nTo reuse Destination folder structure, use the -WithReplace switch.", "ReuseFolderStructure", false, "false", "False" ], [ "IncludeSupportDbs", "If this switch is enabled, ReportServer, ReportServerTempDb, SSISDB, and distribution databases will be copied if they exist on Source. A log file named $SOURCE-$destinstance-$date-Sqls.csv will be \r\nwritten to the current directory.\nUse of this switch requires -BackupRestore or -DetachAttach as well.", "", false, "false", "False" ], [ "UseLastBackup", "Use the last full, diff and logs instead of performing backups. Note that the backups must exist in a location accessible by all destination servers, such a network share.", "", false, "false", "False" ], [ "Continue", "If specified, will to attempt to restore transaction log backups on top of existing database(s) in Recovering or Standby states. Only usable with -UseLastBackup", "", false, "false", "False" ], [ "InputObject", "A collection of dbobjects from the pipeline.", "", false, "true (ByValue)", "" ], [ "NoCopyOnly", "If this switch is enabled, backups will be taken without COPY_ONLY. This will break the LSN backup chain, which will interfere with the restore chain of the database.\nBy default this switch is disabled, so backups will be taken with COPY_ONLY. This will preserve the LSN backup chain.\nFor more details please refer to this MSDN article - https://msdn.microsoft.com/en-us/library/ms191495.aspx", "", false, "false", "False" ], [ "SetSourceOffline", "If this switch is enabled, the Source database will be set to Offline after being copied.", "", false, "false", "False" ], [ "NewName", "If a single database is being copied, this will be used to rename the database during the copy process. Any occurrence of the original database name in the physical file names will be replaced with \r\nNewName\r\nIf specified with multiple databases a warning will be raised and the copy stopped\nThis option is mutually exclusive of Prefix", "", false, "false", "" ], [ "Prefix", "All copied database names and physical files will be prefixed with this string\nThis option is mutually exclusive of NewName", "", false, "false", "" ], [ "Force", "If this switch is enabled, existing databases on Destination with matching names from Source will be dropped. If using -DetachReattach, mirrors will be broken and the database(s) dropped from \r\nAvailability Groups.", "", 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", "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": "Copy-SqlDatabase", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates SQL Server databases from one SQL Server to another.", "Name": "Copy-DbaDatabase", "Links": "https://dbatools.io/Copy-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaDatabase -Source sql2014a -Destination sql2014b -Database TestDB -BackupRestore -SharedPath \\\\fileshare\\sql\\migration\nMigrates a single user database TestDB using Backup and restore from instance sql2014a to sql2014b. Backup files are stored in \\\\fileshare\\sql\\migration.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaDatabase -Source sql2012 -Destination sql2014, sql2016 -DetachAttach -Reattach\nDatabases will be migrated from sql2012 to both sql2014 and sql2016 using the detach/copy files/attach method.The following will be performed: kick all users out of the database, detach all data/log \r\nfiles, move files across the network over an admin share (\\\\SqlSERVER\\M$\\MSSql...), attach file on destination server, reattach at source. If the database files (*.mdf, *.ndf, *.ldf) on *destination* \r\nexist and aren\u0027t in use, they will be overwritten.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaDatabase -Source sql2014a -Destination sqlcluster, sql2016 -BackupRestore -UseLastBackup -Force\nMigrates all user databases to sqlcluster and sql2016 using the last Full, Diff and Log backups from sql204a. If the databases exists on the destinations, they will be dropped prior to attach.\nNote that the backups must exist in a location accessible by all destination servers, such a network share.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaDatabase -Source sql2014a -Destination sqlcluster -ExcludeDatabase Northwind, pubs -IncludeSupportDbs -Force -BackupRestore -SharedPath \\\\fileshare\\sql\\migration\nMigrates all user databases except for Northwind and pubs by using backup/restore (copy-only). Backup files are stored in \\\\fileshare\\sql\\migration. If the database exists on the destination, it will \r\nbe dropped prior to attach.\nIt also includes the support databases (ReportServer, ReportServerTempDb, distribution).", "Syntax": "Copy-DbaDatabase [-Source \u003cDbaInstanceParameter\u003e] [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] -BackupRestore [-SharedPath \u003cString\u003e] [-WithReplace] [-NoRecovery] [-NoBackupCleanup] [-NumberFiles \u003cInt32\u003e] [-SetSourceReadOnly] [-ReuseSourceFolderStructure] [-IncludeSupportDbs] [-UseLastBackup] [-Continue] [-InputObject \u003cDatabase[]\u003e] [-NoCopyOnly] [-SetSourceOffline] [-NewName \u003cString\u003e] [-Prefix \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\nCopy-DbaDatabase [-Source \u003cDbaInstanceParameter\u003e] [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] -DetachAttach [-Reattach] [-SetSourceReadOnly] [-ReuseSourceFolderStructure] [-IncludeSupportDbs] [-InputObject \u003cDatabase[]\u003e] [-NoCopyOnly] [-SetSourceOffline] [-NewName \u003cString\u003e] [-Prefix \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaDataCollector", "Description": "By default, all data collector objects are migrated. If the object already exists on the destination, it will be skipped unless -Force is used.\n\nThe -CollectionSet parameter is auto-populated for command-line completion and can be used to copy only specific objects.", "Tags": [ "Migration", "DataCollection" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination Sql Server. You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "CollectionSet", "The collection set(s) to process - this list is auto-populated from the server. If unspecified, all collection sets will be processed.", "", false, "false", "" ], [ "ExcludeCollectionSet", "The collection set(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "NoServerReconfig", "Upcoming parameter to enable server reconfiguration", "", false, "false", "False" ], [ "Force", "If collection sets exists on destination server, it will be dropped and recreated.", "", 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": "Copy-DbaSqlDataCollector,Copy-SqlDataCollector", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates user SQL Data Collector collection sets. SQL Data Collector configuration is on the agenda, but it\u0027s hard.", "Name": "Copy-DbaDataCollector", "Links": "https://dbatools.io/Copy-DbaDataCollector", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster\nCopies all Data Collector Objects and Configurations from sqlserver2014a to sqlcluster, using Windows credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nCopies all Data Collector Objects and Configurations from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster -CollectionSet \u0027Server Activity\u0027, \u0027Table Usage Analysis\u0027\nCopies two Collection Sets, Server Activity and Table Usage Analysis, from sqlserver2014a to sqlcluster.", "Syntax": "Copy-DbaDataCollector [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-CollectionSet] \u003cObject[]\u003e] [[-ExcludeCollectionSet] \u003cObject[]\u003e] [-NoServerReconfig] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaDbAssembly", "Description": "By default, all assemblies are copied.\n\nIf the assembly already exists on the destination, it will be skipped unless -Force is used.\n\nThis script does not yet copy dependencies or dependent objects.", "Tags": [ "Migration", "Assembly" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Assembly", "The assembly(ies) to process. This list is auto-populated from the server. If unspecified, all assemblies will be processed.", "", false, "false", "" ], [ "ExcludeAssembly", "The assembly(ies) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "Force", "If this switch is enabled, existing assemblies on Destination with matching names from Source will be dropped.", "", 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", "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": "Copy-DbaDatabaseAssembly,Copy-SqlDatabaseAssembly", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaDbAssembly migrates assemblies from one SQL Server to another.", "Name": "Copy-DbaDbAssembly", "Links": "http://dbatools.io/Get-SqlDatabaseAssembly", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaDbAssembly -Source sqlserver2014a -Destination sqlcluster\nCopies all assemblies from sqlserver2014a to sqlcluster using Windows credentials. If assemblies with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaDbAssembly -Source sqlserver2014a -Destination sqlcluster -Assembly dbname.assemblyname, dbname3.anotherassembly -SourceSqlCredential $cred -Force\nCopies two assemblies, the dbname.assemblyname and dbname3.anotherassembly from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If an \r\nassembly with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.\nIn this example, anotherassembly will be copied to the dbname3 database on the server sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaDbAssembly -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaDbAssembly [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Assembly] \u003cObject[]\u003e] [[-ExcludeAssembly] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaDbMail", "Description": "By default, all mail configurations for Profiles, Accounts, Mail Servers and Configs are copied.", "Tags": [ "Migration", "Mail" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "Type", "Specifies the object type to migrate. Valid options are \"Job\", \"Alert\" and \"Operator\". When Type is specified, all categories from the selected type will be migrated.", "", false, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Force", "If this switch is enabled, existing objects on Destination with matching names from Source will be dropped.", "", 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", "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": "Copy-DbaDatabaseMail,Copy-SqlDatabaseMail", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates Mail Profiles, Accounts, Mail Servers and Mail Server Configs from one SQL Server to another.", "Name": "Copy-DbaDbMail", "Links": "https://dbatools.io/Copy-DbaDbMail", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster\nCopies all database mail objects from sqlserver2014a to sqlcluster using Windows credentials. If database mail objects with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nCopies all database mail objects from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster -EnableException\nPerforms execution of function, and will throw a terminating exception if something breaks", "Syntax": "Copy-DbaDbMail -Source \u003cDbaInstanceParameter\u003e -Destination \u003cDbaInstanceParameter[]\u003e [-SourceSqlCredential \u003cPSCredential\u003e] [-DestinationSqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nCopy-DbaDbMail -Source \u003cDbaInstanceParameter\u003e -Destination \u003cDbaInstanceParameter[]\u003e [-Type \u003cString[]\u003e] [-SourceSqlCredential \u003cPSCredential\u003e] [-DestinationSqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaDbTableData", "Description": "Copies data between SQL Server tables using SQL Bulk Copy.\nThe same can be achieved also doing\n$sourcetable = Invoke-DbaQuery -SqlInstance instance1 ... -As DataTable\nWrite-DbaDataTable -SqlInstance ... -InputObject $sourcetable\nbut it will force buffering the contents on the table in memory (high RAM usage for large tables).\nWith this function, a streaming copy will be done in the most speedy and least resource-intensive way.", "Tags": "Migration", "Params": [ [ "SqlInstance", "Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "ServerInstance,SqlServer,Source", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination Sql Server. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database to copy the table from.", "", false, "false", "" ], [ "DestinationDatabase", "The database to copy the table to. If not specified, it is assumed to be the same of Database", "", false, "false", "" ], [ "Table", "Define a specific table you would like to use as source. You can specify a three-part name like db.sch.tbl.\r\nIf the object has special characters please wrap them in square brackets [ ].\r\nThis dbo.First.Table will try to find table named \u0027Table\u0027 on schema \u0027First\u0027 and database \u0027dbo\u0027.\r\nThe correct way to find table named \u0027First.Table\u0027 on schema \u0027dbo\u0027 is passing dbo.[First.Table]", "", false, "false", "" ], [ "Query", "If you want to copy only a portion of a table or selected tables, specify the query.\r\nEnsure to select all required columns. Calculated Columns or columns with default values may be excluded.\r\nThe tablename should be a full three-part name in form [Database].[Schema].[Table]", "", false, "false", "" ], [ "AutoCreateTable", "Creates the destination table if it does not already exist, based off of the \"Export...\" script of the source table.", "", false, "false", "False" ], [ "BatchSize", "The BatchSize for the import defaults to 5000.", "", false, "false", "50000" ], [ "NotifyAfter", "Sets the option to show the notification after so many rows of import", "", false, "false", "5000" ], [ "DestinationTable", "The table you want to use as destination. If not specified, it is assumed to be the same of Table", "", false, "false", "" ], [ "NoTableLock", "If this switch is enabled, a table lock (TABLOCK) will not be placed on the destination table. By default, this operation will lock the destination table while running.", "", false, "false", "False" ], [ "CheckConstraints", "If this switch is enabled, the SqlBulkCopy option to process check constraints will be enabled.\nPer Microsoft \"Check constraints while data is being inserted. By default, constraints are not checked.\"", "", false, "false", "False" ], [ "FireTriggers", "If this switch is enabled, the SqlBulkCopy option to fire insert triggers will be enabled.\nPer Microsoft \"When specified, cause the server to fire the insert triggers for the rows being inserted into the Database.\"", "", false, "false", "False" ], [ "KeepIdentity", "If this switch is enabled, the SqlBulkCopy option to preserve source identity values will be enabled.\nPer Microsoft \"Preserve source identity values. When not specified, identity values are assigned by the destination.\"", "", false, "false", "False" ], [ "KeepNulls", "If this switch is enabled, the SqlBulkCopy option to preserve NULL values will be enabled.\nPer Microsoft \"Preserve null values in the destination table regardless of the settings for default values. When not specified, null values are replaced by default values where applicable.\"", "", false, "false", "False" ], [ "Truncate", "If this switch is enabled, the destination table will be truncated after prompting for confirmation.", "", false, "false", "False" ], [ "bulkCopyTimeOut", "Value in seconds for the BulkCopy operations timeout. The default is 30 seconds.", "", false, "false", "5000" ], [ "InputObject", "Enables piping of Table objects from Get-DbaDbTable", "", 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" ], [ "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": "Copy-DbaTableData", "Author": "Simone Bizzotto (@niphlod)", "Synopsis": "Copies data between SQL Server tables.", "Name": "Copy-DbaDbTableData", "Links": "https://dbatools.io/Copy-DbaDbTableData", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -Table dbo.test_table\nCopies all the data from table dbo.test_table in database dbatools_from on sql1 to table test_table in database dbatools_from on sql2.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -DestinationDatabase dbatools_dest -Table [Schema].[test table]\nCopies all the data from table [Schema].[test table] in database dbatools_from on sql1 to table [Schema].[test table] in database dbatools_dest on sql2\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql1 -Database tempdb -Table tb1, tb2 | Copy-DbaDbTableData -DestinationTable tb3\nCopies all data from tables tb1 and tb2 in tempdb on sql1 to tb3 in tempdb on sql1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql1 -Database tempdb -Table tb1, tb2 | Copy-DbaDbTableData -Destination sql2\nCopies data from tbl1 in tempdb on sql1 to tbl1 in tempdb on sql2\r\nthen\r\nCopies data from tbl2 in tempdb on sql1 to tbl2 in tempdb on sql2\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -Table test_table -KeepIdentity -Truncate\nCopies all the data in table test_table from sql1 to sql2, using the database dbatools_from, keeping identity columns and truncating the destination\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e SourceSqlInstance = \u0027sql1\u0027\r\n\u003e\u003e DestinationSqlInstance = \u0027sql2\u0027\r\n\u003e\u003e Database = \u0027dbatools_from\u0027\r\n\u003e\u003e DestinationDatabase = \u0027dbatools_dest\u0027\r\n\u003e\u003e Table = \u0027[Schema].[Table]\u0027\r\n\u003e\u003e DestinationTable = \u0027[dbo].[Table.Copy]\u0027\r\n\u003e\u003e KeepIdentity = $true\r\n\u003e\u003e KeepNulls = $true\r\n\u003e\u003e Truncate = $true\r\n\u003e\u003e BatchSize = 10000\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Copy-DbaDbTableData @params\nCopies all the data from table [Schema].[Table] in database dbatools_from on sql1 to table [dbo].[Table.Copy] in database dbatools_dest on sql2\r\nKeeps identity columns and Nulls, truncates the destination and processes in BatchSize of 10000.", "Syntax": "Copy-DbaDbTableData [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Destination] \u003cDbaInstanceParameter[]\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [[-DestinationDatabase] \u003cString\u003e] [[-Table] \u003cString[]\u003e] [[-Query] \u003cString\u003e] [-AutoCreateTable] [[-BatchSize] \u003cInt32\u003e] [[-NotifyAfter] \u003cInt32\u003e] [[-DestinationTable] \u003cString\u003e] [-NoTableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] [-Truncate] [[-bulkCopyTimeOut] \u003cInt32\u003e] [[-InputObject] \u003cTable[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaEndpoint", "Description": "By default, all endpoints are copied.\n\nIf the endpoint already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "Endpoint" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Endpoint", "The endpoint(s) to process. This list is auto-populated from the server. If unspecified, all endpoints will be processed.", "", false, "false", "" ], [ "ExcludeEndpoint", "The endpoint(s) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "Force", "If this switch is enabled, existing endpoints on Destination with matching names from Source will be dropped.", "", 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", "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": "Copy-SqlEndpoint", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaEndpoint migrates server endpoints from one SQL Server to another.", "Name": "Copy-DbaEndpoint", "Links": "https://dbatools.io/Copy-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaEndpoint -Source sqlserver2014a -Destination sqlcluster\nCopies all server endpoints from sqlserver2014a to sqlcluster, using Windows credentials. If endpoints with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaEndpoint -Source sqlserver2014a -SourceSqlCredential $cred -Destination sqlcluster -Endpoint tg_noDbDrop -Force\nCopies only the tg_noDbDrop endpoint from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If an endpoint with the same name exists on \r\nsqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaEndpoint -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaEndpoint [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Endpoint] \u003cObject[]\u003e] [[-ExcludeEndpoint] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaExtendedEvent", "Description": "Migrates SQL Extended Event Sessions except the two default sessions, AlwaysOn_health and system_health.\n\nBy default, all non-system Extended Events are migrated.", "Tags": [ "Migration", "ExtendedEvent", "XEvent" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "XeSession", "The Extended Event Session(s) to process. This list is auto-populated from the server. If unspecified, all Extended Event Sessions will be processed.", "", false, "false", "" ], [ "ExcludeXeSession", "The Extended Event Session(s) to exclude. This list is auto-populated from the server.", "", false, "false", "" ], [ "Force", "If this switch is enabled, existing Extended Events sessions on Destination with matching names from Source will be dropped.", "", 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", "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": "Copy-SqlExtendedEvent", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates SQL Extended Event Sessions except the two default sessions, AlwaysOn_health and system_health.", "Name": "Copy-DbaExtendedEvent", "Links": "https://dbatools.io/Copy-DbaExtendedEvent", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster\nCopies all Extended Event sessions from sqlserver2014a to sqlcluster using Windows credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nCopies all Extended Event sessions from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster -XeSession CheckQueries, MonitorUserDefinedException\nCopies only the Extended Events named CheckQueries and MonitorUserDefinedException from sqlserver2014a to sqlcluster.", "Syntax": "Copy-DbaExtendedEvent [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-XeSession] \u003cObject[]\u003e] [[-ExcludeXeSession] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaLinkedServer", "Description": "By using password decryption techniques provided by Antti Rantasaari (NetSPI, 2014), this script migrates SQL Server Linked Servers from one server to another, while maintaining username and password.\n\nCredit: https://blog.netspi.com/decrypting-mssql-database-link-server-passwords/", "Tags": [ "WSMan", "Migration", "LinkedServer" ], "Params": [ [ "Source", "Source SQL Server (2005 and above). You must have sysadmin access to both SQL Server and Windows.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server (2005 and above). You must have sysadmin access to both SQL Server and Windows.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "LinkedServer", "The linked server(s) to process - this list is auto-populated from the server. If unspecified, all linked servers will be processed.", "", false, "false", "" ], [ "ExcludeLinkedServer", "The linked server(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "UpgradeSqlClient", "Upgrade any SqlClient Linked Server to the current Version", "", false, "false", "False" ], [ "Force", "By default, if a Linked Server exists on the source and destination, the Linked Server is not copied over. Specifying -force will drop and recreate the Linked Server on the Destination server.", "", 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": "Copy-SqlLinkedServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaLinkedServer migrates Linked Servers from one SQL Server to another. Linked Server logins and passwords are migrated as well.", "Name": "Copy-DbaLinkedServer", "Links": "https://dbatools.io/Copy-DbaLinkedServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaLinkedServer -Source sqlserver2014a -Destination sqlcluster\nCopies all SQL Server Linked Servers on sqlserver2014a to sqlcluster. If Linked Server exists on destination, it will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaLinkedServer -Source sqlserver2014a -Destination sqlcluster -LinkedServer SQL2K5,SQL2k -Force\nCopies over two SQL Server Linked Servers (SQL2K and SQL2K2) from sqlserver to sqlcluster. If the credential already exists on the destination, it will be dropped.", "Syntax": "Copy-DbaLinkedServer [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-LinkedServer] \u003cObject[]\u003e] [[-ExcludeLinkedServer] \u003cObject[]\u003e] [-UpgradeSqlClient] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaLogin", "Description": "SQL Server 2000: Migrates logins with SIDs, passwords, server roles and database roles.\n\nSQL Server 2005 \u0026 newer: Migrates logins with SIDs, passwords, defaultdb, server roles \u0026 securables, database permissions \u0026 securables, login attributes (enforce password policy, expiration, etc.)\n\nThe login hash algorithm changed in SQL Server 2012, and is not backwards compatible with previous SQL Server versions. This means that while SQL Server 2000 logins can be migrated to SQL Server 2012, logins created in SQL Server 2012 can only be migrated to SQL Server 2012 and above.", "Tags": [ "Migration", "Login" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "ExcludeSystemLogin", "If this switch is enabled, NT SERVICE accounts will be skipped.", "", false, "false", "False" ], [ "SyncOnly", "If this switch is enabled, only SQL Server login permissions, roles, etc. will be synced. Logins and users will not be added or dropped. If a matching Login does not exist on the destination, the \r\nLogin will be skipped.\r\nCredential removal is not currently supported for this parameter.", "", false, "false", "False" ], [ "SyncSaName", "If this switch is enabled, the name of the sa account will be synced between Source and Destination", "", false, "false", "False" ], [ "OutFile", "Calls Export-DbaLogin and exports all logins to a T-SQL formatted file. This does not perform a copy, so no destination is required.", "", true, "false", "" ], [ "InputObject", "Takes the parameters required from a Login object that has been piped into the command", "", false, "true (ByValue)", "" ], [ "LoginRenameHashtable", "Pass a hash table into this parameter to be passed into Rename-DbaLogin to update the Login and mappings after the Login is completed.", "", false, "false", "" ], [ "KillActiveConnection", "If this switch and -Force are enabled, all active connections and sessions on Destination will be killed.\nA login cannot be dropped when it has active connections on the instance.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, the Login(s) will be dropped and recreated on Destination. Logins that own Agent jobs cannot be dropped at this time.", "", false, "false", "False" ], [ "ExcludePermissionSync", "Skips permission syncs", "", 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" ], [ "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": "Copy-SqlLogin", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates logins from source to destination SQL Servers. Supports SQL Server versions 2000 and newer.", "Name": "Copy-DbaLogin", "Links": "https://dbatools.io/Copy-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Force\nCopies all logins from Source Destination. If a SQL Login on Source exists on the Destination, the Login on Destination will be dropped and recreated.\nIf active connections are found for a login, the copy of that Login will fail as it cannot be dropped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Force -KillActiveConnection\nCopies all logins from Source Destination. If a SQL Login on Source exists on the Destination, the Login on Destination will be dropped and recreated.\nIf any active connections are found they will be killed.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -ExcludeLogin realcajun -SourceSqlCredential $scred -DestinationSqlCredential $dcred\nCopies all Logins from Source to Destination except for realcajun using SQL Authentication to connect to both instances.\nIf a Login already exists on the destination, it will not be migrated.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Login realcajun, netnerds -force\nCopies ONLY Logins netnerds and realcajun. If Login realcajun or netnerds exists on Destination, the existing Login(s) will be dropped and recreated.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -SyncOnly\nSyncs only SQL Server login permissions, roles, etc. Does not add or drop logins or users.\nIf a matching Login does not exist on Destination, the Login will be skipped.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eCopy-DbaLogin -LoginRenameHashtable @{ \"PreviousUser\" = \"newlogin\" } -Source $Sql01 -Destination Localhost -SourceSqlCredential $sqlcred\nCopies PreviousUser and then renames it to newlogin.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 | Out-GridView -Passthru | Copy-DbaLogin -Destination sql2017\nDisplays all available logins on sql2016 in a grid view, then copies all selected logins to sql2017.", "Syntax": "Copy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-ExcludePermissionSync] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nCopy-DbaLogin -Source \u003cDbaInstanceParameter\u003e [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-SyncSaName] [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-ExcludePermissionSync] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-SyncSaName] [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-ExcludePermissionSync] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] -OutFile \u003cString\u003e [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-ExcludePermissionSync] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-InputObject \u003cObject\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-ExcludePermissionSync] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaPolicyManagement", "Description": "By default, all policies and conditions are copied. If an object already exist on the destination, it will be skipped unless -Force is used.\n\nThe -Policy and -Condition parameters are auto-populated for command-line completion and can be used to copy only specific objects.", "Tags": "Migration", "Params": [ [ "Source", "Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination Sql Server. You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Policy", "The policy(ies) to process - this list is auto-populated from the server. If unspecified, all policies will be processed.", "", false, "false", "" ], [ "ExcludePolicy", "The policy(ies) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "Condition", "The condition(s) to process - this list is auto-populated from the server. If unspecified, all conditions will be processed.", "", false, "false", "" ], [ "ExcludeCondition", "The condition(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "Force", "If policies exists on destination server, it will be dropped and recreated.", "", 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": "Copy-DbaSqlPolicyManagement,Copy-SqlPolicyManagement", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates SQL Policy Based Management Objects, including both policies and conditions.", "Name": "Copy-DbaPolicyManagement", "Links": "https://dbatools.io/Copy-DbaPolicyManagement", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster\nCopies all policies and conditions from sqlserver2014a to sqlcluster, using Windows credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nCopies all policies and conditions from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -Policy \u0027xp_cmdshell must be disabled\u0027\nCopies only one policy, \u0027xp_cmdshell must be disabled\u0027 from sqlserver2014a to sqlcluster. No conditions are migrated.", "Syntax": "Copy-DbaPolicyManagement [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Policy] \u003cObject[]\u003e] [[-ExcludePolicy] \u003cObject[]\u003e] [[-Condition] \u003cObject[]\u003e] [[-ExcludeCondition] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaQueryStoreConfig", "Description": "Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.", "Tags": "QueryStore", "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2016 or higher.", "", true, "true (ByValue)", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "SourceDatabase", "Specifies the database to copy the Query Store configuration from.", "", true, "true (ByValue)", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2016 or higher.", "", true, "true (ByValue)", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationDatabase", "Specifies a list of databases that will receive a copy of the Query Store configuration of the SourceDatabase.", "", false, "false", "" ], [ "Exclude", "Specifies a list of databases which will NOT receive a copy of the Query Store configuration.", "", false, "false", "" ], [ "AllDatabases", "If this switch is enabled, the Query Store configuration will be copied to all databases on the destination instance.", "", 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", "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": "", "Author": "Enrico van de Laar (@evdlaar)", "Synopsis": "Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.", "Name": "Copy-DbaQueryStoreConfig", "Links": "https://dbatools.io/Copy-QueryStoreConfig", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaQueryStoreConfig -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL -AllDatabases\nCopy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it on all user databases in the ServerB\\SQL Instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaQueryStoreConfig -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL -DestinationDatabase WorldWideTraders\nCopy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it to the WorldWideTraders database in the ServerB\\SQL Instance.", "Syntax": "Copy-DbaQueryStoreConfig [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-SourceDatabase] \u003cObject\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-DestinationDatabase] \u003cObject[]\u003e] [[-Exclude] \u003cObject[]\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaResourceGovernor", "Description": "By default, all non-system resource pools are migrated. If the pool already exists on the destination, it will be skipped unless -Force is used.\n\nThe -ResourcePool parameter is auto-populated for command-line completion and can be used to copy only specific objects.", "Tags": [ "Migration", "ResourceGovernor" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2008 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "ResourcePool", "Specifies the resource pool(s) to process. Options for this list are auto-populated from the server. If unspecified, all resource pools will be processed.", "", false, "false", "" ], [ "ExcludeResourcePool", "Specifies the resource pool(s) to exclude. Options for this list are auto-populated from the server", "", false, "false", "" ], [ "Force", "If this switch is enabled, the policies will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlResourceGovernor", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates Resource Pools", "Name": "Copy-DbaResourceGovernor", "Links": "https://dbatools.io/Copy-DbaResourceGovernor", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaResourceGovernor -Source sqlserver2014a -Destination sqlcluster\nCopies all all non-system resource pools from sqlserver2014a to sqlcluster using Windows credentials to connect to the SQL Server instances..\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaResourceGovernor -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nCopies all all non-system resource pools from sqlserver2014a to sqlcluster using SQL credentials to connect to sqlserver2014a and Windows credentials to connect to sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaResourceGovernor -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.", "Syntax": "Copy-DbaResourceGovernor [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ResourcePool] \u003cObject[]\u003e] [[-ExcludeResourcePool] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaServerAudit", "Description": "By default, all audits are copied. The -Audit parameter is auto-populated for command-line completion and can be used to copy only specific audits.\n\nIf the audit already exists on the destination, it will be skipped unless -Force is used.", "Tags": "Migration", "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Audit", "The audit(s) to process. Options for this list are auto-populated from the server. If unspecified, all audits will be processed.", "", false, "false", "" ], [ "ExcludeAudit", "The audit(s) to exclude. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Force", "If this switch is enabled, the audits will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlAudit", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaServerAudit migrates server audits from one SQL Server to another.", "Name": "Copy-DbaServerAudit", "Links": "https://dbatools.io/Copy-DbaServerAudit", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaServerAudit -Source sqlserver2014a -Destination sqlcluster\nCopies all server audits from sqlserver2014a to sqlcluster, using Windows credentials. If audits with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaServerAudit -Source sqlserver2014a -Destination sqlcluster -Audit tg_noDbDrop -SourceSqlCredential $cred -Force\nCopies a single audit, the tg_noDbDrop audit from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If an audit with the same name exists \r\non sqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaServerAudit -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaServerAudit [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Audit] \u003cObject[]\u003e] [[-ExcludeAudit] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaServerAuditSpecification", "Description": "By default, all audits are copied. The -AuditSpecification parameter is auto-populated for command-line completion and can be used to copy only specific audits.\n\nIf the audit specification already exists on the destination, it will be skipped unless -Force is used.", "Tags": [ "Migration", "ServerAudit", "AuditSpecification" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AuditSpecification", "The Server Audit Specification(s) to process. Options for this list are auto-populated from the server. If unspecified, all Server Audit Specifications will be processed.", "", false, "false", "" ], [ "ExcludeAuditSpecification", "The Server Audit Specification(s) to exclude. Options for this list are auto-populated from the server", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Audits Specifications will be dropped and recreated on Destination.", "", 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", "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": "Copy-SqlAuditSpecification", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaServerAuditSpecification migrates server audit specifications from one SQL Server to another.", "Name": "Copy-DbaServerAuditSpecification", "Links": "https://dbatools.io/Copy-DbaServerAuditSpecification", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster\nCopies all server audits from sqlserver2014a to sqlcluster using Windows credentials to connect. If audits with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster -AuditSpecification tg_noDbDrop -SourceSqlCredential $cred -Force\nCopies a single audit, the tg_noDbDrop audit from sqlserver2014a to sqlcluster using SQL credentials to connect to sqlserver2014a and Windows credentials to connect to sqlcluster. If an audit \r\nspecification with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaServerAuditSpecification [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-AuditSpecification] \u003cObject[]\u003e] [[-ExcludeAuditSpecification] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaServerTrigger", "Description": "By default, all triggers are copied. The -ServerTrigger parameter is auto-populated for command-line completion and can be used to copy only specific triggers.\n\nIf the trigger already exists on the destination, it will be skipped unless -Force is used.", "Tags": "Migration", "Params": [ [ "Source", "Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination Sql Server. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "ServerTrigger", "The Server Trigger(s) to process - this list is auto-populated from the server. If unspecified, all Server Triggers will be processed.", "", false, "false", "" ], [ "ExcludeServerTrigger", "The Server Trigger(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "Force", "Drops and recreates the Trigger if it exists", "", 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": "Copy-SqlServerTrigger", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaServerTrigger migrates server triggers from one SQL Server to another.", "Name": "Copy-DbaServerTrigger", "Links": "https://dbatools.io/Copy-DbaServerTrigger", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaServerTrigger -Source sqlserver2014a -Destination sqlcluster\nCopies all server triggers from sqlserver2014a to sqlcluster, using Windows credentials. If triggers with the same name exist on sqlcluster, they will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaServerTrigger -Source sqlserver2014a -Destination sqlcluster -ServerTrigger tg_noDbDrop -SourceSqlCredential $cred -Force\nCopies a single trigger, the tg_noDbDrop trigger from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a trigger with the same name \r\nexists on sqlcluster, it will be dropped and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaServerTrigger -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.", "Syntax": "Copy-DbaServerTrigger [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ServerTrigger] \u003cObject[]\u003e] [[-ExcludeServerTrigger] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaSpConfigure", "Description": "By default, all configuration values are copied. The -ConfigName parameter is auto-populated for command-line completion and can be used to copy only specific configs.", "Tags": [ "Migration", "Configure", "SpConfigure" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "ConfigName", "Specifies the configuration setting to process. Options for this list are auto-populated from the server. If unspecified, all ConfigNames will be processed.", "", false, "false", "" ], [ "ExcludeConfigName", "Specifies the configuration settings to exclude. Options for this list are auto-populated from the server.", "", 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", "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": "Copy-SqlSpConfigure", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copy-DbaSpConfigure migrates configuration values from one SQL Server to another.", "Name": "Copy-DbaSpConfigure", "Links": "https://dbatools.io/Copy-DbaSpConfigure", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster\nCopies all sp_configure settings from sqlserver2014a to sqlcluster\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster -ConfigName DefaultBackupCompression, IsSqlClrEnabled -SourceSqlCredential $cred\nCopies the values for IsSqlClrEnabled and DefaultBackupCompression from sqlserver2014a to sqlcluster using SQL credentials to authenticate to sqlserver2014a and Windows credentials to authenticate to \r\nsqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster -ExcludeConfigName DefaultBackupCompression, IsSqlClrEnabled\nCopies all configs except for IsSqlClrEnabled and DefaultBackupCompression, from sqlserver2014a to sqlcluster.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster -WhatIf\nShows what would happen if the command were executed.", "Syntax": "Copy-DbaSpConfigure [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ConfigName] \u003cObject[]\u003e] [[-ExcludeConfigName] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaSsisCatalog", "Description": "By default, all folders, projects, and environments are copied. The -Project parameter can be specified to copy only one project, if desired.\n\nThe parameters get more granular from the Folder level. For example, specifying -Folder will only deploy projects/environments from within that folder.", "Tags": [ "Migration", "SSIS" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2012 or higher.", "", true, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2012 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Project", "Specifies a source Project name.", "", false, "false", "" ], [ "Folder", "Specifies a source folder name.", "", false, "false", "" ], [ "Environment", "Specifies an environment to copy.", "", false, "false", "" ], [ "CreateCatalogPassword", "Specifies a secure string to use in creating an SSISDB catalog on Destination. If this is specified, prompts for the password will be skipped.", "", false, "false", "" ], [ "EnableSqlClr", "If this switch is enabled and Destination does not have the SQL CLR configuration option enabled, user prompts for enabling it on Destination will be skipped. SQL CLR is required for SSISDB.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, the SSIS Catalog will be dropped and recreated on Destination if it already exists.", "", 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", "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": "Copy-SqlSsisCatalog", "Author": "Phil Schwartz (philschwartz.me, @pschwartzzz)", "Synopsis": "Copy-DbaSsisCatalog migrates Folders, SSIS projects, and environments from one SQL Server to another.", "Name": "Copy-DbaSsisCatalog", "Links": "https://dbatools.io/Copy-DbaSsisCatalog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster\nCopies all folders, environments and SSIS Projects from sqlserver2014a to sqlcluster, using Windows credentials to authenticate to both instances. If folders with the same name exist on the \r\ndestination they will be skipped, but projects will be redeployed.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster -Project Archive_Tables -SourceSqlCredential $cred -Force\nCopies a single Project, the Archive_Tables Project, from sqlserver2014a to sqlcluster using SQL credentials to authenticate to sqlserver2014a and Windows credentials to authenticate to sqlcluster. \r\nIf a Project with the same name exists on sqlcluster, it will be deleted and recreated because -Force was used.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\nShows what would happen if the command were executed using force.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$SecurePW = Read-Host \"Enter password\" -AsSecureString\nPS C:\\\u003e Copy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster -CreateCatalogPassword $SecurePW\nDeploy entire SSIS catalog to an instance without a destination catalog. User prompts for creating the catalog on Destination will be bypassed.", "Syntax": "Copy-DbaSsisCatalog [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Project] \u003cString\u003e] [[-Folder] \u003cString\u003e] [[-Environment] \u003cString\u003e] [[-CreateCatalogPassword] \u003cSecureString\u003e] [-EnableSqlClr] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaSysDbUserObject", "Description": "Imports all user objects found in source SQL Server\u0027s master, msdb and model databases to the destination. This is useful because many DBAs store backup/maintenance procs/tables/triggers/etc (among other things) in master or msdb.\n\nIt is also useful for migrating objects within the model database.", "Tags": [ "Migration", "SystemDatabase", "UserObject" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Force", "Drop destination objects first. Has no effect if you use Classic. This doesn\u0027t work really well, honestly.", "", false, "false", "False" ], [ "Classic", "Perform the migration the old way", "", 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", "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": "Copy-SqlSysDbUserObjects", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Imports all user objects found in source SQL Server\u0027s master, msdb and model databases to the destination.", "Name": "Copy-DbaSysDbUserObject", "Links": "https://dbatools.io/Copy-DbaSysDbUserObject", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaSysDbUserObject -Source $sourceServer -Destination $destserver\nCopies user objects from source to destination", "Syntax": "Copy-DbaSysDbUserObject [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-Force] [-Classic] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Copy-DbaXESessionTemplate", "Description": "Copies non-Microsoft templates from the dbatools template repository (\\bin\\xetemplates\\) to $home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates.\n\nUseful for when you want to use the SSMS GUI.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "Path", "The path to the template directory. Defaults to the dbatools template repository (\\bin\\xetemplates\\).", "", false, "false", "\"$script:PSModuleRoot\\bin\\xetemplates\"" ], [ "Destination", "Path to the Destination directory, defaults to $home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates.", "", false, "false", "\"$home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates\"" ], [ "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": "Copies non-Microsoft templates from the dbatools template repository (\\bin\\xetemplates\\) to $home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates.", "Name": "Copy-DbaXESessionTemplate", "Links": "https://dbatools.io/Copy-DbaXESessionTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eCopy-DbaXESessionTemplate\nCopies non-Microsoft templates from the dbatools template repository (\\bin\\xetemplates\\) to $home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eCopy-DbaXESessionTemplate -Path C:\\temp\\xetemplates\nCopies your templates from C:\\temp\\xetemplates to $home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates.", "Syntax": "Copy-DbaXESessionTemplate [[-Path] \u003cString[]\u003e] [[-Destination] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Disable-DbaAgHadr", "Description": "In order to build an AG a cluster has to be built and then the Hadr enabled for the SQL Server\nservice. This function disables that feature for the SQL Server service.", "Tags": [ "Hadr", "AG", "AvailabilityGroup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "Credential", "Credential object used to connect to the Windows server as a different user", "", false, "false", "" ], [ "Force", "Will restart SQL Server and SQL Server Agent service to apply the change.", "", 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" ], [ "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": "Shawn Melton (@wsmelton), http://wsmelton.github.io", "Synopsis": "Disables the Hadr service setting on the specified SQL Server.", "Name": "Disable-DbaAgHadr", "Links": "https://dbatools.io/Disable-DbaAgHadr", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eDisable-DbaAgHadr -SqlInstance sql2016\nSets Hadr service to disabled for the instance sql2016 but changes will not be applied until the next time the server restarts.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eDisable-DbaAgHadr -SqlInstance sql2016 -Force\nSets Hadr service to disabled for the instance sql2016, and restart the service to apply the change.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eDisable-DbaAgHadr -SqlInstance sql2012\\dev1 -Force\nSets Hadr service to disabled for the instance dev1 on sq2012, and restart the service to apply the change.", "Syntax": "Disable-DbaAgHadr [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Disable-DbaFilestream", "Description": "Connects to the specified SQL Server instances, and sets the status of the FileStream feature to the required value\n\nTo perform the action, the SQL Server instance must be restarted. By default we will prompt for confirmation for this action, this can be overridden with the -Force switch", "Tags": "Filestream", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "", true, "true (ByPropertyName)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "true (ByPropertyName)", "" ], [ "Credential", "Login to the target server using alternative credentials.", "", false, "true (ByPropertyName)", "" ], [ "Force", "Restart SQL Instance after changes. Use this parameter with care as it overrides whatif.", "", 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" ], [ "WhatIf", "Shows what would happen if the command runs. The command is not run unless Force is specified.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the command.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Stuart Moore ( @napalmgram ) | Chrissy LeMaire ( @cl )", "Synopsis": "Sets the status of FileStream on specified SQL Server instances both at the server level and the instance level", "Name": "Disable-DbaFilestream", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eDisable-DbaFilestream -SqlInstance server1\\instance2\nPrompts for confirmation. Disables filestream on the service and instance levels.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eDisable-DbaFilestream -SqlInstance server1\\instance2 -Confirm:$false\nDoes not prompt for confirmation. Disables filestream on the service and instance levels.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaFilestream -SqlInstance server1\\instance2, server5\\instance5, prod\\hr | Where-Object InstanceAccessLevel -gt 0 | Disable-DbaFilestream -Force\nUsing this pipeline you can scan a range of SQL instances and disable filestream on only those on which it\u0027s enabled.", "Syntax": "Disable-DbaFilestream [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Disable-DbaForceNetworkEncryption", "Description": "Disables Force Encryption for a SQL Server instance. Note that this requires access to the Windows Server, not the SQL instance itself.\n\nThis setting is found in Configuration Manager.", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "ServerInstance,SqlServer,ComputerName", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the computer (not SQL Server instance) using alternative Windows credentials.", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Disables Force Encryption for a SQL Server instance", "Name": "Disable-DbaForceNetworkEncryption", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eDisable-DbaForceNetworkEncryption\nDisables Force Encryption on the default (MSSQLSERVER) instance on localhost - requires (and checks for) RunAs admin.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eDisable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2\nDisables Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both login and modify the registry.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eDisable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2 -WhatIf\nShows what would happen if the command were executed.", "Syntax": "Disable-DbaForceNetworkEncryption [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Disable-DbaTraceFlag", "Description": "The function will disable a Trace Flag that is currently running globally on the SQL Server instance(s) listed", "Tags": "TraceFlag", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "TraceFlag", "Trace flag number to enable globally", "", 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.", "Silent", false, "false", "False" ] ], "Alias": "", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Disable a Global Trace Flag that is currently running", "Name": "Disable-DbaTraceFlag", "Links": "https://dbatools.io/Disable-DbaTraceFlag", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eDisable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 3226\nDisable the globally running trace flag 3226 on SQL Server instance sql2016", "Syntax": "Disable-DbaTraceFlag [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -TraceFlag \u003cInt32[]\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Dismount-DbaDatabase", "Description": "This command detaches one or more SQL Server databases. If necessary, -Force can be used to break mirrors and remove databases from availability groups prior to detaching.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database(s) to detach.", "", true, "false", "" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase), to be detached.", "", true, "true (ByValue)", "" ], [ "UpdateStatistics", "If this switch is enabled, statistics for the database will be updated prior to detaching it.", "", false, "false", "False" ], [ "Force", "If this switch is enabled and the database is part of a mirror, the mirror will be broken. If the database is part of an Availability Group, it will be removed from the AG.", "", 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", "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": "Detach-DbaDatabase", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Detach a SQL Server Database.", "Name": "Dismount-DbaDatabase", "Links": "https://dbatools.io/Dismount-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eDetach-DbaDatabase -SqlInstance sql2016b -Database SharePoint_Config, WSS_Logging\nDetaches SharePoint_Config and WSS_Logging from sql2016b\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016b -Database \u0027PerformancePoint Service Application_10032db0fa0041df8f913f558a5dc0d4\u0027 | Detach-DbaDatabase -Force\nDetaches \u0027PerformancePoint Service Application_10032db0fa0041df8f913f558a5dc0d4\u0027 from sql2016b. Since Force was specified, if the database is part of mirror, the mirror will be broken prior to \r\ndetaching.\nIf the database is part of an Availability Group, it will first be dropped prior to detachment.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016b -Database WSS_Logging | Detach-DbaDatabase -Force -WhatIf\nShows what would happen if the command were to execute (without actually executing the detach/break/remove commands).", "Syntax": "Dismount-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-UpdateStatistics] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nDismount-DbaDatabase -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cString[]\u003e [-UpdateStatistics] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nDismount-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cDatabase[]\u003e [-UpdateStatistics] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Enable-DbaAgHadr", "Description": "In order to build an AG a cluster has to be built and then the Hadr enabled for the SQL Server\nservice. This function enables that feature for the SQL Server service.", "Tags": [ "Hadr", "HA", "AG", "AvailabilityGroup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "Credential", "Credential object used to connect to the Windows server as a different user", "", false, "false", "" ], [ "Force", "Will restart SQL Server and SQL Server Agent service to apply the change.", "", 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" ], [ "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": "Shawn Melton (@wsmelton), http://wsmelton.github.io", "Synopsis": "Enables the Hadr service setting on the specified SQL Server.", "Name": "Enable-DbaAgHadr", "Links": "https://dbatools.io/Enable-DbaAgHadr", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eEnable-DbaAgHadr -SqlInstance sql2016\nSets Hadr service to enabled for the instance sql2016 but changes will not be applied until the next time the server restarts.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eEnable-DbaAgHadr -SqlInstance sql2016 -Force\nSets Hadr service to enabled for the instance sql2016, and restart the service to apply the change.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eEnable-DbaAgHadr -SqlInstance sql2012\\dev1 -Force\nSets Hadr service to disabled for the instance dev1 on sq2012, and restart the service to apply the change.", "Syntax": "Enable-DbaAgHadr [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Enable-DbaFilestream", "Description": "Connects to the specified SQL Server instances, and Enables the FileStream feature to the required value\n\nTo perform the action, the SQL Server instance must be restarted. By default we will prompt for confirmation for this action, this can be overridden with the -Force switch", "Tags": "Filestream", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "", true, "true (ByPropertyName)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "true (ByPropertyName)", "" ], [ "Credential", "Login to the target server using alternative credentials.", "", false, "true (ByPropertyName)", "" ], [ "FileStreamLevel", "The level to of FileStream to be enabled:\r\n1 or TSql - T-Sql Access Only\r\n2 or TSqlIoStreaming - T-Sql and Win32 access enabled\r\n3 or TSqlIoStreamingRemoteClient T-Sql, Win32 and Remote access enabled", "", false, "false", "1" ], [ "ShareName", "Specifies the Windows file share name to be used for storing the FILESTREAM data.", "", false, "false", "" ], [ "Force", "Restart SQL Instance after changes. Use this parameter with care as it overrides whatif.", "", 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" ], [ "WhatIf", "Shows what would happen if the command runs. The command is not run unless Force is specified.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the command.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Stuart Moore ( @napalmgram ) | Chrissy LeMaire ( @cl )", "Synopsis": "Enables FileStream on specified SQL Server instances", "Name": "Enable-DbaFilestream", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eEnable-DbaFilestream -SqlInstance server1\\instance2 -FileStreamLevel TSql\nPS C:\\\u003e Enable-DbaFilestream -SqlInstance server1\\instance2 -FileStreamLevel 1\nThese commands are functionally equivalent, both will set Filestream level on server1\\instance2 to T-Sql Only\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaFilestream -SqlInstance server1\\instance2, server5\\instance5, prod\\hr | Where-Object InstanceAccessLevel -eq 0 | Enable-DbaFilestream -FileStreamLevel TSqlIoStreamingRemoteClient -Force\nUsing this pipeline you can scan a range of SQL instances and enable filestream on only those on which it\u0027s disabled.", "Syntax": "Enable-DbaFilestream [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-FileStreamLevel] \u003cString\u003e] [[-ShareName] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Enable-DbaForceNetworkEncryption", "Description": "Enables Force Encryption for a SQL Server instance. Note that this requires access to the Windows Server, not the SQL instance itself.\n\nThis setting is found in Configuration Manager.", "Tags": [ "Certificate", "Encryption" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,ComputerName", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the computer (not SQL Server instance) using alternative Windows credentials", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Enables Force Encryption for a SQL Server instance.", "Name": "Enable-DbaForceNetworkEncryption", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eEnable-DbaForceNetworkEncryption\nEnables Force Encryption on the default (MSSQLSERVER) instance on localhost. Requires (and checks for) RunAs admin.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eEnable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2\nEnables Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both connect and modify the registry.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eEnable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2 -WhatIf\nShows what would happen if the command were executed.", "Syntax": "Enable-DbaForceNetworkEncryption [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Enable-DbaTraceFlag", "Description": "The function will set one or multiple trace flags on the SQL Server instance(s) listed", "Tags": "TraceFlag", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "TraceFlag", "Trace flag number(s) to enable globally", "", 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.", "Silent", false, "false", "False" ] ], "Alias": "", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Enable Global Trace Flag(s)", "Name": "Enable-DbaTraceFlag", "Links": "https://dbatools.io/Enable-DbaTraceFlag", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eEnable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 3226\nEnable the trace flag 3226 on SQL Server instance sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eEnable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 1117, 1118\nEnable multiple trace flags on SQL Server instance sql2016", "Syntax": "Enable-DbaTraceFlag [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -TraceFlag \u003cInt32[]\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Expand-DbaDbLogFile", "Description": "As you may already know, having a transaction log file with too many Virtual Log Files (VLFs) can hurt your database performance in many ways.\n\nExample:\nToo many VLFs can cause transaction log backups to slow down and can also slow down database recovery and, in extreme cases, even impact insert/update/delete performance.\n\nReferences:\nhttp://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\nhttp://blogs.msdn.com/b/saponsqlserver/archive/2012/02/22/too-many-virtual-log-files-vlfs-can-cause-slow-database-recovery.aspx\nhttp://www.brentozar.com/blitz/high-virtual-log-file-vlf-count/\n\nIn order to get rid of this fragmentation we need to grow the file taking the following into consideration:\n- How many VLFs are created when we perform a grow operation or when an auto-grow is invoked?\n\nNote: In SQL Server 2014 this algorithm has changed (http://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/)\n\nAttention:\nWe are growing in MB instead of GB because of known issue prior to SQL 2012:\nMore detail here:\nhttp://www.sqlskills.com/BLOGS/PAUL/post/Bug-log-file-growth-broken-for-multiples-of-4GB.aspx\nand\nhttp://connect.microsoft.com/SqlInstance/feedback/details/481594/log-growth-not-working-properly-with-specific-growth-sizes-vlfs-also-not-created-appropriately\nor\nhttps://connect.microsoft.com/SqlInstance/feedback/details/357502/transaction-log-file-size-will-not-grow-exactly-4gb-when-filegrowth-4gb\n\nUnderstanding related problems:\nhttp://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\nhttp://blogs.msdn.com/b/saponsqlserver/archive/2012/02/22/too-many-virtual-log-files-vlfs-can-cause-slow-database-recovery.aspx\nhttp://www.brentozar.com/blitz/high-virtual-log-file-vlf-count/\n\nKnown bug before SQL Server 2012\nhttp://www.sqlskills.com/BLOGS/PAUL/post/Bug-log-file-growth-broken-for-multiples-of-4GB.aspx\nhttp://connect.microsoft.com/SqlInstance/feedback/details/481594/log-growth-not-working-properly-with-specific-growth-sizes-vlfs-also-not-created-appropriately\nhttps://connect.microsoft.com/SqlInstance/feedback/details/357502/transaction-log-file-size-will-not-grow-exactly-4gb-when-filegrowth-4gb\n\nHow it works?\nThe transaction log will grow in chunks until it reaches the desired size.\nExample: If you have a log file with 8192MB and you say that the target size is 81920MB (80GB) it will grow in chunks of 8192MB until it reaches 81920MB. 8192 -\u003e 16384 -\u003e 24576 ... 73728 -\u003e 81920", "Tags": [ "Storage", "Backup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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", "" ], [ "ExcludeDatabase", "The database(s) to exclude. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "TargetLogSize", "Specifies the target size of the transaction log file in megabytes.", "TargetLogSizeMB", true, "false", "0" ], [ "IncrementSize", "Specifies the amount the transaction log should grow in megabytes. If this value differs from the suggested value based on your TargetLogSize, you will be prompted to confirm your choice.\nThis value will be calculated if not specified.", "IncrementSizeMB", false, "false", "-1" ], [ "LogFileId", "Specifies the file number(s) of additional transaction log files to grow.\nIf this value is not specified, only the first transaction log file will be processed.", "", false, "false", "-1" ], [ "ShrinkLogFile", "If this switch is enabled, your transaction log files will be shrunk.", "", true, "false", "False" ], [ "ShrinkSize", "Specifies the target size of the transaction log file for the shrink operation in megabytes.", "ShrinkSizeMB", true, "false", "0" ], [ "BackupDirectory", "Specifies the location of your backups. Backups must be performed to shrink the transaction log.\nIf this value is not specified, the SQL Server instance\u0027s default backup directory will be used.", "", false, "false", "" ], [ "ExcludeDiskSpaceValidation", "If this switch is enabled, the validation for enough disk space using Get-DbaDiskSpace command will be skipped.\r\nThis can be useful when you know that you have enough space to grow your TLog but you don\u0027t have PowerShell Remoting enabled to validate it.", "", 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", "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": "Expand-DbaTLogResponsibly,Expand-SqlTLogResponsibly", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "This command will help you to automatically grow your transaction log file in a responsible way (preventing the generation of too many VLFs).", "Name": "Expand-DbaDbLogFile", "Links": "https://dbatools.io/Expand-DbaDbLogFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eExpand-DbaDbLogFile -SqlInstance sqlcluster -Database db1 -TargetLogSize 50000\nGrows the transaction log for database db1 on sqlcluster to 50000 MB and calculates the increment size.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eExpand-DbaDbLogFile -SqlInstance sqlcluster -Database db1, db2 -TargetLogSize 10000 -IncrementSize 200\nGrows the transaction logs for databases db1 and db2 on sqlcluster to 1000MB and sets the growth increment to 200MB.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eExpand-DbaDbLogFile -SqlInstance sqlcluster -Database db1 -TargetLogSize 10000 -LogFileId 9\nGrows the transaction log file with FileId 9 of the db1 database on sqlcluster instance to 10000MB.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eExpand-DbaDbLogFile -SqlInstance sqlcluster -Database (Get-Content D:\\DBs.txt) -TargetLogSize 50000\nGrows the transaction log of the databases specified in the file \u0027D:\\DBs.txt\u0027 on sqlcluster instance to 50000MB.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eExpand-DbaDbLogFile -SqlInstance SqlInstance -Database db1,db2 -TargetLogSize 100 -IncrementSize 10 -ShrinkLogFile -ShrinkSize 10 -BackupDirectory R:\\MSSQL\\Backup\nGrows the transaction logs for databases db1 and db2 on SQL server SQLInstance to 100MB, sets the incremental growth to 10MB, shrinks the transaction log to 10MB and uses the directory \r\nR:\\MSSQL\\Backup for the required backups.", "Syntax": "Expand-DbaDbLogFile [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-TargetLogSize] \u003cInt32\u003e [[-IncrementSize] \u003cInt32\u003e] [[-LogFileId] \u003cInt32\u003e] [-ExcludeDiskSpaceValidation] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nExpand-DbaDbLogFile [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-TargetLogSize] \u003cInt32\u003e [[-IncrementSize] \u003cInt32\u003e] [[-LogFileId] \u003cInt32\u003e] [-ShrinkLogFile] [-ShrinkSize] \u003cInt32\u003e [[-BackupDirectory] \u003cString\u003e] [-ExcludeDiskSpaceValidation] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "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 -AvailabilityGroup 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:\\\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 3 --------------------------\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\"" ], [ "DacOption", "Export options for a corresponding export type. Can be created by New-DbaDacOption -Type Dacpac | Bacpac", "ExtractOptions,ExportOptions,DacExtractOptions,DacExportOptions,Options,Option", false, "false", "" ], [ "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", "" ], [ "Type", "Selecting the type of the export: Dacpac (default) or Bacpac.", "", false, "false", "Dacpac" ], [ "Table", "List of the tables to include into the export. Should be provided as an array of strings: dbo.Table1, Table2, Schema1.Table3.", "", 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$options = New-DbaDacOption -Type Dacpac -Action Export\nPS C:\\\u003e $options.ExtractAllTableData = $true\r\nPS C:\\\u003e $options.CommandTimeout = 0\r\nPS C:\\\u003e Export-DbaDacPackage -SqlInstance sql2016 -Database DB1 -Options $options\nUses DacOption object to set the CommandTimeout to 0 then extracts the dacpac for DB1 on sql2016 to $home\\Documents\\DB1.dacpac including all table data.\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. Uses command line instead of SMO behind the scenes.", "Syntax": "Export-DbaDacPackage -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllUserDatabases] [-Path \u003cString\u003e] [-DacOption \u003cObject\u003e] [-Type \u003cString\u003e] [-Table \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nExport-DbaDacPackage -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllUserDatabases] [-Path \u003cString\u003e] [-ExtendedParameters \u003cString\u003e] [-ExtendedProperties \u003cString\u003e] [-Type \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 database restore scripts.\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* database restore scripts, 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 -ExcludeLogin 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 sqlserver2008 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 sqlserver2014a 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 sqlserver2008 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]" }, { "CommandName": "Find-DbaAgentJob", "Description": "This command filters SQL Agent jobs giving the DBA a list of jobs that may need attention or could possibly be options for removal.", "Tags": [ "Agent", "Job" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "", false, "false", "" ], [ "JobName", "Filter agent jobs to only the name(s) you list.\r\nSupports regular expression (e.g. MyJob*) being passed in.", "Name", false, "false", "" ], [ "ExcludeJobName", "Allows you to enter an array of agent job names to ignore", "", false, "false", "" ], [ "StepName", "Filter based on StepName.\r\nSupports regular expression (e.g. MyJob*) being passed in.", "", false, "false", "" ], [ "LastUsed", "Find all jobs that havent ran in the INT number of previous day(s)", "", false, "false", "0" ], [ "IsDisabled", "Find all jobs that are disabled", "Disabled", false, "false", "False" ], [ "IsFailed", "Find all jobs that have failed", "Failed", false, "false", "False" ], [ "IsNotScheduled", "Find all jobs with no schedule assigned", "NoSchedule", false, "false", "False" ], [ "IsNoEmailNotification", "Find all jobs without email notification configured", "NoEmailNotification", false, "false", "False" ], [ "Category", "Filter based on agent job categories", "", false, "false", "" ], [ "Owner", "Filter based on owner of the job/s", "", false, "false", "" ], [ "Since", "Datetime object used to narrow the results to a date", "", 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": "Stephen Bennett (https://sqlnotesfromtheunderground.wordpress.com/)", "Synopsis": "Find-DbaAgentJob finds agent job/s that fit certain search filters.", "Name": "Find-DbaAgentJob", "Links": "https://dbatools.io/Find-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -JobName *backup*\nReturns all agent job(s) that have backup in the name\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01, Dev02 -JobName Mybackup\nReturns all agent job(s) that are named exactly Mybackup\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -LastUsed 10\nReturns all agent job(s) that have not ran in 10 days\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -IsDisabled -IsNoEmailNotification -IsNotScheduled\nReturns all agent job(s) that are either disabled, have no email notification or don\u0027t have a schedule. returned with detail\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers | Find-DbaAgentJob -IsFailed | Start-DbaAgentJob\nFinds all failed job then starts them. Consider using a -WhatIf at the end of Start-DbaAgentJob to see what it\u0027ll do first\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -LastUsed 10 -Exclude \"Yearly - RollUp Workload\", \"SMS - Notification\"\nReturns all agent jobs that have not ran in the last 10 days ignoring jobs \"Yearly - RollUp Workload\" and \"SMS - Notification\"\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -Category \"REPL-Distribution\", \"REPL-Snapshot\" | Format-Table -AutoSize -Wrap\nReturns all job/s on Dev01 that are in either category \"REPL-Distribution\" or \"REPL-Snapshot\"\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01, Dev02 -IsFailed -Since \u00272016-07-01 10:47:00\u0027\nReturns all agent job(s) on Dev01 and Dev02 that have failed since July of 2016 (and still have history in msdb)\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance CMSServer -Group Production | Find-DbaAgentJob -Disabled -IsNotScheduled | Format-Table -AutoSize -Wrap\nQueries CMS server to return all SQL instances in the Production folder and then list out all agent jobs that have either been disabled or have no schedule.", "Syntax": "Find-DbaAgentJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-JobName \u003cString[]\u003e] [-ExcludeJobName \u003cString[]\u003e] [-StepName \u003cString[]\u003e] [-LastUsed \u003cInt32\u003e] [-IsDisabled] [-IsFailed] [-IsNotScheduled] [-IsNoEmailNotification] [-Category \u003cString[]\u003e] [-Owner \u003cString\u003e] [-Since \u003cDateTime\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaBackup", "Description": "Provides all of the same functionality for finding SQL backups to remove from disk as a standard maintenance plan would.\n\nAs an addition you have the ability to check the Archive bit on files before deletion. This will allow you to ensure backups have been archived to your archive location before removal.", "Tags": "Backup", "Params": [ [ "Path", "Specifies the name of the base level folder to search for backup files.", "BackupFolder", true, "false", "" ], [ "BackupFileExtension", "Specifies the filename extension of the backup files you wish to find (typically \u0027bak\u0027, \u0027trn\u0027 or \u0027log\u0027). Do not include the period.", "", true, "false", "" ], [ "RetentionPeriod", "Specifies the retention period for backup files. Correct format is ##U.\n## is the retention value and must be an integer value\r\nU signifies the units where the valid units are:\r\nh = hours\r\nd = days\r\nw = weeks\r\nm = months\nFormatting Examples:\r\n\u002748h\u0027 = 48 hours\r\n\u00277d\u0027 = 7 days\r\n\u00274w\u0027 = 4 weeks\r\n\u00271m\u0027 = 1 month", "", true, "false", "" ], [ "CheckArchiveBit", "If this switch is enabled, the filesystem Archive bit is checked.\r\nIf this bit is set (which translates to \"it has not been backed up to another location yet\"), the file won\u0027t be included.", "", 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": "Chris Sommer (@cjsommer), www.cjsommer.com", "Synopsis": "Finds SQL Server backups on disk.", "Name": "Find-DbaBackup", "Links": "https://dbatools.io/Find-DbaBackup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaBackup -Path \u0027C:\\MSSQL\\SQL Backup\\\u0027 -BackupFileExtension trn -RetentionPeriod 48h\nSearches for all trn files in C:\\MSSQL\\SQL Backup\\ and all subdirectories that are more than 48 hours old will be included.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaBackup -Path \u0027C:\\MSSQL\\Backup\\\u0027 -BackupFileExtension bak -RetentionPeriod 7d -CheckArchiveBit\nSearches for all bak files in C:\\MSSQL\\Backup\\ and all subdirectories that are more than 7 days old will be included, but only if the files have been backed up to another location as verified by \r\nchecking the Archive bit.", "Syntax": "Find-DbaBackup [-Path] \u003cString\u003e [-BackupFileExtension] \u003cString\u003e [-RetentionPeriod] \u003cString\u003e [-CheckArchiveBit] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaCommand", "Description": "Finds dbatools commands searching through the inline help text, building a consolidated json index and querying it because Get-Help is too slow", "Tags": [ "Find", "Help", "Command" ], "Params": [ [ "Pattern", "Searches help for all commands in dbatools for the specified pattern and displays all results", "", false, "false", "" ], [ "Tag", "Finds all commands tagged with this auto-populated tag", "", false, "false", "" ], [ "Author", "Finds all commands tagged with this author", "", false, "false", "" ], [ "MinimumVersion", "Finds all commands tagged with this auto-populated minimum version", "", false, "false", "" ], [ "MaximumVersion", "Finds all commands tagged with this auto-populated maximum version", "", false, "false", "" ], [ "Rebuild", "Rebuilds the index", "", 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", "Displays what would happen if the command is run", "wi", false, "false", "" ], [ "Confirm", "Confirms overwrite of index", "cf", false, "false", "" ] ], "Alias": "", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Finds dbatools commands searching through the inline help text", "Name": "Find-DbaCommand", "Links": "https://dbatools.io/Find-DbaCommand", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaCommand \"snapshot\"\nFor lazy typers: finds all commands searching the entire help for \"snapshot\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaCommand -Pattern \"snapshot\"\nFor rigorous typers: finds all commands searching the entire help for \"snapshot\"\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaCommand -Tag copy\nFinds all commands tagged with \"copy\"\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaCommand -Tag copy,user\nFinds all commands tagged with BOTH \"copy\" and \"user\"\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eFind-DbaCommand -Author chrissy\nFinds every command whose author contains our beloved \"chrissy\"\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eFind-DbaCommand -Author chrissy -Tag copy\nFinds every command whose author contains our beloved \"chrissy\" and it tagged as \"copy\"\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eFind-DbaCommand -Pattern snapshot -Rebuild\nFinds all commands searching the entire help for \"snapshot\", rebuilding the index (good for developers)", "Syntax": "Find-DbaCommand [[-Pattern] \u003cString\u003e] [[-Tag] \u003cString[]\u003e] [[-Author] \u003cString\u003e] [[-MinimumVersion] \u003cString\u003e] [[-MaximumVersion] \u003cString\u003e] [-Rebuild] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaDatabase", "Description": "Allows you to search SQL Server instances for database that have either the same name, owner or service broker guid.\n\nThere a several reasons for the service broker guid not matching on a restored database primarily using alter database new broker. or turn off broker to return a guid of 0000-0000-0000-0000.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "Credential", false, "false", "" ], [ "Property", "What you would like to search on. Either Database Name, Owner, or Service Broker GUID. Database name is the default.", "", false, "false", "Name" ], [ "Pattern", "Value that is searched for. This is a regular expression match but you can just use a plain ol string like \u0027dbareports\u0027", "", true, "false", "" ], [ "Exact", "Search for an exact match instead of a pattern", "", false, "false", "False" ], [ "Detailed", "Output all properties, will be depreciated in 1.0.0 release.", "", 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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Find database/s on multiple servers that match criteria you input", "Name": "Find-DbaDatabase", "Links": "https://dbatools.io/Find-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaDatabase -SqlInstance \"DEV01\", \"DEV02\", \"UAT01\", \"UAT02\", \"PROD01\", \"PROD02\" -Pattern Report\nReturns all database from the SqlInstances that have a database with Report in the name\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaDatabase -SqlInstance \"DEV01\", \"DEV02\", \"UAT01\", \"UAT02\", \"PROD01\", \"PROD02\" -Pattern TestDB -Exact | Select-Object *\nReturns all database from the SqlInstances that have a database named TestDB with a detailed output.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaDatabase -SqlInstance \"DEV01\", \"DEV02\", \"UAT01\", \"UAT02\", \"PROD01\", \"PROD02\" -Property ServiceBrokerGuid -Pattern \u0027-faeb-495a-9898-f25a782835f5\u0027 | Select-Object *\nReturns all database from the SqlInstances that have the same Service Broker GUID with a detailed output", "Syntax": "Find-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Property] \u003cString\u003e] [-Pattern] \u003cString\u003e [-Exact] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaDbGrowthEvent", "Description": "Finds any database AutoGrow events in the Default Trace.\n\nThe following events are included:\n92 - Data File Auto Grow\n93 - Log File Auto Grow\n94 - Data File Auto Shrink\n95 - Log File Auto Shrink", "Tags": [ "AutoGrow", "Growth", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "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", "" ], [ "EventType", "Provide a filter on growth event type to filter the results.\nAllowed values: Growth, Shrink", "", false, "false", "" ], [ "FileType", "Provide a filter on file type to filter the results.\nAllowed values: Data, Log", "", false, "false", "" ], [ "UseLocalTime", "Return the local time of the instance instead of converting to UTC.", "", 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": "Find-DbaDatabaseGrowthEvent", "Author": "Aaron Nelson", "Synopsis": "Finds any database AutoGrow events in the Default Trace.", "Name": "Find-DbaDbGrowthEvent", "Links": "https://dbatools.io/Find-DbaDatabaseGrowthEvent", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance localhost\nReturns any database AutoGrow events in the Default Trace with UTC time for the instance for every database on the localhost instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance localhost -UseLocalTime\nReturns any database AutoGrow events in the Default Trace with the local time of the instance for every database on the localhost instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016, ServerA\\SQL2014\nReturns any database AutoGrow events in the Default Traces for every database on ServerA\\sql2016 \u0026 ServerA\\SQL2014.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016 | Format-Table -AutoSize -Wrap\nReturns any database AutoGrow events in the Default Trace for every database on the ServerA\\SQL2016 instance in a table format.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016 -EventType Shrink\nReturns any database Auto Shrink events in the Default Trace for every database on the ServerA\\SQL2016 instance.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016 -EventType Growth -FileType Data\nReturns any database Auto Growth events on data files in the Default Trace for every database on the ServerA\\SQL2016 instance.", "Syntax": "Find-DbaDbGrowthEvent [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-EventType] \u003cString\u003e] [[-FileType] \u003cString\u003e] [-UseLocalTime] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaDbUnusedIndex", "Description": "This command will help you to find Unused indexes on a database or a list of databases\n\nFor now only supported for CLUSTERED and NONCLUSTERED indexes", "Tags": "Index", "Params": [ [ "SqlInstance", "The SQL Server you want to check for unused indexes.", "", false, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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.", "", false, "false", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "IgnoreUptime", "Less than 7 days uptime can mean that analysis of unused indexes is unreliable, and normally no results will be returned. By setting this option results will be returned even if the Instance has been \r\nrunning for less that 7 days.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", 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": "Find-SqlUnusedIndex", "Author": "Aaron Nelson (@SQLvariant), SQLvariant.com", "Synopsis": "Find unused indexes", "Name": "Find-DbaDbUnusedIndex", "Links": "https://dbatools.io/Find-DbaDbUnusedIndex", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaDbUnusedIndex -SqlInstance sql2016 -Database db1, db2\nFinds unused databases on db1 and db2 on sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaDbUnusedIndex -SqlInstance sql2016 -SqlCredential $cred\nFinds unused databases on db1 and db2 on sql2016 using SQL Authentication to connect to the server\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 | Find-DbaDbUnusedIndex\nFinds unused databases on all databases on sql2016", "Syntax": "Find-DbaDbUnusedIndex [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IgnoreUptime] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaDisabledIndex", "Description": "This command will help you to find disabled indexes on a database or a list of databases.", "Tags": "Index", "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "NoClobber", "If this switch is enabled, the output file will not be overwritten.", "", false, "false", "False" ], [ "Append", "If this switch is enabled, content will be appended to the output 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", "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": "", "Author": "Jason Squires, sqlnotnull.com", "Synopsis": "Find Disabled indexes", "Name": "Find-DbaDisabledIndex", "Links": "https://dbatools.io/Find-DbadisabledIndex", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaDisabledIndex -SqlInstance sql2005\nGenerates the SQL statements to drop the selected disabled indexes on server \"sql2005\".\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaDisabledIndex -SqlInstance sqlserver2016 -SqlCredential $cred\nGenerates the SQL statements to drop the selected disabled indexes on server \"sqlserver2016\", using SQL Authentication to connect to the database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaDisabledIndex -SqlInstance sqlserver2016 -Database db1, db2\nGenerates the SQL Statement to drop selected indexes in databases db1 \u0026 db2 on server \"sqlserver2016\".\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaDisabledIndex -SqlInstance sqlserver2016\nGenerates the SQL statements to drop selected indexes on all user databases.", "Syntax": "Find-DbaDisabledIndex [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-NoClobber] [-Append] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaDuplicateIndex", "Description": "This command will help you to find duplicate and overlapping indexes on a database or a list of databases.\n\nOn SQL Server 2008 and higher, the IsFiltered property will also be checked\n\nOnly supports CLUSTERED and NONCLUSTERED indexes.\n\nOutput:\nTableName\nIndexName\nKeyColumns\nIncludedColumns\nIndexSizeMB\nIndexType\nCompressionDescription (When 2008+)\n[RowCount]\nIsDisabled\nIsFiltered (When 2008+)", "Tags": "Index", "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "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", "" ], [ "IncludeOverlapping", "If this switch is enabled, indexes which are partially duplicated will be returned.\nExample: If the first key column is the same between two indexes, but one has included columns and the other not, this will be shown.", "", 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": "Find-SqlDuplicateIndex", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Find duplicate and overlapping indexes.", "Name": "Find-DbaDuplicateIndex", "Links": "https://dbatools.io/Find-DbaDuplicateIndex", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sql2005\nReturns duplicate indexes found on sql2005\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sql2017 -SqlCredential sqladmin\nFinds exact duplicate indexes on all user databases present on sql2017, using SQL authentication.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sql2017 -Database db1, db2\nFinds exact duplicate indexes on the db1 and db2 databases.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sql2017 -IncludeOverlapping\nFinds both duplicate and overlapping indexes on all user databases.", "Syntax": "Find-DbaDuplicateIndex [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [-IncludeOverlapping] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaInstance", "Description": "This function searches for SQL Server Instances.\n\nIt supports a variety of scans for this purpose which can be separated in two categories:\n- Discovery\n- Scan\n\nDiscovery:\nThis is where it compiles a list of computers / addresses to check.\nIt supports several methods of generating such lists (including Active Directory lookup or IP Ranges), but also supports specifying a list of computers to check.\n- For details on discovery, see the documentation on the \u0027-DiscoveryType\u0027 parameter\n- For details on explicitly providing a list, see the documentation on the \u0027-ComputerName\u0027 parameter\n\nScan:\nOnce a list of computers has been provided, this command will execute a variety of actions to determine any instances present for each of them.\nThis is described in more detail in the documentation on the \u0027-ScanType\u0027 parameter.\nAdditional parameters allow more granular control over individual scans (e.g. Credentials to use).\n\nNote on logging and auditing:\nThe Discovery phase is un-problematic since it is non-intrusive, however during the scan phase, all targeted computers may be accessed repeatedly.\nThis may cause issues with security teams, due to many logon events and possibly failed authentication.\nThis action constitutes a network scan, which may be illegal depending on the nation you are in and whether you own the network you scan.\nIf you are unsure whether you may use this command in your environment, check the detailed description on the \u0027-ScanType\u0027 parameter and contact your IT security team for advice.", "Tags": [ "Instance", "Connect", "SqlServer" ], "Params": [ [ "ComputerName", "The computer to scan. Can be a variety of input types, including text or the output of Get-ADComputer.\r\nAny extra instance information (such as connection strings or live sql server connections) beyond the computername will be discarded.", "", true, "true (ByValue)", "" ], [ "DiscoveryType", "The mechanisms to be used to discover instances.\r\nSupports any combination of:\r\n- Service Principal Name lookup (\u0027Domain\u0027; from Active Directory)\r\n- SQL Instance Enumeration (\u0027DataSourceEnumeration\u0027; same as SSMS uses)\r\n- IP Address range (\u0027IPRange\u0027; all IP Addresses will be scanned)\nSPN Lookup:\r\nThe function tries to connect active directory to look up all computers with registered SQL Instances.\r\nNot all instances need to be registered properly, making this not 100% reliable.\r\nBy default, your nearest Domain Controller is contacted for this scan.\r\nHowever it is possible to explicitly state the DC to contact using its DistinguishedName and the \u0027-DomainController\u0027 parameter.\r\nIf credentials were specified using the \u0027-Credential\u0027 parameter, those same credentials are used to perform this lookup, allowing the scan of other domains.\nSQL Instance Enumeration:\r\nThis uses the default UDP Broadcast based instance enumeration used by SSMS to detect instances.\r\nNote that the result from this is not used in the actual scan, but only to compile a list of computers to scan.\r\nTo enable the same results for the scan, ensure that the \u0027Browser\u0027 scan is enabled.\nIP Address range:\r\nThis \u0027Discovery\u0027 uses a range of IPAddresses and simply passes them on to be tested.\r\nSee the \u0027Description\u0027 part of help on security issues of network scanning.\r\nBy default, it will enumerate all ethernet network adapters on the local computer and scan the entire subnet they are on.\r\nBy using the \u0027-IpAddress\u0027 parameter, custom network ranges can be specified.", "", true, "false", "" ], [ "Credential", "The credentials to use on windows network connection.\r\nThese credentials are used for:\r\n- Contact to domain controllers for SPN lookups (only if explicit Domain Controller is specified)\r\n- CIM/WMI contact to the scanned computers during the scan phase (see the \u0027-ScanType\u0027 parameter documentation on affected scans).", "", false, "false", "" ], [ "SqlCredential", "The credentials used to connect to SqlInstances to during the scan phase.\r\nSee the \u0027-ScanType\u0027 parameter documentation on affected scans.", "", false, "false", "" ], [ "ScanType", "The scans are the individual methods used to retrieve information about the scanned computer and any potentially installed instances.\r\nThis parameter is optional, by default all scans except for establishing an actual SQL connection are performed.\r\nScans can be specified in any arbitrary combination, however at least one instance detecting scan needs to be specified in order for data to be returned.\nScans:\r\n Browser\r\n- Tries discovering all instances via the browser service\r\n- This scan detects instances.\nSQLService\r\n- Tries listing all SQL Services using CIM/WMI\r\n- This scan uses credentials specified in the \u0027-Credential\u0027 parameter if any.\r\n- This scan detects instances.\r\n- Success in this scan guarantees high confidence (See parameter \u0027-MinimumConfidence\u0027 for details).\nSPN\r\n- Tries looking up the Service Principal Names for each instance\r\n- Will use the nearest Domain Controller by default\r\n- Target a specific domain controller using the \u0027-DomainController\u0027 parameter\r\n- If using the \u0027-DomainController\u0027 parameter, use the \u0027-Credential\u0027 parameter to specify the credentials used to connect\nTCPPort\r\n- Tries connecting to the TCP Ports.\r\n- By default, port 1433 is connected to.\r\n- The parameter \u0027-TCPPort\u0027 can be used to provide a list of port numbers to scan.\r\n- This scan detects possible instances. Since other services might bind to a given port, this is not the most reliable test.\r\n- This scan is also used to validate found SPNs if both scans are used in combination\nDNSResolve\r\n- Tries resolving the computername in DNS\nPing\r\n- Tries pinging the computer. Failure will NOT terminate scans.\nSqlConnect\r\n- Tries to establish a SQL connection to the server\r\n- Uses windows credentials by default\r\n- Specify custom credentials using the \u0027-SqlCredential\u0027 parameter\r\n- This scan is not used by default\r\n- Success in this scan guarantees high confidence (See parameter \u0027-MinimumConfidence\u0027 for details).\nAll\r\n- All of the above", "", false, "false", "Default" ], [ "IpAddress", "This parameter can be used to override the defaults for the IPRange discovery.\r\nThis parameter accepts a list of strings supporting any combination of:\r\n- Plain IP Addresses (e.g.: \"10.1.1.1\")\r\n- IP Address Ranges (e.g.: \"10.1.1.1-10.1.1.5\")\r\n- IP Address \u0026 Subnet Mask (e.g.: \"10.1.1.1/255.255.255.0\")\r\n- IP Address \u0026 Subnet Length: (e.g.: \"10.1.1.1/24)\r\nOverlapping addresses will not result in duplicate scans.", "", false, "false", "" ], [ "DomainController", "The domain controller to contact for SPN lookups / searches.\r\nUses the credentials from the \u0027-Credential\u0027 parameter if specified.", "", false, "false", "" ], [ "TCPPort", "The ports to scan in the TCP Port Scan method.\r\nDefaults to 1433.", "", false, "false", "1433" ], [ "MinimumConfidence", "This command tries to discover instances, which isn\u0027t always a sure thing.\r\nDepending on the number and type of scans completed, we have different levels of confidence in our results.\r\nBy default, we will return anything that we have at least a low confidence of being an instance.\r\nThese are the confidence levels we support and how they are determined:\r\n- High: Established SQL Connection (including rejection for bad credentials) or service scan.\r\n- Medium: Browser reply or a combination of TCPConnect _and_ SPN test.\r\n- Low: Either TCPConnect _or_ SPN\r\n- None: Computer existence could be verified, but no sign of an SQL Instance", "", false, "false", "Low" ], [ "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": "Scott Sutherland, 2018 NetSPI | Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Search for SQL Server Instances.", "Name": "Find-DbaInstance", "Links": "https://dbatools.io/Find-DbaInstance", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaInstance -DiscoveryType Domain, DataSourceEnumeration\nPerforms a network search for SQL Instances by:\r\n- Looking up the Service Principal Names of computers in active directory\r\n- Using the UDP broadcast based auto-discovery of SSMS\r\nAfter that it will extensively scan all hosts thus discovered for instances.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaInstance -DiscoveryType All\nPerforms a network search for SQL Instances, using all discovery protocols:\r\n- Active directory search for Service Principal Names\r\n- SQL Instance Enumeration (same as SSMS does)\r\n- All IPAddresses in the current computer\u0027s subnets of all connected network interfaces\r\nNote: This scan will take a long time, due to including the IP Scan\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-ADComputer -Filter \"*\" | Find-DbaInstance\nScans all computers in the domain for SQL Instances, using a deep probe:\r\n- Tries resolving the name in DNS\r\n- Tries pinging the computer\r\n- Tries listing all SQL Services using CIM/WMI\r\n- Tries discovering all instances via the browser service\r\n- Tries connecting to the default TCP Port (1433)\r\n- Tries connecting to the TCP port of each discovered instance\r\n- Tries to establish a SQL connection to the server using default windows credentials\r\n- Tries looking up the Service Principal Names for each instance\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-Content .\\servers.txt | Find-DbaInstance -SqlCredential $cred -ScanType Browser, SqlConnect\nReads all servers from the servers.txt file (one server per line),\r\nthen scans each of them for instances using the browser service\r\nand finally attempts to connect to each instance found using the specified credentials.\r\nthen scans each of them for instances using the browser service and SqlService\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eFind-DbaInstance -ComputerName localhost | Get-DbaDatabase | Format-Table -Wrap\nScans localhost for instances using the browser service, traverses all instances for all databases and displays all information in a formatted table.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eFind-DbaInstance -ComputerName localhost | Get-DbaDatabase | Select-Object SqlInstance, Name, Status, RecoveryModel, SizeMB, Compatibility, Owner, LastFullBackup, LastDiffBackup, LastLogBackup \r\n| Format-Table -Wrap\nScans localhost for instances using the browser service, traverses all instances for all databases and displays a subset of the important information in a formatted table.\nUsing this method reguarly is not recommended. Use Get-DbaService or Get-DbaCmsRegServer instead.", "Syntax": "Find-DbaInstance -ComputerName \u003cDbaInstanceParameter[]\u003e [-Credential \u003cPSCredential\u003e] [-SqlCredential \u003cPSCredential\u003e] [-ScanType {TCPPort | SqlConnect | SqlService | DNSResolve | SPN | Browser | Ping | Default | All}] [-DomainController \u003cString\u003e] [-TCPPort \u003cInt32[]\u003e] [-MinimumConfidence {None | Low | Medium | High}] [-EnableException] [\u003cCommonParameters\u003e]\nFind-DbaInstance -DiscoveryType {IPRange | Domain | DataSourceEnumeration | All} [-Credential \u003cPSCredential\u003e] [-SqlCredential \u003cPSCredential\u003e] [-ScanType {TCPPort | SqlConnect | SqlService | DNSResolve | SPN | Browser | Ping | Default | All}] [-IpAddress \u003cString[]\u003e] [-DomainController \u003cString\u003e] [-TCPPort \u003cInt32[]\u003e] [-MinimumConfidence {None | Low | Medium | High}] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaLoginInGroup", "Description": "Outputs all the active directory groups members for a server, or limits it to find a specific AD user in the groups", "Tags": [ "Login", "Group", "Security" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "PSCredential object to connect under. If not specified, current Windows login will be used.", "", false, "false", "" ], [ "Login", "Find all AD Groups used on the instance that an individual login is a member of.", "", 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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/ | Simone Bizzotto (@niphlod)", "Synopsis": "Finds Logins in Active Directory groups that have logins on the SQL Instance.", "Name": "Find-DbaLoginInGroup", "Links": "https://dbatools.io/Find-DbaLoginInGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaLoginInGroup -SqlInstance DEV01 -Login \"MyDomain\\Stephen.Bennett\"\nReturns all active directory groups with logins on Sql Instance DEV01 that contain the AD user Stephen.Bennett.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaLoginInGroup -SqlInstance DEV01\nReturns all active directory users within all windows AD groups that have logins on the instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaLoginInGroup -SqlInstance DEV01 | Where-Object Login -like \u0027*stephen*\u0027\nReturns all active directory users within all windows AD groups that have logins on the instance whose login contains \"stephen\"", "Syntax": "Find-DbaLoginInGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaOrphanedFile", "Description": "This command searches all directories associated with SQL database files for database files that are not currently in use by the SQL Server instance.\n\nBy default, it looks for orphaned .mdf, .ldf and .ndf files in the root\\data directory, the default data path, the default log path, the system paths and any directory in use by any attached directory.\n\nYou can specify additional filetypes using the -FileType parameter, and additional paths to search using the -Path parameter.", "Tags": [ "Orphan", "Database", "DatabaseFile" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 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 one or more directories to search in addition to the default data and log directories.", "", false, "false", "" ], [ "FileType", "Specifies file extensions other than mdf, ldf and ndf to search for. Do not include the dot (\".\") when specifying the extension.", "", false, "false", "" ], [ "LocalOnly", "If this switch is enabled, only local filenames will be returned. Using this switch with multiple servers is not recommended since it does not return the associated server name.", "", false, "false", "False" ], [ "RemoteOnly", "If this switch is enabled, only remote filenames will be returned.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Find-DbaOrphanedFile finds orphaned database files. Orphaned database files are files not associated with any attached database.", "Name": "Find-DbaOrphanedFile", "Links": "https://dbatools.io/Find-DbaOrphanedFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sqlserver2014a\nConnects to sqlserver2014a, authenticating with Windows credentials, and searches for orphaned files. Returns server name, local filename, and unc path to file.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sqlserver2014a -SqlCredential $cred\nConnects to sqlserver2014a, authenticating with SQL Server authentication, and searches for orphaned files. Returns server name, local filename, and unc path to file.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014 -Path \u0027E:\\Dir1\u0027, \u0027E:\\Dir2\u0027\nFinds the orphaned files in \"E:\\Dir1\" and \"E:Dir2\" in addition to the default directories.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014 -LocalOnly\nReturns only the local file paths for orphaned files.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014 -RemoteOnly\nReturns only the remote file path for orphaned files.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014, sql2016 -FileType fsf, mld\nFinds the orphaned ending with \".fsf\" and \".mld\" in addition to the default filetypes \".mdf\", \".ldf\", \".ndf\" for both the servers sql2014 and sql2016.", "Syntax": "Find-DbaOrphanedFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString[]\u003e] [[-FileType] \u003cString[]\u003e] [-LocalOnly] [-RemoteOnly] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaSimilarTable", "Description": "This function can either run against specific databases or all databases searching all/specific tables and views including in system databases.\nTypically one would use this to find for example archive version(s) of a table whose structures are similar.\nThis can also be used to find tables/views that are very similar to a given table/view structure to see where a table/view might be used.\n\nMore information can be found here: https://sqljana.wordpress.com/2017/03/31/sql-server-find-tables-with-similar-table-structure/", "Tags": "Table", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "SchemaName", "If you are looking in a specific schema whose table structures is to be used as reference structure, provide the name of the schema.\r\nIf no schema is provided, looks at all schemas", "", false, "false", "" ], [ "TableName", "If you are looking in a specific table whose structure is to be used as reference structure, provide the name of the table.\r\nIf no table is provided, looks at all tables\r\nIf the table name exists in multiple schemas, all of them would qualify", "", false, "false", "" ], [ "ExcludeViews", "By default, views are included. You can exclude them by setting this switch to $false\r\nThis excludes views in both matching and matched list", "", false, "false", "False" ], [ "IncludeSystemDatabases", "By default system databases are ignored but you can include them within the search using this parameter", "", false, "false", "False" ], [ "MatchPercentThreshold", "The minimum percentage of column names that should match between the matching and matched objects.\r\nEntries with no matches are eliminated", "", false, "false", "0" ], [ "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": "Jana Sattainathan (@SQLJana), http://sqljana.wordpress.com", "Synopsis": "Returns all tables/views that are similar in structure by comparing the column names of matching and matched tables/views", "Name": "Find-DbaSimilarTable", "Links": "https://dbatools.io/Find-DbaSimilarTable", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01\nSearches all user database tables and views for each, returns all tables or views with their matching tables/views and match percent\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks\nSearches AdventureWorks database and lists tables/views and their corresponding matching tables/views with match percent\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -SchemaName HumanResource\nSearches AdventureWorks database and lists tables/views in the HumanResource schema with their corresponding matching tables/views with match percent\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -SchemaName HumanResource -Table Employee\nSearches AdventureWorks database and lists tables/views in the HumanResource schema and table Employee with its corresponding matching tables/views with match percent\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -MatchPercentThreshold 60\nSearches AdventureWorks database and lists all tables/views with its corresponding matching tables/views with match percent greater than or equal to 60", "Syntax": "Find-DbaSimilarTable [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-SchemaName \u003cString\u003e] [-TableName \u003cString\u003e] [-ExcludeViews] [-IncludeSystemDatabases] [-MatchPercentThreshold \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaStoredProcedure", "Description": "This function can either run against specific databases or all databases searching all user or user and system stored procedures.", "Tags": [ "StoredProcedure", "Proc" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "Pattern", "String pattern that you want to search for in the stored procedure text body", "", true, "false", "" ], [ "IncludeSystemObjects", "By default, system stored procedures are ignored but you can include them within the search using this parameter.\nWarning - this will likely make it super slow if you run it on all databases.", "", false, "false", "False" ], [ "IncludeSystemDatabases", "By default system databases are ignored but you can include them within the search using this parameter", "", 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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Returns all stored procedures that contain a specific case-insensitive string or regex pattern.", "Name": "Find-DbaStoredProcedure", "Links": "https://dbatools.io/Find-DbaStoredProcedure", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance DEV01 -Pattern whatever\nSearches all user databases stored procedures for \"whatever\" in the text body\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance sql2016 -Pattern \u0027\\w+@\\w+\\.\\w+\u0027\nSearches all databases for all stored procedures that contain a valid email pattern in the text body\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance DEV01 -Database MyDB -Pattern \u0027some string\u0027 -Verbose\nSearches in \"mydb\" database stored procedures for \"some string\" in the text body\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance sql2016 -Database MyDB -Pattern RUNTIME -IncludeSystemObjects\nSearches in \"mydb\" database stored procedures for \"runtime\" in the text body", "Syntax": "Find-DbaStoredProcedure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -Pattern \u003cString\u003e [-IncludeSystemObjects] [-IncludeSystemDatabases] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaTrigger", "Description": "This function search on Instance, Database and Object level.\nIf you specify one or more databases, search on Server level will not be preformed.", "Tags": "Trigger", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "Pattern", "String pattern that you want to search for in the trigger text body", "", true, "false", "" ], [ "TriggerLevel", "Allows specify the trigger level that you want to search. By default is All (Server, Database, Object).", "", false, "false", "All" ], [ "IncludeSystemObjects", "By default, system triggers are ignored but you can include them within the search using this parameter.\nWarning - this will likely make it super slow if you run it on all databases.", "", false, "false", "False" ], [ "IncludeSystemDatabases", "By default system databases are ignored but you can include them within the search using this parameter", "", 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": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Returns all triggers that contain a specific case-insensitive string or regex pattern.", "Name": "Find-DbaTrigger", "Links": "https://dbatools.io/Find-DbaTrigger", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaTrigger -SqlInstance DEV01 -Pattern whatever\nSearches all user databases triggers for \"whatever\" in the text body\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaTrigger -SqlInstance sql2016 -Pattern \u0027\\w+@\\w+\\.\\w+\u0027\nSearches all databases for all triggers that contain a valid email pattern in the text body\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaTrigger -SqlInstance DEV01 -Database MyDB -Pattern \u0027some string\u0027 -Verbose\nSearches in \"mydb\" database triggers for \"some string\" in the text body\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaTrigger -SqlInstance sql2016 -Database MyDB -Pattern RUNTIME -IncludeSystemObjects\nSearches in \"mydb\" database triggers for \"runtime\" in the text body", "Syntax": "Find-DbaTrigger [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -Pattern \u003cString\u003e [-TriggerLevel \u003cString\u003e] [-IncludeSystemObjects] [-IncludeSystemDatabases] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaUserObject", "Description": "Looks at the below list of objects to see if they are either owned by a user or a specific user (using the parameter -Pattern)\nDatabase Owner\nAgent Job Owner\nUsed in Credential\nUSed in Proxy\nSQL Agent Steps using a Proxy\nEndpoints\nServer Roles\nDatabase Schemas\nDatabase Roles\nDatabase Assembles\nDatabase Synonyms", "Tags": "Object", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input", "ServerInstance,SqlServer,SqlInstances", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Pattern", "The regex pattern that the command will search for", "", 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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Searches SQL Server to find user-owned objects (i.e. not dbo or sa) or for any object owned by a specific user specified by the Pattern parameter.", "Name": "Find-DbaUserObject", "Links": "https://dbatools.io/Find-DbaUserObject", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaUserObject -SqlInstance DEV01 -Pattern ad\\stephen\nSearches user objects for owner ad\\stephen\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaUserObject -SqlInstance DEV01 -Verbose\nShows all user owned (non-sa, non-dbo) objects and verbose output", "Syntax": "Find-DbaUserObject [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Pattern \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Find-DbaView", "Description": "This function can either run against specific databases or all databases searching all user or user and system views.", "Tags": "View", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "Pattern", "String pattern that you want to search for in the view text body", "", true, "false", "" ], [ "IncludeSystemObjects", "By default, system views are ignored but you can include them within the search using this parameter.\nWarning - this will likely make it super slow if you run it on all databases.", "", false, "false", "False" ], [ "IncludeSystemDatabases", "By default system databases are ignored but you can include them within the search using this parameter", "", 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": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Returns all views that contain a specific case-insensitive string or regex pattern.", "Name": "Find-DbaView", "Links": "https://dbatools.io/Find-DbaView", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eFind-DbaView -SqlInstance DEV01 -Pattern whatever\nSearches all user databases views for \"whatever\" in the text body\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eFind-DbaView -SqlInstance sql2016 -Pattern \u0027\\w+@\\w+\\.\\w+\u0027\nSearches all databases for all views that contain a valid email pattern in the text body\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaView -SqlInstance DEV01 -Database MyDB -Pattern \u0027some string\u0027 -Verbose\nSearches in \"mydb\" database views for \"some string\" in the text body\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eFind-DbaView -SqlInstance sql2016 -Database MyDB -Pattern RUNTIME -IncludeSystemObjects\nSearches in \"mydb\" database views for \"runtime\" in the text body", "Syntax": "Find-DbaView [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -Pattern \u003cString\u003e [-IncludeSystemObjects] [-IncludeSystemDatabases] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Format-DbaBackupInformation", "Description": "Performs various mapping on Backup History, ready restoring\nOptions include changing restore paths, backup paths, database name and many others", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "BackupHistory", "A dbatools backupHistory object, normally this will have been created using Select-DbaBackupInformation", "", true, "true (ByValue)", "" ], [ "ReplaceDatabaseName", "If a single value is provided, this will be replaced do all occurrences a database name\r\nIf a Hashtable is passed in, each database name mention will be replaced as specified. If a database\u0027s name does not appear it will not be replace\r\nDatabaseName will also be replaced where it occurs in the file paths of data and log files.\r\nPlease note, that this won\u0027t change the Logical Names of data files, that has to be done with a separate Alter DB call", "", false, "false", "" ], [ "ReplaceDbNameInFile", "If set, will replace the old database name with the new name if it occurs in the file name", "", false, "false", "False" ], [ "DataFileDirectory", "This will move ALL restored files to this location during the restore", "", false, "false", "" ], [ "LogFileDirectory", "This will move all log files to this location, overriding DataFileDirectory", "", false, "false", "" ], [ "DestinationFileStreamDirectory", "This move the FileStream folder and contents to the new location, overriding DataFileDirectory", "", false, "false", "" ], [ "DatabaseNamePrefix", "This string will be prefixed to all restored database\u0027s name", "", false, "false", "" ], [ "DatabaseFilePrefix", "A string that will be prefixed to every file restored", "", false, "false", "" ], [ "DatabaseFileSuffix", "A string that will be suffixed to every file restored", "", false, "false", "" ], [ "RebaseBackupFolder", "Use this to rebase where your backups are stored.", "", false, "false", "" ], [ "Continue", "Indicates that this is a continuing restore", "", false, "false", "False" ], [ "FileMapping", "A hashtable that can be used to move specific files to a location.\r\n`$FileMapping = @{\u0027DataFile1\u0027=\u0027c:\\restoredfiles\\Datafile1.mdf\u0027;\u0027DataFile3\u0027=\u0027d:\\DataFile3.mdf\u0027}`\r\nAnd files not specified in the mapping will be restored to their original location\r\nThis Parameter is exclusive with DestinationDataDirectory\r\nIf specified, this will override any other file renaming/relocation options.", "", false, "false", "" ], [ "PathSep", "By default is Windows\u0027s style (`\\`) but you can pass also, e.g., `/` for Unix\u0027s style paths", "", 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": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Transforms the data in a dbatools BackupHistory object for a restore", "Name": "Format-DbaBackupInformation", "Links": "https://dbatools.io/Format-DbaBackupInformation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$History | Format-DbaBackupInformation -ReplaceDatabaseName NewDb\nChanges as database name references to NewDb, both in the database name and any restore paths. Note, this will fail if the BackupHistory object contains backups for more than 1 database\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$History | Format-DbaBackupInformation -ReplaceDatabaseName @{\u0027OldB\u0027=\u0027NewDb\u0027;\u0027ProdHr\u0027=\u0027DevHr\u0027}\nWill change all occurrences of original database name in the backup history (names and restore paths) using the mapping in the hashtable.\r\nIn this example any occurrence of OldDb will be replaced with NewDb and ProdHr with DevPR\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$History | Format-DbaBackupInformation -DataFileDirectory \u0027D:\\DataFiles\\\u0027 -LogFileDirectory \u0027E:\\LogFiles\\\nThis example with change the restore path for all data files (everything that is not a log file) to d:\\datafiles\r\nAnd all Transaction Log files will be restored to E:\\Logfiles\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$History | Format-DbaBackupInformation -RebaseBackupFolder f:\\backups\nThis example changes the location that SQL Server will look for the backups. This is useful if you\u0027ve moved the backups to a different location", "Syntax": "Format-DbaBackupInformation [-BackupHistory] \u003cObject[]\u003e [[-ReplaceDatabaseName] \u003cObject\u003e] [-ReplaceDbNameInFile] [[-DataFileDirectory] \u003cString\u003e] [[-LogFileDirectory] \u003cString\u003e] [[-DestinationFileStreamDirectory] \u003cString\u003e] [[-DatabaseNamePrefix] \u003cString\u003e] [[-DatabaseFilePrefix] \u003cString\u003e] [[-DatabaseFileSuffix] \u003cString\u003e] [[-RebaseBackupFolder] \u003cString\u003e] [-Continue] [[-FileMapping] \u003cHashtable\u003e] [[-PathSep] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgDatabase", "Description": "Gets availability group databases from a SQL Server instance.\n\nDefault view provides most common set of properties for information on the database in an availability group.\n\nInformation returned on the database will be specific to that replica, whether it is primary or a secondary.", "Tags": [ "Hadr", "HA", "AG", "AvailabilityGroup", "Replica" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "Specify the availability groups to query.", "", false, "false", "" ], [ "Database", "Specify the database or databases to return. This list is auto-populated from the server for tab completion. Multiple databases can be specified. If none are specified all databases will be processed.", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaAvailabilityGroup.", "", 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": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Gets availability group databases from a SQL Server instance.", "Name": "Get-DbaAgDatabase", "Links": "https://dbatools.io/Get-DbaAgDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sql2017a\nReturns all the databases in each availability group found on sql2017a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sql2017a -AvailabilityGroup AG101\nReturns all the databases in the availability group AG101 on sql2017a\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlcluster -AvailabilityGroup SharePoint -Database Sharepoint_Config | Get-DbaAgDatabase\nReturns the database Sharepoint_Config found in the availability group SharePoint on server sqlcluster", "Syntax": "Get-DbaAgDatabase [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentAlert", "Description": "This function returns SQL Agent alerts.", "Tags": [ "Agent", "SMO" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,Instance,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", "" ], [ "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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Returns all SQL Agent alerts on a SQL Server Agent.", "Name": "Get-DbaAgentAlert", "Links": "https://dbatools.io/Get-DbaAgentAlert", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentAlert -SqlInstance ServerA,ServerB\\instanceB\nReturns all SQL Agent alerts on serverA and serverB\\instanceB\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027serverA\u0027,\u0027serverB\\instanceB\u0027 | Get-DbaAgentAlert\nReturns all SQL Agent alerts on serverA and serverB\\instanceB", "Syntax": "Get-DbaAgentAlert [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentJob", "Description": "The Get-DbaAgentJob returns connected SMO object for SQL Agent Job information for each instance(s) of SQL Server.", "Tags": [ "Job", "Agent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "Job", "The job(s) to process - this list is auto-populated from the server. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude - this list is auto-populated from the server.", "", false, "false", "" ], [ "NoDisabledJobs", "Switch will exclude disabled jobs from the output.", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Agent Job information for each instance(s) of SQL Server.", "Name": "Get-DbaAgentJob", "Links": "https://dbatools.io/Get-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost\nReturns all SQL Agent Jobs on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost, sql2016\nReturns all SQl Agent Jobs for the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost -Job BackupData, BackupDiff\nReturns all SQL Agent Jobs named BackupData and BackupDiff from the local SQL Server instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost -ExcludeJob BackupDiff\nReturns all SQl Agent Jobs for the local SQL Server instances, except the BackupDiff Job.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost -NoDisabledJobs\nReturns all SQl Agent Jobs for the local SQL Server instances, excluding the disabled jobs.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$servers | Get-DbaAgentJob | Out-GridView -PassThru | Start-DbaAgentJob -WhatIf\nFind all of your Jobs from SQL Server instances in the $servers collection, select the jobs you want to start then see jobs would start if you ran Start-DbaAgentJob", "Syntax": "Get-DbaAgentJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-NoDisabledJobs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentJobCategory", "Description": "Get-DbaAgentJobCategory makes it possible to retrieve the job categories.", "Tags": [ "Agent", "Job", "JobCategory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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)", "Credential", false, "false", "" ], [ "Category", "The name of the category to filter out. If no category is used all categories will be returned.", "", false, "false", "" ], [ "CategoryType", "The type of category. This can be \"LocalJob\", \"MultiServerJob\" or \"None\".\r\nIf no category is used all categories types will be returned.", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Get-DbaJobCategory", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Get-DbaAgentJobCategory retrieves the job categories.", "Name": "Get-DbaAgentJobCategory", "Links": "https://dbatools.io/Get-DbaAgentJobCategory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJobCategory -SqlInstance sql1\nReturn all the job categories.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Log Shipping\u0027\nReturn all the job categories that have the name \u0027Log Shipping\u0027.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgentJobCategory -SqlInstance sstad-pc -CategoryType MultiServerJob\nReturn all the job categories that have a type MultiServerJob.", "Syntax": "Get-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \u003cString[]\u003e] [[-CategoryType] \u003cString\u003e] [-Force] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentJobHistory", "Description": "Get-DbaAgentJobHistory returns all information on the executions still available on each instance(s) of SQL Server submitted.\nThe cleanup of SQL Agent history determines how many records are kept.\n\nhttps://msdn.microsoft.com/en-us/library/ms201680.aspx\nhttps://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.agent.jobhistoryfilter(v=sql.120).aspx", "Tags": [ "Job", "Agent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "Job", "The name of the job from which the history is wanted. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "StartDate", "The DateTime starting from which the history is wanted. If unspecified, all available records will be processed.", "", false, "false", "1900-01-01" ], [ "EndDate", "The DateTime before which the history is wanted. If unspecified, all available records will be processed.", "", false, "false", "$(Get-Date)" ], [ "NoJobSteps", "Use this switch to discard all job steps, and return only the job totals", "", false, "false", "False" ], [ "WithOutputFile", "Use this switch to retrieve the output file (only if you want step details). Bonus points, we handle the quirks\r\nof SQL Agent tokens to the best of our knowledge (https://technet.microsoft.com/it-it/library/ms175575(v=sql.110).aspx)", "", false, "false", "False" ], [ "JobCollection", "An array of SMO jobs", "", 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" ] ], "Alias": "", "Author": "Klaas Vandenberghe (@PowerDbaKlaas) | Simone Bizzotto (@niphold)", "Synopsis": "Gets execution history of SQL Agent Job on instance(s) of SQL Server.", "Name": "Get-DbaAgentJobHistory", "Links": "https://dbatools.io/Get-DbaAgentJobHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance localhost\nReturns all SQL Agent Job execution results on the local default SQL Server instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance localhost, sql2016\nReturns all SQL Agent Job execution results for the local and sql2016 SQL Server instances.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\\Inst2K17\u0027 | Get-DbaAgentJobHistory\nReturns all SQL Agent Job execution results for sql1 and sql2\\Inst2K17.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 | Select-Object *\nReturns all properties for all SQl Agent Job execution results on sql2\\Inst2K17.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -Job \u0027Output File Cleanup\u0027\nReturns all properties for all SQl Agent Job execution results of the \u0027Output File Cleanup\u0027 job on sql2\\Inst2K17.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -Job \u0027Output File Cleanup\u0027 -WithOutputFile\nReturns all properties for all SQl Agent Job execution results of the \u0027Output File Cleanup\u0027 job on sql2\\Inst2K17,\r\nwith additional properties that show the output filename path\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -NoJobSteps\nReturns the SQL Agent Job execution results for the whole jobs on sql2\\Inst2K17, leaving out job step execution results.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -StartDate \u00272017-05-22\u0027 -EndDate \u00272017-05-23 12:30:00\u0027\nReturns the SQL Agent Job execution results between 2017/05/22 00:00:00 and 2017/05/23 12:30:00 on sql2\\Inst2K17.\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 | Where-Object Name -Match backup | Get-DbaAgentJobHistory\nGets all jobs with the name that match the regex pattern \"backup\" and then gets the job history from those. You can also use -Like *backup* in this example.", "Syntax": "Get-DbaAgentJobHistory [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-StartDate \u003cDateTime\u003e] [-EndDate \u003cDateTime\u003e] [-NoJobSteps] [-WithOutputFile] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaAgentJobHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-StartDate \u003cDateTime\u003e] [-EndDate \u003cDateTime\u003e] [-NoJobSteps] [-WithOutputFile] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaAgentJobHistory [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-StartDate \u003cDateTime\u003e] [-EndDate \u003cDateTime\u003e] [-NoJobSteps] [-WithOutputFile] -JobCollection \u003cJob\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentJobOutputFile", "Description": "This function returns for one or more SQL Instances the output file value for each step of one or many agent job with the Job Names\nprovided dynamically. It will not return anything if there is no Output File", "Tags": [ "Agent", "Job" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", true, "true (ByValue, ByPropertyName)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user be it Windows or SQL Server. Windows users are determined by the existence of a backslash, so if you are intending to use an \r\nalternative Windows connection instead of a SQL login, ensure it contains a backslash.", "", false, "true (ByPropertyName)", "" ], [ "Job", "The job(s) to process - this list is auto-populated from the server. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude - this list is auto-populated from the server", "", 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": "Rob Sewell (https://sqldbawithabeard.com) | Simone Bizzotto (@niphold)", "Synopsis": "Returns the Output File for each step of one or many agent job with the Job Names provided dynamically if\nrequired for one or more SQL Instances", "Name": "Get-DbaAgentJobOutputFile", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Job \u0027The Agent Job\u0027\nThis will return the configured paths to the output files for each of the job step of the The Agent Job Job\r\non the SERVERNAME instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME\nThis will return the configured paths to the output files for each of the job step of all the Agent Jobs\r\non the SERVERNAME instance\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME,SERVERNAME2 -Job \u0027The Agent Job\u0027\nThis will return the configured paths to the output files for each of the job step of the The Agent Job Job\r\non the SERVERNAME instance and SERVERNAME2\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$Servers = \u0027SERVER\u0027,\u0027SERVER\\INSTANCE1\u0027\nGet-DbaAgentJobOutputFile -SqlInstance $Servers -Job \u0027The Agent Job\u0027 -OpenFile\nThis will return the configured paths to the output files for each of the job step of the The Agent Job Job\r\non the SERVER instance and the SERVER\\INSTANCE1 and open the files if they are available\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME | Out-GridView\nThis will return the configured paths to the output files for each of the job step of all the Agent Jobs\r\non the SERVERNAME instance and Pipe them to Out-GridView\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e(Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME | Out-GridView -PassThru).FileName | Invoke-Item\nThis will return the configured paths to the output files for each of the job step of all the Agent Jobs\r\non the SERVERNAME instance and Pipe them to Out-GridView and enable you to choose the output\r\nfile and open it\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Verbose\nThis will return the configured paths to the output files for each of the job step of all the Agent Jobs\r\non the SERVERNAME instance and also show the job steps without an output file", "Syntax": "Get-DbaAgentJobOutputFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentJobStep", "Description": "The Get-DbaAgentJobStep returns connected SMO object for SQL Agent Job Step for each instance(s) of SQL Server.", "Tags": [ "Job", "Agent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "Job", "The job(s) to process - this list is auto-populated from the server. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude - this list is auto-populated from the server.", "", false, "false", "" ], [ "NoDisabledJobs", "Switch will exclude disabled jobs from the output.", "", 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": "Klaas Vandenberghe (@PowerDbaKlaas), http://powerdba.eu", "Synopsis": "Gets SQL Agent Job Step information for each instance(s) of SQL Server.", "Name": "Get-DbaAgentJobStep", "Links": "https://dbatools.io/Get-DbaAgentJobStep", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost\nReturns all SQL Agent Job Steps on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost, sql2016\nReturns all SQL Agent Job Steps for the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost -Job BackupData, BackupDiff\nReturns all SQL Agent Job Steps for the jobs named BackupData and BackupDiff from the local SQL Server instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost -ExcludeJob BackupDiff\nReturns all SQL Agent Job Steps for the local SQL Server instances, except for the BackupDiff Job.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost -NoDisabledJobs\nReturns all SQL Agent Job Steps for the local SQL Server instances, excluding the disabled jobs.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$servers | Get-DbaAgentJobStep\nFind all of your Job Steps from SQL Server instances in the $servers collection", "Syntax": "Get-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-NoDisabledJobs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentLog", "Description": "Gets the \"SQL Agent Error Log\" of an instance. Returns all 10 error logs by default.", "Tags": "Logging", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "Credential", false, "false", "" ], [ "LogNumber", "An Int32 value that specifies the index number of the error log required. Error logs are listed 0 through 9 where 0 is the current error log and 9 is the oldest.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the \"SQL Agent Error Log\" of an instance", "Name": "Get-DbaAgentLog", "Links": "https://dbatools.io/Get-DbaAgentLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentLog -SqlInstance sql01\\sharepoint\nReturns the entire error log for the SQL Agent on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentLog -SqlInstance sql01\\sharepoint -LogNumber 3, 6\nReturns log numbers 3 and 6 for the SQL Agent on sql01\\sharepoint\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaAgentLog -LogNumber 0\nReturns the most recent SQL Agent error logs for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaAgentLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-LogNumber] \u003cInt32[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentOperator", "Description": "This function returns SQL Agent operators.", "Tags": [ "Agent", "Operator" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "Operator", "The operator(s) to process - this list is auto-populated from the server. If unspecified, all operators will be processed.", "", false, "false", "" ], [ "ExcludeOperator", "The operator(s) to exclude - this list is auto-populated from the server", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Returns all SQL Agent operators on a SQL Server Agent.", "Name": "Get-DbaAgentOperator", "Links": "https://dbatools.io/Get-DbaAgentOperator", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentOperator -SqlInstance ServerA,ServerB\\instanceB\nReturns any SQL Agent operators on serverA and serverB\\instanceB\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027ServerA\u0027,\u0027ServerB\\instanceB\u0027 | Get-DbaAgentOperator\nReturns all SQL Agent operators on serverA and serverB\\instanceB\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgentOperator -SqlInstance ServerA -Operator Dba1,Dba2\nReturns only the SQL Agent Operators Dba1 and Dba2 on ServerA.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAgentOperator -SqlInstance ServerA,ServerB -ExcludeOperator Dba3\nReturns all the SQL Agent operators on ServerA and ServerB, except the Dba3 operator.", "Syntax": "Get-DbaAgentOperator [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Operator \u003cObject[]\u003e] [-ExcludeOperator \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentProxy", "Description": "This function returns SQL Agent proxies.", "Tags": [ "Agent", "SMO" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,Instance,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", "" ], [ "Proxy", "The proxy to process - this list is auto-populated from the server. If unspecified, all proxies will be processed.", "", 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": "Returns all SQL Agent proxies on a SQL Server Agent.", "Name": "Get-DbaAgentProxy", "Links": "https://dbatools.io/Get-DbaAgentProxy", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentProxy -SqlInstance ServerA,ServerB\\instanceB\nReturns all SQL Agent proxies on serverA and serverB\\instanceB\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027serverA\u0027,\u0027serverB\\instanceB\u0027 | Get-DbaAgentProxy\nReturns all SQL Agent proxies on serverA and serverB\\instanceB", "Syntax": "Get-DbaAgentProxy [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Proxy \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgentSchedule", "Description": "This function returns SQL Agent Shared Schedules.", "Tags": [ "Agent", "Schedule" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,Instance,SqlServer", true, "true (ByValue)", "" ], [ "Schedule", "Parameter to filter the schedules returned", "Schedules", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Chris McKeown (@devopsfu), http://www.devopsfu.com", "Synopsis": "Returns all SQL Agent Shared Schedules on a SQL Server Agent.", "Name": "Get-DbaAgentSchedule", "Links": "https://dbatools.io/Get-DbaAgentSchedule", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance localhost\nReturns all SQL Agent Shared Schedules on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance localhost, sql2016\nReturns all SQL Agent Shared Schedules for the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance sql2016 -Schedule \"Maintenance10min\",\"Maintenance60min\"\nReturns the \"Maintenance10min\" \u0026 \"Maintenance60min\" schedules from the sql2016 SQL Server instance", "Syntax": "Get-DbaAgentSchedule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Schedule \u003cObject[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgHadr", "Description": "Gets the Hadr setting, from the service level, and returns true or false for the specified SQL Server instance.", "Tags": [ "Hadr", "HA", "AG", "AvailabilityGroup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Shawn Melton (@wsmelton), http://wsmelton.github.io", "Synopsis": "Gets the Hadr service setting on the specified SQL Server instance.", "Name": "Get-DbaAgHadr", "Links": "https://dbatools.io/Get-DbaAgHadr", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgHadr -SqlInstance sql2016\nReturns a status of the Hadr setting for sql2016 SQL Server instance.", "Syntax": "Get-DbaAgHadr [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgListener", "Description": "Returns availability group listeners.", "Tags": [ "AG", "HA", "AvailabilityGroup", "Listener" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "Specify the availability groups to query.", "", false, "false", "" ], [ "Listener", "Return only specific listeners.", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaAvailabilityGroup.", "", 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": "Viorel Ciucu (@viorelciucu)", "Synopsis": "Returns availability group listeners.", "Name": "Get-DbaAgListener", "Links": "https://dbatools.io/Get-DbaAgListener", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgListener -SqlInstance sql2017a\nReturns all listeners found on sql2017a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgListener -SqlInstance sql2017a -AvailabilityGroup AG-a\nReturns all listeners found on sql2017a on sql2017a for the availability group AG-a\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2017a -AvailabilityGroup OPP | Get-DbaAgListener\nReturns all listeners found on sql2017a on sql2017a for the availability group OPP", "Syntax": "Get-DbaAgListener [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-Listener] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAgReplica", "Description": "Returns the availability group replica object found on the server.", "Tags": [ "AG", "HA", "AvailabilityGroup", "Replica" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "Specify the availability groups to query.", "", false, "false", "" ], [ "Replica", "Return only specific replicas.", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaAvailabilityGroup.", "", 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": "Shawn Melton (@wsmelton) | Chrissy LeMaire (@cl)", "Synopsis": "Returns the availability group replica object found on the server.", "Name": "Get-DbaAgReplica", "Links": "https://dbatools.io/Get-DbaAgReplica", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sql2017a\nReturns basic information on all the availability group replicas found on sql2017a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sql2017a -AvailabilityGroup SharePoint\nShows basic information on the replicas found on availability group SharePoint on sql2017a\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sql2017a | Select-Object *\nReturns full object properties on all availability group replicas found on sql2017a", "Syntax": "Get-DbaAgReplica [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-Replica] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAvailabilityGroup", "Description": "Returns availability group objects from a SQL Server instance.\n\nDefault view provides most common set of properties for information on the Availability Group(s).", "Tags": [ "Hadr", "HA", "AG", "AvailabilityGroup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2012 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", "" ], [ "AvailabilityGroup", "Return only specific availability groups.", "", false, "false", "" ], [ "IsPrimary", "If this switch is enabled, a boolean indicating whether SqlInstance is the Primary replica in the AG is returned.", "", 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": "Shawn Melton (@wsmelton) | Chrissy LeMaire (@cl)", "Synopsis": "Returns availability group objects from a SQL Server instance.", "Name": "Get-DbaAvailabilityGroup", "Links": "https://dbatools.io/Get-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a\nReturns basic information on all the Availability Group(s) found on sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a -AvailabilityGroup AG-a\nShows basic information on the Availability Group AG-a on sqlserver2014a.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a | Select *\nReturns full object properties on all Availability Group(s) on sqlserver2014a.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a | Select-Object -ExpandProperty PrimaryReplicaServerName\nReturns the SQL Server instancename of the primary replica as a string\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a -AvailabilityGroup AG-a -IsPrimary\nReturns true/false if the server, sqlserver2014a, is the primary replica for AG-a Availability Group.", "Syntax": "Get-DbaAvailabilityGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [-IsPrimary] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaAvailableCollation", "Description": "The Get-DbaAvailableCollation function returns the list of collations available on each SQL Server.\nOnly the connect permission is required to get this information.", "Tags": [ "Collation", "Configuration" ], "Params": [ [ "SqlInstance", "TThe target SQL Server instance or instances. Only connect permission is required.", "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", "" ], [ "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": "Bryan Hamby (@galador)", "Synopsis": "Function to get available collations for a given SQL Server", "Name": "Get-DbaAvailableCollation", "Links": "https://dbatools.io/Get-DbaAvailableCollation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAvailableCollation -SqlInstance sql2016\nGets all the collations from server sql2016 using NT authentication", "Syntax": "Get-DbaAvailableCollation [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaBackupDevice", "Description": "The Get-DbaBackupDevice command gets SQL Backup Device information for each instance(s) of SQL Server.", "Tags": "Backup", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Backup Device information for each instance(s) of SQL Server.", "Name": "Get-DbaBackupDevice", "Links": "https://dbatools.io/Get-DbaBackupDevice", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaBackupDevice -SqlInstance localhost\nReturns all Backup Devices on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaBackupDevice -SqlInstance localhost, sql2016\nReturns all Backup Devices for the local and sql2016 SQL Server instances", "Syntax": "Get-DbaBackupDevice [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaBackupHistory", "Description": "Returns backup history details for some or all databases on a SQL Server.\n\nYou can even get detailed information (including file path) for latest full, differential and log files.\n\nBackups taken with the CopyOnly option will NOT be returned, unless the IncludeCopyOnly switch is present\n\nReference: http://www.sqlhub.com/2011/07/find-your-backup-history-in-sql-server.html", "Tags": [ "DisasterRecovery", "Backup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server Instance as a different user. This can be a Windows or SQL Server account. Windows users are determined by the existence of a backslash, so if you \r\nare intending to use an alternative Windows connection instead of a SQL login, ensure it contains a backslash.", "Credential", false, "false", "" ], [ "Database", "Specifies one or more database(s) to process. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Specifies one or more database(s) to exclude from processing.", "", false, "false", "" ], [ "IncludeCopyOnly", "By default Get-DbaBackupHistory will ignore backups taken with the CopyOnly option. This switch will include them", "", false, "false", "False" ], [ "Force", "If this switch is enabled, a large amount of information is returned, similar to what SQL Server itself returns.", "", false, "false", "False" ], [ "Since", "Specifies a DateTime object to use as the starting point for the search for backups.", "", false, "false", "(Get-Date \u002701/01/1970\u0027)" ], [ "RecoveryFork", "Specifies the Recovery Fork you want backup history for", "", false, "false", "" ], [ "Last", "If this switch is enabled, the most recent full chain of full, diff and log backup sets is returned.", "", false, "false", "False" ], [ "LastFull", "If this switch is enabled, the most recent full backup set is returned.", "", false, "false", "False" ], [ "LastDiff", "If this switch is enabled, the most recent differential backup set is returned.", "", false, "false", "False" ], [ "LastLog", "If this switch is enabled, the most recent log backup is returned.", "", false, "false", "False" ], [ "DeviceType", "Specifies a filter for backup sets based on DeviceTypes. Valid options are \u0027Disk\u0027,\u0027Permanent Disk Device\u0027, \u0027Tape\u0027, \u0027Permanent Tape Device\u0027,\u0027Pipe\u0027,\u0027Permanent Pipe Device\u0027,\u0027Virtual Device\u0027, in addition \r\nto custom integers for your own DeviceTypes.", "", false, "false", "" ], [ "Raw", "If this switch is enabled, one object per backup file is returned. Otherwise, media sets (striped backups across multiple files) will be grouped into a single return object.", "", false, "false", "False" ], [ "LastLsn", "Specifies a minimum LSN to use in filtering backup history. Only backups with an LSN greater than this value will be returned, which helps speed the retrieval process.", "", false, "false", "" ], [ "Type", "Specifies one or more types of backups to return. Valid options are \u0027Full\u0027, \u0027Log\u0027, \u0027Differential\u0027, \u0027File\u0027, \u0027Differential File\u0027, \u0027Partial Full\u0027, and \u0027Partial Differential\u0027. Otherwise, all types of \r\nbackups will be returned unless one of the -Last* switches is enabled.", "", 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": "Chrissy LeMaire (@cl) | Stuart Moore (@napalmgram)", "Synopsis": "Returns backup history details for databases on a SQL Server.", "Name": "Get-DbaBackupHistory", "Links": "https://dbatools.io/Get-DbaBackupHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance SqlInstance2014a\nReturns server name, database, username, backup type, date for all database backups still in msdb history on SqlInstance2014a. This may return many rows; consider using filters that are included in \r\nother examples.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nGet-DbaBackupHistory -SqlInstance SqlInstance2014a -SqlCredential $cred\nDoes the same as above but connect to SqlInstance2014a as SQL user \"sqladmin\"\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance SqlInstance2014a -Database db1, db2 -Since \u00272016-07-01 10:47:00\u0027\nReturns backup information only for databases db1 and db2 on SqlInstance2014a since July 1, 2016 at 10:47 AM.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014, pubs -Force | Format-Table\nReturns information only for AdventureWorks2014 and pubs and formats the results as a table.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Last\nReturns information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Last -DeviceType Disk\nReturns information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014, but only for backups to disk.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Last -DeviceType 148,107\nReturns information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014, but only for backups with device_type 148 and 107.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -LastFull\nReturns information about the most recent full backup for AdventureWorks2014 on sql2014.\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Type Full\nReturns information about all Full backups for AdventureWorks2014 on sql2014.\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2016 | Get-DbaBackupHistory\nReturns database backup information for every database on every server listed in the Central Management Server on sql2016.\n-------------------------- EXAMPLE 11 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance SqlInstance2014a, sql2016 -Force\nReturns detailed backup history for all databases on SqlInstance2014a and sql2016.\n-------------------------- EXAMPLE 12 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2016 -Database db1 -RecoveryFork 38e5e84a-3557-4643-a5d5-eed607bef9c6 -Last\nIf db1 has multiple recovery forks, specifying the RecoveryFork GUID will restrict the search to that fork.", "Syntax": "Get-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Force] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Since \u003cDateTime\u003e] [-RecoveryFork \u003cString\u003e] [-Last] [-LastFull] [-LastDiff] [-LastLog] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaBackupInformation", "Description": "Upon being passed a list of potential backups files this command will scan the files, select those that contain SQL Server\nbackup sets. It will then filter those files down to a set\n\nThe function defaults to working on a remote instance. This means that all paths passed in must be relative to the remote instance.\nXpDirTree will be used to perform the file scans\n\nVarious means can be used to pass in a list of files to be considered. The default is to non recursively scan the folder\npassed in.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "Path", "Path to SQL Server backup files.\nPaths passed in as strings will be scanned using the desired method, default is a non recursive folder scan\r\nAccepts multiple paths separated by \u0027,\u0027\nOr it can consist of FileInfo objects, such as the output of Get-ChildItem or Get-Item. This allows you to work with\r\nyour own file structures as needed", "", true, "true (ByValue)", "" ], [ "SqlInstance", "The SQL Server instance to be used to read the headers of the backup files", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "", false, "false", "" ], [ "DatabaseName", "An array of Database Names to filter by. If empty all databases are returned.", "", false, "false", "" ], [ "SourceInstance", "If provided only backup originating from this destination will be returned. This SQL instance will not be connected to or involved in this work", "", false, "false", "" ], [ "NoXpDirTree", "If this switch is set, then Files will be parsed as locally files. This can cause failures if the running user can see files that the parsing SQL Instance cannot", "", false, "false", "False" ], [ "DirectoryRecurse", "If specified the provided path/directory will be traversed (only applies if not using XpDirTree)", "", false, "false", "False" ], [ "EnableException", "Replaces user friendly yellow warnings with bloody red exceptions of doom!\r\nUse this if you want the function to throw terminating errors you want to catch.", "", false, "false", "False" ], [ "MaintenanceSolution", "This switch tells the function that the folder is the root of a Ola Hallengren backup folder", "", false, "false", "False" ], [ "IgnoreLogBackup", "This switch only works with the MaintenanceSolution switch. With an Ola Hallengren style backup we can be sure that the LOG folder contains only log backups and skip it.\r\nFor all other scenarios we need to read the file headers to be sure.", "", false, "false", "False" ], [ "ExportPath", "If specified the output will export via CliXml format to the specified file. This allows you to store the backup history object for later usage, or move it between computers", "", false, "false", "" ], [ "AzureCredential", "The name of the SQL Server credential to be used if restoring from an Azure hosted backup", "", false, "false", "" ], [ "Import", "When specified along with a path the command will import a previously exported BackupHistory object from an xml file.", "", false, "false", "False" ], [ "Anonymise", "If specified we will output the results with ComputerName, InstanceName, Database, UserName, and Paths hashed out\r\nThis options is mainly for use if we need you to submit details for fault finding to the dbatools team", "Anonymize", false, "false", "False" ], [ "NoClobber", "If specified will stop Export from overwriting an existing file, the default is to overwrite", "", false, "false", "False" ], [ "PassThru", "When data is exported the cmdlet will return no other output, this switch means it will also return the normal output which can be then piped into another command", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl) | Stuart Moore (@napalmgram)", "Synopsis": "Scan backup files and creates a set, compatible with Restore-DbaDatabase", "Name": "Get-DbaBackupInformation", "Links": "https://dbatools.io/Get-DbaBackupInformation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaBackupInformation -SqlInstance Server1 -Path c:\\backups\\ -DirectoryRecurse\nWill use the Server1 instance to recursively read all backup files under c:\\backups, and return a dbatools BackupHistory object\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaBackupInformation -SqlInstance Server1 -Path c:\\backups\\ -DirectoryRecurse -ExportPath c:\\store\\BackupHistory.xml\nPS C:\\\u003e robocopy c:\\store\\ \\\\remoteMachine\\C$\\store\\ BackupHistory.xml\r\nPS C:\\\u003e Get-DbaBackupInformation -Import -Path c:\\store\\BackupHistory.xml | Restore-DbaDatabase -SqlInstance Server2 -TrustDbBackupHistory\nThis example creates backup history output from server1 and copies the file to the remote machine in order to preserve backup history. It is then used to restore the databases onto server2.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaBackupInformation -SqlInstance Server1 -Path c:\\backups\\ -DirectoryRecurse -ExportPath C:\\store\\BackupHistory.xml -PassThru | Restore-DbaDatabase -SqlInstance Server2 \r\n-TrustDbBackupHistory\nIn this example we gather backup information, export it to an xml file, and then pass it on through to Restore-DbaDatabase.\r\nThis allows us to repeat the restore without having to scan all the backup files again\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-ChildItem c:\\backups\\ -recurse -files | Where-Object {$_.extension -in (\u0027.bak\u0027,\u0027.trn\u0027) -and $_.LastWriteTime -gt (get-date).AddMonths(-1)} | Get-DbaBackupInformation -SqlInstance Server1 \r\n-ExportPath C:\\backupHistory.xml\nThis lets you keep a record of all backup history from the last month on hand to speed up refreshes\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\network\\backups\nPS C:\\\u003e $Backups += Get-DbaBackupInformation -SqlInstance Server2 -NoXpDirTree -Path c:\\backups\nScan the unc folder \\\\network\\backups with Server1, and then scan the C:\\backups folder on\r\nServer2 not using xp_dirtree, adding the results to the first set.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\network\\backups -MaintenanceSolution\nWhen MaintenanceSolution is indicated we know we are dealing with the output from Ola Hallengren backup scripts. So we make sure that a FULL folder exists in the first level of Path, if not we \r\nshortcut scanning all the files as we have nothing to work with\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\network\\backups -MaintenanceSolution -IgnoreLogBackup\nAs we know we are dealing with an Ola Hallengren style backup folder from the MaintenanceSolution switch, when IgnoreLogBackup is also included we can ignore the LOG folder to skip any scanning of \r\nlog backups. Note this also means they WON\u0027T be restored", "Syntax": "Get-DbaBackupInformation -Path \u003cObject[]\u003e -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-DatabaseName \u003cString[]\u003e] [-SourceInstance \u003cString[]\u003e] [-NoXpDirTree] [-DirectoryRecurse] [-EnableException] [-MaintenanceSolution] [-IgnoreLogBackup] [-ExportPath \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-Anonymise] [-NoClobber] [-PassThru] [\u003cCommonParameters\u003e]\nGet-DbaBackupInformation -Path \u003cObject[]\u003e [-DatabaseName \u003cString[]\u003e] [-SourceInstance \u003cString[]\u003e] [-EnableException] [-MaintenanceSolution] [-IgnoreLogBackup] [-ExportPath \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-Import] [-Anonymise] [-NoClobber] [-PassThru] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaBuildReference", "Description": "Returns info about the specific build of a SQL instance, including the SP, the CU and the reference KB, wherever possible.\nIt also includes End Of Support dates as specified on Microsoft Life Cycle Policy", "Tags": "SqlBuild", "Params": [ [ "Build", "Instead of connecting to a real instance, pass a string identifying the build to get the info back.", "", false, "false", "" ], [ "SqlInstance", "Target any number of instances, in order to return their build state.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "When connecting to an instance, use the credentials specified.", "Credential", false, "false", "" ], [ "Update", "Looks online for the most up to date reference, replacing the local one.", "", 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": "Get-DbaSqlBuildReference", "Author": "Simone Bizzotto (@niphold) | Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Returns SQL Server Build infos on a SQL instance", "Name": "Get-DbaBuildReference", "Links": "https://dbatools.io/Get-DbaBuildReference", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaBuildReference -Build \"12.00.4502\"\nReturns information about a build identified by \"12.00.4502\" (which is SQL 2014 with SP1 and CU11)\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaBuildReference -Build \"12.00.4502\" -Update\nReturns information about a build trying to fetch the most up to date index online. When the online version is newer, the local one gets overwritten\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaBuildReference -Build \"12.0.4502\",\"10.50.4260\"\nReturns information builds identified by these versions strings\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a | Get-DbaBuildReference\nIntegrate with other cmdlets to have builds checked for all your registered servers on sqlserver2014a", "Syntax": "Get-DbaBuildReference [[-Build] \u003cVersion[]\u003e] [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Update] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaClientAlias", "Description": "Gets SQL Server alias by reading HKLM:\\SOFTWARE\\Microsoft\\MSSQLServer\\Client", "Tags": "Alias", "Params": [ [ "ComputerName", "The target computer where the alias has been created", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to remote computers using alternative credentials", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets any SQL Server alias for the specified server(s)", "Name": "Get-DbaClientAlias", "Links": "https://dbatools.io/Get-DbaClientAlias", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaClientAlias\nGets all SQL Server client aliases on the local computer\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaClientAlias -ComputerName workstationx\nGets all SQL Server client aliases on Workstationx\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaClientAlias -ComputerName workstationx -Credential ad\\sqldba\nLogs into workstationx as ad\\sqldba then retrieves all SQL Server client aliases on Workstationx\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027Server1\u0027, \u0027Server2\u0027 | Get-DbaClientAlias\nGets all SQL Server client aliases on Server1 and Server2", "Syntax": "Get-DbaClientAlias [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaClientProtocol", "Description": "Gets the SQL Server related client protocols on one or more computers.\n\nRequires Local Admin rights on destination computer(s).\nThe client protocols can be enabled and disabled when retrieved via WSMan.", "Tags": "Protocol", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Gets the SQL Server related client protocols on a computer.", "Name": "Get-DbaClientProtocol", "Links": "https://dbatools.io/Get-DbaClientProtocol", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaClientProtocol -ComputerName sqlserver2014a\nGets the SQL Server related client protocols on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaClientProtocol\nGets the SQL Server related client protocols on computers sql1, sql2 and sql3.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaClientProtocol -ComputerName sql1,sql2 | Out-GridView\nGets the SQL Server related client protocols on computers sql1 and sql2, and shows them in a grid view.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e(Get-DbaClientProtocol -ComputerName sql2 | Where { $_.DisplayName = \u0027via\u0027 }).Disable()\nDisables the VIA ClientNetworkProtocol on computer sql2.\r\nIf successful, return code 0 is shown.", "Syntax": "Get-DbaClientProtocol [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCmConnection", "Description": "Retrieves windows management connections from the cache", "Tags": [ "ComputerManagement", "CIM" ], "Params": [ [ "ComputerName", "The computername to ComputerName for.", "Filter", false, "true (ByValue)", "*" ], [ "UserName", "Username on credentials to look for. Will not find connections using the default windows credentials.", "", 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": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Retrieves windows management connections from the cache", "Name": "Get-DbaCmConnection", "Links": "https://dbatools.io/Get-DbaCmConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCmConnection\nList all cached connections.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmConnection sql2014\nList the cached connection - if any - to the server sql2014.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmConnection -UserName \"*charles*\"\nList all cached connection that use a username containing \"charles\" as default or override credentials.", "Syntax": "Get-DbaCmConnection [[-ComputerName] \u003cString[]\u003e] [-UserName \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCmObject", "Description": "This function centralizes all requests for information retrieved from Get-WmiObject or Get-CimInstance.\nIt uses different protocols as available in this order:\n- Cim over WinRM\n- Cim over DCOM\n- Wmi\n- Wmi over PowerShell Remoting\nIt remembers channels that didn\u0027t work and will henceforth avoid them. It remembers invalid credentials and will avoid reusing them.\nMuch of its behavior can be configured using Test-DbaCmConnection.", "Tags": [ "ComputerManagement", "CIM" ], "Params": [ [ "ClassName", "The name of the class to retrieve.", "Class", true, "false", "" ], [ "Query", "The Wmi/Cim query tu run against the server.", "", true, "false", "" ], [ "ComputerName", "The computer(s) to connect to. Defaults to localhost.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credentials to use. Invalid credentials will be stored in a credentials cache and not be reused.", "", false, "false", "" ], [ "Namespace", "The namespace of the class to use.", "", false, "false", "root\\cimv2" ], [ "DoNotUse", "Connection Protocols that should not be used.", "", false, "false", "None" ], [ "Force", "Overrides some checks that might otherwise halt execution as a precaution\r\n- Ignores timeout on bad connections", "", false, "false", "False" ], [ "SilentlyContinue", "Use in conjunction with the -EnableException switch.\r\nBy default, Get-DbaCmObject will throw a terminating exception when connecting to a target is impossible in exception enabled mode.\r\nSetting this switch will cause it write a non-terminating exception and continue with the next computer.", "", 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": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Retrieves Wmi/Cim-Style information from computers.", "Name": "Get-DbaCmObject", "Links": "https://dbatools.io/Get-DbaCmObject", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCmObject win32_OperatingSystem\nRetrieves the common operating system information from the local computer.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmObject -Computername \"sql2014\" -ClassName Win32_OperatingSystem -Credential $cred -DoNotUse CimRM\nRetrieves the common operating system information from the server sql2014.\r\nIt will use the Credentials stored in $cred to connect, unless they are known to not work, in which case they will default to windows credentials (unless another default has been set).", "Syntax": "Get-DbaCmObject [-ClassName] \u003cString\u003e [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-Namespace \u003cString\u003e] [-DoNotUse {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-Force] [-SilentlyContinue] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaCmObject [-Query] \u003cString\u003e [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-Namespace \u003cString\u003e] [-DoNotUse {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-Force] [-SilentlyContinue] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCmsRegServer", "Description": "Returns an array of servers found in the CMS.", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Name", "Specifies one or more names to include. Name is the visible name in SSMS CMS interface (labeled Registered Server Name)", "", false, "false", "" ], [ "ServerName", "Specifies one or more server names to include. Server Name is the actual instance name (labeled Server Name)", "", false, "false", "" ], [ "Group", "Specifies one or more groups to include from SQL Server Central Management Server.", "Groups", false, "false", "" ], [ "ExcludeGroup", "Specifies one or more Central Management Server groups to exclude.", "", false, "false", "" ], [ "Id", "Get server by Id(s)", "", false, "false", "" ], [ "IncludeSelf", "If this switch is enabled, the CMS server itself will be included in the results, along with all other Registered Servers.", "", false, "false", "False" ], [ "ExcludeCmsServer", "Deprecated, now follows the Microsoft convention of not including it by default. If you\u0027d like to include the CMS Server, use -IncludeSelf", "", false, "false", "False" ], [ "ResolveNetworkName", "If this switch is enabled, the NetBIOS name and IP address(es) of each server will be returned.", "", false, "false", "False" ], [ "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.", "Silent", false, "false", "False" ] ], "Alias": "Get-DbaCmsRegServerName,Get-DbaRegisteredServer,Get-SqlRegisteredServerName", "Author": "Bryan Hamby (@galador)", "Synopsis": "Gets list of SQL Server objects stored in SQL Server Central Management Server (CMS).", "Name": "Get-DbaCmsRegServer", "Links": "https://dbatools.io/Get-DbaCmsRegServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a\nGets a list of servers from the CMS on sqlserver2014a, using Windows Credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a -IncludeSelf\nGets a list of servers from the CMS on sqlserver2014a and includes sqlserver2014a in the output results.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a -SqlCredential $credential | Select-Object -Unique -ExpandProperty ServerName\nReturns only the server names from the CMS on sqlserver2014a, using SQL Authentication to authenticate to the server.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a -Group HR, Accounting\nGets a list of servers in the HR and Accounting groups from the CMS on sqlserver2014a.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a -Group HR\\Development\nReturns a list of servers in the HR and sub-group Development from the CMS on sqlserver2014a.", "Syntax": "Get-DbaCmsRegServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-Group] \u003cObject[]\u003e] [[-ExcludeGroup] \u003cObject[]\u003e] [[-Id] \u003cInt32[]\u003e] [-IncludeSelf] [-ExcludeCmsServer] [-ResolveNetworkName] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCmsRegServerGroup", "Description": "Returns an array of Server Groups found in the CMS.", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Group", "Specifies one or more groups to include from SQL Server Central Management Server.", "", false, "false", "" ], [ "ExcludeGroup", "Specifies one or more Central Management Server groups to exclude.", "", false, "false", "" ], [ "Id", "Get group by Id(s). This parameter only works if the group has a registered server in it.", "", false, "false", "" ], [ "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": "Get-DbaRegisteredServerGroup", "Author": "Tony Wilhelm (@tonywsql)", "Synopsis": "Gets list of Server Groups objects stored in SQL Server Central Management Server (CMS).", "Name": "Get-DbaCmsRegServerGroup", "Links": "https://dbatools.io/Get-DbaCmsRegServerGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sqlserver2014a\nGets the top level groups from the CMS on sqlserver2014a, using Windows Credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sqlserver2014a -SqlCredential $credential\nGets the top level groups from the CMS on sqlserver2014a, using alternative credentials to authenticate to the server.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sqlserver2014a -Group HR, Accounting\nGets the HR and Accounting groups from the CMS on sqlserver2014a.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sqlserver2014a -Group HR\\Development\nReturns the sub-group Development of the HR group from the CMS on sqlserver2014a.", "Syntax": "Get-DbaCmsRegServerGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Group] \u003cObject[]\u003e] [[-ExcludeGroup] \u003cObject[]\u003e] [[-Id] \u003cInt32[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCmsRegServerStore", "Description": "Returns a SQL Server Registered Server Store object - useful for working with Central Management Store", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple 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", "" ], [ "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": "Get-DbaRegisteredServerStore", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns a SQL Server Registered Server Store Object", "Name": "Get-DbaCmsRegServerStore", "Links": "https://dbatools.io/Get-DbaCmsRegServerStore", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerStore -SqlInstance sqlserver2014a\nReturns a SQL Server Registered Server Store Object from sqlserver2014a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerStore -SqlInstance sqlserver2014a -SqlCredential sqladmin\nReturns a SQL Server Registered Server Store Object from sqlserver2014a by logging in with the sqladmin login", "Syntax": "Get-DbaCmsRegServerStore [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaComputerCertificate", "Description": "Gets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption", "Tags": "Certificate", "Params": [ [ "ComputerName", "The target SQL Server instance or instances. Defaults to localhost. If target is a cluster, you must specify the distinct nodes.", "ServerInstance,SqlServer,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative credentials.", "", false, "false", "" ], [ "Store", "Certificate store - defaults to LocalMachine", "", false, "false", "LocalMachine" ], [ "Folder", "Certificate folder - defaults to My (Personal)", "", false, "false", "My" ], [ "Path", "The path to a certificate - basically changes the path into a certificate object", "", false, "false", "" ], [ "Thumbprint", "Return certificate based on thumbprint", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Simplifies finding computer certificates that are candidates for using with SQL Server\u0027s network encryption", "Name": "Get-DbaComputerCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaComputerCertificate\nGets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaComputerCertificate -ComputerName sql2016\nGets computer certificates on sql2016 that are candidates for using with SQL Server\u0027s network encryption\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaComputerCertificate -ComputerName sql2016 -Thumbprint 8123472E32AB412ED4288888B83811DB8F504DED, 04BFF8B3679BB01A986E097868D8D494D70A46D6\nGets computer certificates on sql2016 that match thumbprints 8123472E32AB412ED4288888B83811DB8F504DED or 04BFF8B3679BB01A986E097868D8D494D70A46D6", "Syntax": "Get-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] [[-Path] \u003cString\u003e] [[-Thumbprint] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaComputerSystem", "Description": "Gets computer system information from the server and returns as an object.", "Tags": "ServerInfo", "Params": [ [ "ComputerName", "Target computer(s). If no computer name is specified, the local computer is targeted", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Alternate credential object to use for accessing the target computer(s).", "", false, "false", "" ], [ "IncludeAws", "If computer is hosted in AWS Infrastructure as a Service (IaaS), additional information will be included.", "", 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": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Gets computer system information from the server.", "Name": "Get-DbaComputerSystem", "Links": "https://dbatools.io/Get-DbaComputerSystem", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaComputerSystem\nReturns information about the local computer\u0027s computer system\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaComputerSystem -ComputerName sql2016\nReturns information about the sql2016\u0027s computer system\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaComputerSystem -ComputerName sql2016 -IncludeAws\nReturns information about the sql2016\u0027s computer system and includes additional properties around the EC2 instance.", "Syntax": "Get-DbaComputerSystem [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-IncludeAws] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaConnection", "Description": "Returns a bunch of information from dm_exec_connections which, according to Microsoft:\n\"Returns information about the connections established to this instance of SQL Server and the details of each connection. Returns server wide connection information for SQL Server. Returns current database connection information for SQL Database.\"", "Tags": "Connection", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server(s) must be SQL Server 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)", "Credential,Cred", 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": "Returns a bunch of information from dm_exec_connections.", "Name": "Get-DbaConnection", "Links": "https://dbatools.io/Get-DbaConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaConnection -SqlInstance sql2016, sql2017\nReturns client connection information from sql2016 and sql2017", "Syntax": "Get-DbaConnection [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCpuRingBuffer", "Description": "This command is based off of Glen Berry\u0027s diagnostic query for average CPU\n\nThe sys.dm_os_ring_buffers stores the average CPU utilization history\nby the current instance of SQL Server, plus the summed average CPU utilization\nby all other processes on your machine are captured in one minute increments\nfor the past 256 minutes.\n\nReference: https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-detailed-day-16//", "Tags": "CPU", "Params": [ [ "SqlInstance", "Allows you to specify a comma separated list of servers to query.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted. To use:\r\n$cred = Get-Credential, this pass this $cred to the param.\nWindows Authentication will be used if DestinationSqlCredential is not specified. To connect as a different Windows user, run PowerShell as that user.", "", false, "false", "" ], [ "CollectionMinutes", "Allows you to specify a Collection Period in Minutes. Default is 60 minutes", "", false, "false", "60" ], [ "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": "Patrick Flynn (@sqllensman)", "Synopsis": "Collects CPU data from sys.dm_os_ring_buffers. Works on SQL Server 2005 and above.", "Name": "Get-DbaCpuRingBuffer", "Links": "https://dbatools.io/Get-DbaCpuRingBuffer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCpuRingBuffer -SqlInstance sql2008, sqlserver2012\nGets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012 for last 60 minutes.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240\nGets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$output = Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240 | Select * | ConvertTo-DbaDataTable\nGets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes into a Data Table.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027sql2008\u0027,\u0027sql2012\u0027 | Get-DbaCpuRingBuffer\nGets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaCpuRingBuffer -SqlInstance sql2008 -SqlCredential $cred\nConnects using sqladmin credential and returns CPU Statistics from sys.dm_os_ring_buffers from sql2008", "Syntax": "Get-DbaCpuRingBuffer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-CollectionMinutes] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCpuUsage", "Description": "\"If there are a lot of processes running on your instance and the CPU is very high,\nthen it\u0027s hard to find the exact process eating up your CPU using just the SQL Server\ntools. One way to correlate the data between what is running within SQL Server and at\nthe Windows level is to use SPID and KPID values to get the exact process.\"\n\nThis command automates that process.\n\nReferences: https://www.mssqltips.com/sqlservertip/2454/how-to-find-out-how-much-cpu-a-sql-server-process-is-really-using/\n\nNote: This command returns results from all SQL instances on the destination server but the process\ncolumn is specific to -SqlInstance passed.", "Tags": "CPU", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to the SQL instance using alternative credentials.", "", false, "false", "" ], [ "Credential", "Allows you to login to the Windows Server using alternative credentials.", "", false, "false", "" ], [ "Threshold", "CPU threshold.", "", false, "false", "0" ], [ "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": "Provides detailed CPU usage information about a SQL Server\u0027s process", "Name": "Get-DbaCpuUsage", "Links": "https://dbatools.io/Get-DbaCpuUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCpuUsage -SqlInstance sql2017\nLogs into the SQL Server instance \"sql2017\" and also the Computer itself (via WMI) to gather information\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$usage = Get-DbaCpuUsage -SqlInstance sql2017\nPS C:\\\u003e $usage.Process\nExplores the processes (from Get-DbaProcess) associated with the usage results\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCpuUsage -SqlInstance sql2017 -SqlCredential sqladmin -Credential ad\\sqldba\nLogs into the SQL instance using the SQL Login \u0027sqladmin\u0027 and then Windows instance as \u0027ad\\sqldba\u0027", "Syntax": "Get-DbaCpuUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Threshold] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCredential", "Description": "The Get-DbaCredential command gets SQL Credential information for each instance(s) of SQL Server.", "Tags": "Credential", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "Only include specific names\r\nNote: if spaces exist in the credential name, you will have to type \"\" or \u0027\u0027 around it.", "", false, "false", "" ], [ "ExcludeName", "Excluded credential names", "", false, "false", "" ], [ "Identity", "Only include specific identities\r\nNote: if spaces exist in the credential identity, you will have to type \"\" or \u0027\u0027 around it.", "CredentialIdentity", false, "false", "" ], [ "ExcludeIdentity", "Excluded identities", "ExcludeCredentialIdentity", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Credential information for each instance(s) of SQL Server.", "Name": "Get-DbaCredential", "Links": "https://dbatools.io/Get-DbaCredential", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCredential -SqlInstance localhost\nReturns all SQL Credentials on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCredential -SqlInstance localhost, sql2016 -Name \u0027PowerShell Proxy\u0027\nReturns the SQL Credentials named \u0027PowerShell Proxy\u0027 for the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCredential -SqlInstance localhost, sql2016 -Identity ad\\powershell\nReturns the SQL Credentials for the account \u0027ad\\powershell\u0027 on the local and sql2016 SQL Server instances", "Syntax": "Get-DbaCredential [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Name \u003cString[]\u003e] [-ExcludeName \u003cString[]\u003e] [-Identity \u003cString[]\u003e] [-ExcludeIdentity \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaCustomError", "Description": "The Get-DbaCustomError command gets SQL Custom Error Message information for each instance(s) of SQL Server.", "Tags": [ "Error", "CustomError" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Custom Error Message information for each instance(s) of SQL Server.", "Name": "Get-DbaCustomError", "Links": "https://dbatools.io/Get-DbaCustomError", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCustomError -SqlInstance localhost\nReturns all Custom Error Message(s) on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCustomError -SqlInstance localhost, sql2016\nReturns all Custom Error Message(s) for the local and sql2016 SQL Server instances", "Syntax": "Get-DbaCustomError [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDatabase", "Description": "The Get-DbaDatabase command gets SQL database information for each database that is present on the target instance(s) of\nSQL Server. If the name of the database is provided, the command will return only the specific database information.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "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", "" ], [ "Database", "Specifies one or more database(s) to process. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Specifies one or more database(s) to exclude from processing.", "", false, "false", "" ], [ "ExcludeAllUserDb", "If this switch is enabled, only databases which are not User databases will be processed.\nThis parameter cannot be used with -ExcludeAllSystemDb.", "SystemDbOnly,NoUserDb", false, "false", "False" ], [ "ExcludeAllSystemDb", "If this switch is enabled, only databases which are not System databases will be processed.\nThis parameter cannot be used with -ExcludeAllUserDb.", "UserDbOnly,NoSystemDb", false, "false", "False" ], [ "Owner", "Specifies one or more database owners. Only databases owned by the listed owner(s) will be returned.", "", false, "false", "" ], [ "Encrypted", "If this switch is enabled, only databases which have Transparent Data Encryption (TDE) enabled will be returned.", "", false, "false", "False" ], [ "Status", "Specifies one or more database statuses to filter on. Only databases in the status(es) listed will be returned. Valid options for this parameter are \u0027Emergency\u0027, \u0027Normal\u0027, \u0027Offline\u0027, \u0027Recovering\u0027, \r\n\u0027Restoring\u0027, \u0027Standby\u0027, and \u0027Suspect\u0027.", "", false, "false", "@(\u0027EmergencyMode\u0027, \u0027Normal\u0027, \u0027Offline\u0027, \u0027Recovering\u0027, \u0027Restoring\u0027, \u0027Standby\u0027, \u0027Suspect\u0027)" ], [ "Access", "Filters databases returned by their access type. Valid options for this parameter are \u0027ReadOnly\u0027 and \u0027ReadWrite\u0027. If omitted, no filtering is performed.", "", false, "false", "" ], [ "RecoveryModel", "Filters databases returned by their recovery model. Valid options for this parameter are \u0027Full\u0027, \u0027Simple\u0027, and \u0027BulkLogged\u0027.", "", false, "false", "@(\u0027Full\u0027, \u0027Simple\u0027, \u0027BulkLogged\u0027)" ], [ "NoFullBackup", "If this switch is enabled, only databases without a full backup recorded by SQL Server will be returned. This will also indicate which of these databases only have CopyOnly full backups.", "", false, "false", "False" ], [ "NoFullBackupSince", "Only databases which haven\u0027t had a full backup since the specified DateTime will be returned.", "", false, "false", "" ], [ "NoLogBackup", "If this switch is enabled, only databases without a log backup recorded by SQL Server will be returned. This will also indicate which of these databases only have CopyOnly log backups.", "", false, "false", "False" ], [ "NoLogBackupSince", "Only databases which haven\u0027t had a log backup since the specified DateTime will be returned.", "", 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" ], [ "IncludeLastUsed", "If this switch is enabled, the last used read \u0026 write times for each database will be returned. This data is retrieved from sys.dm_db_index_usage_stats which is reset when SQL Server is restarted.", "", false, "false", "False" ], [ "OnlyAccessible", "If this switch is enabled, only accessible databases are returned (huge speedup in SMO enumeration)", "", false, "false", "False" ] ], "Alias": "", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com | Klaas Vandenberghe (@PowerDbaKlaas) | Simone Bizzotto ( @niphlod )", "Synopsis": "Gets SQL Database information for each database that is present on the target instance(s) of SQL Server.", "Name": "Get-DbaDatabase", "Links": "https://dbatools.io/Get-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance localhost\nReturns all databases on the local default SQL Server instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance localhost -ExcludeAllUserDb\nReturns only the system databases on the local default SQL Server instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance localhost -ExcludeAllSystemDb\nReturns only the user databases on the local default SQL Server instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027localhost\u0027,\u0027sql2016\u0027 | Get-DbaDatabase\nReturns databases on multiple instances piped into the function.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress -RecoveryModel full,Simple\nReturns only the user databases in Full or Simple recovery model from SQL Server instance SQL1\\SQLExpress.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress -Status Normal\nReturns only the user databases with status \u0027normal\u0027 from SQL Server instance SQL1\\SQLExpress.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress -IncludeLastUsed\nReturns the databases from SQL Server instance SQL1\\SQLExpress and includes the last used information\r\nfrom the sys.dm_db_index_usage_stats DMV.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress,SQL2 -ExcludeDatabase model,master\nReturns all databases except master and model from SQL Server instances SQL1\\SQLExpress and SQL2.\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress,SQL2 -Encrypted\nReturns only databases using TDE from SQL Server instances SQL1\\SQLExpress and SQL2.\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress,SQL2 -Access ReadOnly\nReturns only read only databases from SQL Server instances SQL1\\SQLExpress and SQL2.\n-------------------------- EXAMPLE 11 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL2,SQL3 -Database OneDB,OtherDB\nReturns databases \u0027OneDb\u0027 and \u0027OtherDB\u0027 from SQL Server instances SQL2 and SQL3 if databases by those names exist on those instances.", "Syntax": "Get-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-ExcludeAllUserDb] [-ExcludeAllSystemDb] [-Owner \u003cString[]\u003e] [-Encrypted] [-Status \u003cString[]\u003e] [-Access \u003cString\u003e] [-RecoveryModel \u003cString[]\u003e] [-NoFullBackup] [-NoFullBackupSince \u003cDateTime\u003e] [-NoLogBackup] [-NoLogBackupSince \u003cDateTime\u003e] [-EnableException] [-IncludeLastUsed] [-OnlyAccessible] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbAssembly", "Description": "The Get-DbaDbAssembly command gets SQL Database Assembly information for each instance(s) of SQL Server.", "Tags": [ "Assembly", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Get-DbaDatabaseAssembly", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Database Assembly information for each instance(s) of SQL Server.", "Name": "Get-DbaDbAssembly", "Links": "https://dbatools.io/Get-DbaDbAssembly", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbAssembly -SqlInstance localhost\nReturns all Database Assembly on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbAssembly -SqlInstance localhost, sql2016\nReturns all Database Assembly for the local and sql2016 SQL Server instances", "Syntax": "Get-DbaDbAssembly [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbCertificate", "Description": "Gets database certificates", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "Get certificate from specific database", "", false, "false", "" ], [ "ExcludeDatabase", "Database(s) to ignore when retrieving certificates", "", false, "false", "" ], [ "Certificate", "Get specific certificate by name", "", false, "false", "" ], [ "Subject", "sometimes it\u0027s text, other times cert", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", 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": "Get-DbaDatabaseCertificate", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets database certificates", "Name": "Get-DbaDbCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance sql2016\nGets all certificates\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance Server1 -Database db1\nGets the certificate for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance Server1 -Database db1 -Certificate cert1\nGets the cert1 certificate within the db1 database\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance Server1 -Database db1 -Subject \u0027Availability Group Cert\u0027\nGets the cert1 certificate within the db1 database", "Syntax": "Get-DbaDbCertificate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Certificate] \u003cObject[]\u003e] [[-Subject] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbCheckConstraint", "Description": "Gets database Checks constraints.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get Checks from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", false, "false", "" ], [ "ExcludeSystemTable", "This switch removes all system objects from the table collection", "", 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": "Claudio Silva (@ClaudioESSilva), https://claudioessilva.eu", "Synopsis": "Gets database Check constraints.", "Name": "Get-DbaDbCheckConstraint", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance sql2016\nGets all database check constraints.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance Server1 -Database db1\nGets the check constraints for the db1 database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance Server1 -ExcludeDatabase db1\nGets the check constraints for all databases except db1.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance Server1 -ExcludeSystemTable\nGets the check constraints for all databases that are not system objects.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbCheckConstraint\nGets the check constraints for the databases on Sql1 and Sql2/sqlexpress.", "Syntax": "Get-DbaDbCheckConstraint [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemTable] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbCompatibility", "Description": "Get the current database compatibility level for all databases on a server or list of databases passed in to the function.", "Tags": [ "Compatibility", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "", false, "false", "" ], [ "Database", "The database or databases to process. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase)", "", 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": "Garry Bargsley, http://blog.garrybargsley.com/", "Synopsis": "Displays the compatibility level for SQL Server databases.", "Name": "Get-DbaDbCompatibility", "Links": "https://dbatools.io/Get-DbaDbCompatibility", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbCompatibility -SqlInstance localhost\\sql2017\nDisplays database compatibility level for all user databases on server localhost\\sql2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbCompatibility -SqlInstance localhost\\sql2017 -Database Test\nDisplays database compatibility level for database Test on server localhost\\sql2017", "Syntax": "Get-DbaDbCompatibility [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbCompression", "Description": "This function gets the current size and compression for all objects in the specified database(s), if no database is specified it will return all objects in all user databases.", "Tags": [ "Compression", "Table", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "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", "" ], [ "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": "Jess Pomfret (@jpomfret), jesspomfret.com", "Synopsis": "Gets tables and indexes size and current compression settings.", "Name": "Get-DbaDbCompression", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbCompression -SqlInstance localhost\nReturns objects size and current compression level for all user databases.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbCompression -SqlInstance localhost -Database TestDatabase\nReturns objects size and current compression level for objects within the TestDatabase database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbCompression -SqlInstance localhost -ExcludeDatabase TestDatabases\nReturns objects size and current compression level for objects in all databases except the TestDatabase database.", "Syntax": "Get-DbaDbCompression [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbEncryption", "Description": "Shows if a database has Transparent Data Encryption (TDE), any certificates, asymmetric keys or symmetric keys with details for each.", "Tags": [ "Encryption", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input.", "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", "" ], [ "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", "" ], [ "IncludeSystemDBs", "Switch parameter that when used will display system database information.", "", 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": "Get-DbaDatabaseEncryption", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Returns a summary of encryption used on databases passed to it.", "Name": "Get-DbaDbEncryption", "Links": "https://dbatools.io/Get-DbaDbEncryption", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01\nList all encryption found on the instance by database\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01 -Database MyDB\nList all encryption found for the MyDB database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01 -ExcludeDatabase MyDB\nList all encryption found for all databases except MyDB.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01 -IncludeSystemDBs\nList all encryption found for all databases including the system databases.", "Syntax": "Get-DbaDbEncryption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbExtentDiff", "Description": "This is only an implementation of the script created by Paul S. Randal to find what percentage of a database has changed since the last full backup.\nhttps://www.sqlskills.com/blogs/paul/new-script-how-much-of-the-database-has-changed-since-the-last-full-backup/", "Tags": [ "Backup", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "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", "" ], [ "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", "" ], [ "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": "Viorel Ciucu, cviorel.com", "Synopsis": "What percentage of a database has changed since the last full backup", "Name": "Get-DbaDbExtentDiff", "Links": "http://dbatools.io/Get-DbaDbExtentDiff", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbExtentDiff -SqlInstance SQL2016 -Database DBA\nGet the changes for the DBA database.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$Cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaDbExtentDiff -SqlInstance SQL2017N1, SQL2017N2, SQL2016 -Database DB01 -SqlCredential $Cred\nGet the changes for the DB01 database on multiple servers.", "Syntax": "Get-DbaDbExtentDiff [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbFeatureUsage", "Description": "Shows features that are enabled in the database but not supported on all editions of SQL Server.\n\nBasically checks for Enterprise feature usage.\n\nThis feature must be removed before the database can be migrated to all available editions of SQL Server.", "Tags": "Deprecated", "Params": [ [ "SqlInstance", "The target SQL Server instance", "ServerInstance,SqlServer,SqlServers", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-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", "" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase), to be tested.", "", 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": "Brandon Abshire, netnerds.net", "Synopsis": "Shows features that are enabled in the database but not supported on all editions of SQL Server. Basically checks for Enterprise feature usage.", "Name": "Get-DbaDbFeatureUsage", "Links": "https://dbatools.io/Get-DbaDbFeatureUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2008 -Database testdb, db2 | Get-DbaDbFeatureUsage\nShows features that are enabled in the testdb and db2 databases but\r\nnot supported on the all the editions of SQL Server.", "Syntax": "Get-DbaDbFeatureUsage [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbFile", "Description": "Returns detailed information about database files. Does not use SMO - SMO causes enumeration and this command avoids that.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Credentials to connect to the SQL Server instance if the calling user doesn\u0027t have permission", "", 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", "" ], [ "InputObject", "A piped collection of database objects", "", 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": "Get-DbaDatabaseFile", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Returns detailed information about database files.", "Name": "Get-DbaDbFile", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbFile -SqlInstance sql2016\nWill return an object containing all file groups and their contained files for every database on the sql2016 SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbFile -SqlInstance sql2016 -Database Impromptu\nWill return an object containing all file groups and their contained files for the Impromptu Database on the sql2016 SQL Server instance\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbFile -SqlInstance sql2016 -Database Impromptu, Trading\nWill return an object containing all file groups and their contained files for the Impromptu and Trading databases on the sql2016 SQL Server instance", "Syntax": "Get-DbaDbFile [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-InputObject \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaDbFile -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-InputObject \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbForeignKey", "Description": "Gets database Foreign Keys.", "Tags": [ "Database", "ForeignKey", "Table" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get Foreign Keys from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", false, "false", "" ], [ "ExcludeSystemTable", "This switch removes all system objects from the tables collection", "", 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": "Claudio Silva (@ClaudioESSilva), https://claudioessilva.eu", "Synopsis": "Gets database Foreign Keys.", "Name": "Get-DbaDbForeignKey", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance sql2016\nGets all database Foreign Keys.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance Server1 -Database db1\nGets the Foreign Keys for the db1 database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance Server1 -ExcludeDatabase db1\nGets the Foreign Keys for all databases except db1.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance Server1 -ExcludeSystemTable\nGets the Foreign Keys from all tables that are not system objects from all databases.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbForeignKey\nGets the Foreign Keys for the databases on Sql1 and Sql2/sqlexpress.", "Syntax": "Get-DbaDbForeignKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemTable] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbLogShipError", "Description": "When your log shipping fails it\u0027s sometimes hard to see why is fails.\nUsing this function you\u0027ll be able to find out what went wrong in a short amount of time.", "Tags": "LogShipping", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Database", "Allows you to filter the results to only return the databases you\u0027re interested in. This can be one or more values separated by commas.\r\nThis is not a wildcard and should be the exact database name. See examples for more info.", "", false, "false", "" ], [ "ExcludeDatabase", "Allows you to filter the results to only return the databases you\u0027re not interested in. This can be one or more values separated by commas.\r\nThis is not a wildcard and should be the exact database name.", "", false, "false", "" ], [ "Action", "Filter to get the log shipping action that has occurred like Backup, Copy, Restore.\r\nBy default all the actions are returned.", "", false, "false", "" ], [ "DateTimeFrom", "Filter the results based on the date starting from datetime X", "", false, "false", "" ], [ "DateTimeTo", "Filter the results based on the date ending with datetime X", "", false, "false", "" ], [ "Primary", "Allows to filter the results to only return values that apply to the primary instance.", "", false, "false", "False" ], [ "Secondary", "Allows to filter the results to only return values that apply to the secondary instance.", "", 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": "Get-DbaLogShippingError", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Get-DbaDbLogShipError returns all the log shipping errors that occurred", "Name": "Get-DbaDbLogShipError", "Links": "https://dbatools.io/Get-DbaDbLogShipError", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbLogShipError -SqlInstance sql1\nGet all the log shipping errors that occurred\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbLogShipError -SqlInstance sql1 -Action Backup\nGet the errors that have something to do with the backup of the databases\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbLogShipError -SqlInstance sql1 -Secondary\nGet the errors that occurred on the secondary instance.\r\nThis will return the copy of the restore actions because those only occur on the secondary instance\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbLogShipError -SqlInstance sql1 -DateTimeFrom \"01/05/2018\"\nGet the errors that have occurred from \"01/05/2018\". This can also be of format \"yyyy-MM-dd\"\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDbLogShipError -SqlInstance sql1 -Secondary -DateTimeFrom \"01/05/2018\" -DateTimeTo \"2018-01-07\"\nGet the errors that have occurred between \"01/05/2018\" and \"01/07/2018\".\r\nSee that is doesn\u0027t matter how the date is represented.", "Syntax": "Get-DbaDbLogShipError [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Action] \u003cString[]\u003e] [[-DateTimeFrom] \u003cDateTime\u003e] [[-DateTimeTo] \u003cDateTime\u003e] [-Primary] [-Secondary] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMail", "Description": "Gets the database mail from SQL Server", "Tags": [ "DatabaseMail", "DBMail", "Mail" ], "Params": [ [ "SqlInstance", "TThe target SQL Server instance or 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)", "Credential", 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": "Gets the database mail from SQL Server", "Name": "Get-DbaDbMail", "Links": "https://dbatools.io/Get-DbaDbMail", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMail -SqlInstance sql01\\sharepoint\nReturns the db mail server object on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMail -SqlInstance sql01\\sharepoint | Select *\nReturns the db mail server object on sql01\\sharepoint then return a bunch more columns\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMail\nReturns the db mail server object for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMail [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMailAccount", "Description": "Gets database mail accounts from SQL Server", "Tags": [ "DatabaseMail", "DbMail", "Mail" ], "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)", "Credential", false, "false", "" ], [ "Account", "Specifies one or more account(s) to get. If unspecified, all accounts will be returned.", "", false, "false", "" ], [ "ExcludeAccount", "Specifies one or more account(s) to exclude.", "", false, "false", "" ], [ "InputObject", "Accepts pipeline input from Get-DbaDbMail", "", 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": "Gets database mail accounts from SQL Server", "Name": "Get-DbaDbMailAccount", "Links": "https://dbatools.io/Get-DbaDbMailAccount", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMailAccount -SqlInstance sql01\\sharepoint\nReturns Database Mail accounts on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMailAccount -SqlInstance sql01\\sharepoint -Account \u0027The DBA Team\u0027\nReturns The DBA Team Database Mail account from sql01\\sharepoint\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbMailAccount -SqlInstance sql01\\sharepoint | Select *\nReturns the Database Mail accounts on sql01\\sharepoint then return a bunch more columns\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMail | Get-DbaDbMailAccount\nReturns the Database Mail accounts for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMailAccount [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Account] \u003cString[]\u003e] [[-ExcludeAccount] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMailConfig", "Description": "Gets database mail configs from SQL Server", "Tags": [ "DatabaseMail", "DBMail", "Mail" ], "Params": [ [ "SqlInstance", "TThe 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)", "Credential", false, "false", "" ], [ "Name", "Specifies one or more config(s) to get. If unspecified, all configs will be returned.", "Config,ConfigName", false, "false", "" ], [ "InputObject", "Accepts pipeline input from Get-DbaDbMail", "", 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": "Gets database mail configs from SQL Server", "Name": "Get-DbaDbMailConfig", "Links": "https://dbatools.io/Get-DbaDbMailConfig", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMailConfig -SqlInstance sql01\\sharepoint\nReturns DBMail configs on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMailConfig -SqlInstance sql01\\sharepoint -Name ProhibitedExtensions\nReturns the ProhibitedExtensions configuration on sql01\\sharepoint\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbMailConfig -SqlInstance sql01\\sharepoint | Select *\nReturns the DBMail configs on sql01\\sharepoint then return a bunch more columns\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMail | Get-DbaDbMailConfig\nReturns the DBMail configs for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMailConfig [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMailHistory", "Description": "Gets the history of mail sent from a SQL instance", "Tags": [ "DatabaseMail", "DBMail", "Mail" ], "Params": [ [ "SqlInstance", "TThe target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "Credential", false, "false", "" ], [ "Since", "Datetime object used to narrow the results to the send request date", "", false, "false", "" ], [ "Status", "Narrow the results by status. Valid values include Unsent, Sent, Failed and Retrying", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the history of mail sent from a SQL instance", "Name": "Get-DbaDbMailHistory", "Links": "https://dbatools.io/Get-DbaDbMailHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMailHistory -SqlInstance sql01\\sharepoint\nReturns the entire DBMail history on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMailHistory -SqlInstance sql01\\sharepoint | Select *\nReturns the entire DBMail history on sql01\\sharepoint then return a bunch more columns\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMailHistory\nReturns the all DBMail history for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMailHistory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Since] \u003cDateTime\u003e] [[-Status] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMailLog", "Description": "Gets the DBMail log from a SQL instance", "Tags": [ "DatabaseMail", "DBMail", "Mail" ], "Params": [ [ "SqlInstance", "TThe target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "Credential", false, "false", "" ], [ "Since", "Datetime object used to narrow the results to the send request date", "", false, "false", "" ], [ "Type", "Narrow the results by type. Valid values include Error, Warning, Success, Information, Internal", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the DBMail log from a SQL instance", "Name": "Get-DbaDbMailLog", "Links": "https://dbatools.io/Get-DbaDbMailLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMailLog -SqlInstance sql01\\sharepoint\nReturns the entire DBMail log on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMailLog -SqlInstance sql01\\sharepoint | Select *\nReturns the entire DBMail log on sql01\\sharepoint, includes all returned information.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMailLog -Type Error, Information\nReturns only the Error and Information DBMail log for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMailLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Since] \u003cDateTime\u003e] [[-Type] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMailProfile", "Description": "Gets database mail profiles from SQL Server", "Tags": [ "DatabaseMail", "DBMail", "Mail" ], "Params": [ [ "SqlInstance", "TThe 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)", "Credential", false, "false", "" ], [ "Profile", "Specifies one or more profile(s) to get. If unspecified, all profiles will be returned.", "", false, "false", "" ], [ "ExcludeProfile", "Specifies one or more profile(s) to exclude.", "", false, "false", "" ], [ "InputObject", "Accepts pipeline input from Get-DbaDbMail", "", 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": "Gets database mail profiles from SQL Server", "Name": "Get-DbaDbMailProfile", "Links": "https://dbatools.io/Get-DbaDbMailProfile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMailProfile -SqlInstance sql01\\sharepoint\nReturns DBMail profiles on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMailProfile -SqlInstance sql01\\sharepoint -Profile \u0027The DBA Team\u0027\nReturns The DBA Team DBMail profile from sql01\\sharepoint\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbMailProfile -SqlInstance sql01\\sharepoint | Select *\nReturns the DBMail profiles on sql01\\sharepoint then return a bunch more columns\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMail | Get-DbaDbMailProfile\nReturns the DBMail profiles for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMailProfile [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Profile] \u003cString[]\u003e] [[-ExcludeProfile] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMailServer", "Description": "Gets database mail servers from SQL Server", "Tags": [ "DatabaseMail", "DBMail", "Mail" ], "Params": [ [ "SqlInstance", "TThe 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)", "Credential", false, "false", "" ], [ "Server", "Specifies one or more server(s) to get. If unspecified, all servers will be returned.", "Name", false, "false", "" ], [ "Account", "Get only the mail server associated with specific accounts", "", false, "false", "" ], [ "InputObject", "Accepts pipeline input from Get-DbaDbMail", "", 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": "Gets database mail servers from SQL Server", "Name": "Get-DbaDbMailServer", "Links": "https://dbatools.io/Get-DbaDbMailServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMailServer -SqlInstance sql01\\sharepoint\nReturns all DBMail servers on sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMailServer -SqlInstance sql01\\sharepoint -Server DbaTeam\nReturns The DBA Team DBMail server from sql01\\sharepoint\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbMailServer -SqlInstance sql01\\sharepoint | Select *\nReturns the DBMail servers on sql01\\sharepoint then return a bunch more columns\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDbMail | Get-DbaDbMailServer\nReturns the DBMail servers for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDbMailServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Server] \u003cString[]\u003e] [[-Account] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMasterKey", "Description": "Gets specified database master key", "Tags": [ "Certificate", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "Get master key from specific database", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "InputObject", "Database object piped in from Get-DbaDatabase", "", 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": "Get-DbaDatabaseMasterKey", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets specified database master key", "Name": "Get-DbaDbMasterKey", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMasterKey -SqlInstance sql2016\nGets all master database keys\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMasterKey -SqlInstance Server1 -Database db1\nGets the master key for the db1 database", "Syntax": "Get-DbaDbMasterKey [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMemoryUsage", "Description": "This command can be utilized to determine which databases on a given instance are consuming buffer pool memory.\n\nThis command is based on query provided by Aaron Bertrand.\nReference: https://www.mssqltips.com/sqlservertip/2393/determine-sql-server-memory-use-by-database-and-object/", "Tags": [ "Memory", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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, "true (ByPropertyName)", "" ], [ "ExcludeDatabase", "The database(s) to exclude.", "", false, "false", "" ], [ "IncludeSystemDb", "Switch to have the output include system database memory consumption.", "", 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": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Determine buffer pool usage by database.", "Name": "Get-DbaDbMemoryUsage", "Links": "https://dbatools.io/Get-DbaDbMemoryUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMemoryUsage -SqlInstance sqlserver2014a\nReturns the buffer pool consumption for all user databases\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMemoryUsage -SqlInstance sqlserver2014a -IncludeSystemDb\nReturns the buffer pool consumption for all user databases and system databases\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbMemoryUsage -SqlInstance sql1 -IncludeSystemDb -Database tempdb\nReturns the buffer pool consumption for tempdb database only\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaMemoryUsage -SqlInstance sql2 -IncludeSystemDb -Exclude \u0027master\u0027,\u0027model\u0027,\u0027msdb\u0027,\u0027ResourceDb\u0027\nReturns the buffer pool consumption for all user databases and tempdb database", "Syntax": "Get-DbaDbMemoryUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeSystemDb] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMirror", "Description": "Gets properties of database mirrors and mirror witnesses.", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Gets properties of database mirrors and mirror witnesses.", "Name": "Get-DbaDbMirror", "Links": "https://dbatools.io/Get-DbaDbMirror", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMirror -SqlInstance localhost\nGets properties of database mirrors and mirror witnesses on localhost\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMirror -SqlInstance localhost, sql2016\nGets properties of database mirrors and mirror witnesses on localhost and sql2016 SQL Server instances", "Syntax": "Get-DbaDbMirror [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbMirrorMonitor", "Description": "Returns status rows for a monitored database from the status table in which database mirroring monitoring history is stored and allows you to choose whether the procedure obtains the latest status beforehand.\n\nBasically executes sp_dbmmonitorresults.", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", "", false, "false", "" ], [ "Database", "The target database.", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaDatabase.", "", false, "true (ByValue)", "" ], [ "Update", "Updates the status for the database by calling sp_dbmmonitorupdate before computing the results.\r\nHowever, if the status table has been updated within the previous 15 seconds, or the user is not a member of the sysadmin fixed server role, the command runs without updating the status.", "", false, "false", "False" ], [ "LimitResults", "Limit results. Defaults to last two hours.\nOptions include:\r\nLastRow\r\nLastTwoHours\r\nLastFourHours\r\nLastEightHours\r\nLastDay\r\nLastTwoDays\r\nLast100Rows\r\nLast500Rows\r\nLast1000Rows\r\nLast1000000Rows", "", false, "false", "LastTwoHours" ], [ "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": "Returns status rows for a monitored database from the status table in which database mirroring monitoring history is stored and allows you to choose whether the procedure obtains the latest status beforehand.", "Name": "Get-DbaDbMirrorMonitor", "Links": "https://dbatools.io/Get-DbaDbMirrorMonitor", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbMirrorMonitor -SqlInstance sql2008, sql2012\nReturns last two hours\u0027 worth of status rows for a monitored database from the status table on sql2008 and sql2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbMirrorMonitor -SqlInstance sql2005 -LimitResults LastDay -Update\nUpdates monitor stats then returns the last 24 hours worth of status rows for a monitored database from the status table on sql2008 and sql2012.", "Syntax": "Get-DbaDbMirrorMonitor [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-Update] [[-LimitResults] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbPageInfo", "Description": "Get-DbaDbPageInfo is able to return information about the pages in a database.\nIt\u0027s possible to return the information for multiple databases and filter on specific databases, schemas and tables.", "Tags": [ "Database", "Page" ], "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", "" ], [ "Database", "Filter to only get specific databases", "", false, "false", "" ], [ "Schema", "Filter to only get specific schemas", "", false, "false", "" ], [ "Table", "Filter to only get specific tables", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", 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": "Get-DbaDbPageInfo will return page information for a database", "Name": "Get-DbaDbPageInfo", "Links": "https://dbatools.io/Get-DbaDbPageInfo", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eet-DbaDbPageInfo -SqlInstance sql2017\nReturns page information for all databases on sql2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbPageInfo -SqlInstance sql2017, sql2016 -Database testdb\nReturns page information for the testdb on sql2017 and sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers | Get-DbaDatabase -Database testdb | Get-DbaDbPageInfo\nReturns page information for the testdb on all $servers", "Syntax": "Get-DbaDbPageInfo [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-Schema] \u003cString[]\u003e] [[-Table] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbPartitionFunction", "Description": "Gets database Partition Functions", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get users from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", 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": "Get-DbaDatabasePartitionFunction", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database Partition Functions", "Name": "Get-DbaDbPartitionFunction", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbPartitionFunction -SqlInstance sql2016\nGets all database Partition Functions\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbPartitionFunction -SqlInstance Server1 -Database db1\nGets the Partition Functions for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbPartitionFunction -SqlInstance Server1 -ExcludeDatabase db1\nGets the Partition Functions for all databases except db1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbPartitionFunction\nGets the Partition Functions for the databases on Sql1 and Sql2/sqlexpress", "Syntax": "Get-DbaDbPartitionFunction [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbPartitionScheme", "Description": "Gets database Partition Schemes", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get users from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", 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": "Get-DbaDatabasePartitionScheme", "Author": "Klaas Vandenberghe (@PowerDbaKlaas)", "Synopsis": "Gets database Partition Schemes", "Name": "Get-DbaDbPartitionScheme", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbPartitionScheme -SqlInstance sql2016\nGets all database Partition Schemes\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbPartitionScheme -SqlInstance Server1 -Database db1\nGets the Partition Schemes for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbPartitionScheme -SqlInstance Server1 -ExcludeDatabase db1\nGets the Partition Schemes for all databases except db1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbPartitionScheme\nGets the Partition Schemes for the databases on Sql1 and Sql2/sqlexpress", "Syntax": "Get-DbaDbPartitionScheme [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbQueryStoreOption", "Description": "Retrieves and returns the Query Store configuration for every database that has the Query Store feature enabled.", "Tags": "QueryStore", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "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", "" ], [ "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": "Get-DbaDbQueryStoreOptions,Get-DbaQueryStoreConfig", "Author": "Enrico van de Laar (@evdlaar) | Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Get the Query Store configuration for Query Store enabled databases.", "Name": "Get-DbaDbQueryStoreOption", "Links": "https://dbatools.io/Get-DbaQueryStoreOptions", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbQueryStoreOption -SqlInstance ServerA\\sql\nReturns Query Store configuration settings for every database on the ServerA\\sql instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbQueryStoreOption -SqlInstance ServerA\\sql | Where-Object {$_.ActualState -eq \"ReadWrite\"}\nReturns the Query Store configuration for all databases on ServerA\\sql where the Query Store feature is in Read/Write mode.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbQueryStoreOption -SqlInstance localhost | format-table -AutoSize -Wrap\nReturns Query Store configuration settings for every database on the ServerA\\sql instance inside a table format.", "Syntax": "Get-DbaDbQueryStoreOption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbRecoveryModel", "Description": "Get-DbaDbRecoveryModel displays the Recovery Model for all databases. This is the default, you can filter using -Database, -ExcludeDatabase, -RecoveryModel", "Tags": [ "Recovery", "RecoveryModel", "Simple", "Full", "Bulk", "BulkLogged" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "RecoveryModel", "Filters the output based on Recovery Model. Valid options are Simple, Full and BulkLogged\nDetails about the recovery models can be found here:\r\nhttps://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/recovery-models-sql-server", "", 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", "" ], [ "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": "Viorel Ciucu (@viorelciucu), https://www.cviorel.com", "Synopsis": "Get-DbaDbRecoveryModel displays the Recovery Model.", "Name": "Get-DbaDbRecoveryModel", "Links": "https://dbatools.io/Get-DbaDbRecoveryModel", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Verbose\nGets all databases on SQL Server instance sql2014 having RecoveryModel set to BulkLogged.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbRecoveryModel -SqlInstance sql2014 -Database TestDB\nGets recovery model information for TestDB. If TestDB does not exist on the instance nothing is returned.", "Syntax": "Get-DbaDbRecoveryModel [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-RecoveryModel] \u003cString[]\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbRestoreHistory", "Description": "By default, this command will return the server name, database, username, restore type, date, from file and to files.\n\nThanks to https://www.mssqltips.com/SqlInstancetip/1724/when-was-the-last-time-your-sql-server-database-was-restored/ for the query and https://sqlstudies.com/2016/07/27/when-was-this-database-restored/ for the idea.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "SqlInstance", "Specifies the SQL Server instance(s) to operate on. Requires SQL Server 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)", "Credential", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Since", "Specifies a datetime to use as the starting point for searching backup history.", "", false, "false", "" ], [ "Force", "Deprecated.", "", false, "false", "False" ], [ "Last", "If this switch is enabled, the last restore action performed on each database is returned.", "", 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": "Get-DbaRestoreHistory", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns restore history details for databases on a SQL Server.", "Name": "Get-DbaDbRestoreHistory", "Links": "https://dbatools.io/Get-DbaDbRestoreHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbRestoreHistory -SqlInstance sql2016\nReturns server name, database, username, restore type, date for all restored databases on sql2016.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbRestoreHistory -SqlInstance sql2016 -Database db1, db2 -Since \u00272016-07-01 10:47:00\u0027\nReturns restore information only for databases db1 and db2 on sql2016 since July 1, 2016 at 10:47 AM.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbRestoreHistory -SqlInstance sql2014, sql2016 -Exclude db1\nReturns restore information for all databases except db1 on sql2014 and sql2016.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaDbRestoreHistory -SqlInstance sql2014 -Database AdventureWorks2014, pubs -SqlCredential $cred | Format-Table\nReturns database restore information for AdventureWorks2014 and pubs database on sql2014, connects using SQL Authentication via sqladmin account. Formats the data as a table.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2016 | Get-DbaDbRestoreHistory\nReturns database restore information for every database on every server listed in the Central Management Server on sql2016.", "Syntax": "Get-DbaDbRestoreHistory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Since] \u003cDateTime\u003e] [-Force] [-Last] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbRoleMember", "Description": "The Get-DbaDbRoleMember returns connected SMO object for database roles for each instance(s) of SQL Server.", "Tags": [ "Role", "Database", "Security", "Login" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (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", "" ], [ "Role", "The role(s) to process. If unspecified, all roles will be processed.", "", false, "false", "" ], [ "ExcludeRole", "The role(s) to exclude.", "", false, "false", "" ], [ "ExcludeFixedRole", "Excludes all members of fixed roles.", "", false, "false", "False" ], [ "IncludeSystemUser", "Includes system users. By default system users are not included.", "", 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": "Get-DbaRoleMember", "Author": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Get members of database roles for each instance(s) of SQL Server.", "Name": "Get-DbaDbRoleMember", "Links": "https://dbatools.io/Get-DbaDbRoleMember", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbRoleMember -SqlInstance localhost\nReturns all members of all database roles on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbRoleMember -SqlInstance localhost, sql2016\nReturns all members of all database roles on the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers = Get-Content C:\\servers.txt\nPS C:\\\u003e $servers | Get-DbaDbRoleMember\nReturns all members of all database roles for every server in C:\\servers.txt\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbRoleMember -SqlInstance localhost -Database msdb\nReturns non-system members of all roles in the msdb database on localhost.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDbRoleMember -SqlInstance localhost -Database msdb -IncludeSystemUser -ExcludeFixedRole\nReturns all members of non-fixed roles in the msdb database on localhost.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaDbRoleMember -SqlInstance localhost -Database msdb -Role \u0027db_owner\u0027\nReturns all members of the db_owner role in the msdb database on localhost.", "Syntax": "Get-DbaDbRoleMember [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cString[]\u003e] [-ExcludeDatabase \u003cString[]\u003e] [-Role \u003cString[]\u003e] [-ExcludeRole \u003cString[]\u003e] [-ExcludeFixedRole] [-IncludeSystemUser] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbSharePoint", "Description": "Returns databases that are part of a SharePoint Farm, as found in the SharePoint Configuration database.\n\nBy default, this command checks SharePoint_Config. To use an alternate database, use the ConfigDatabase parameter.", "Tags": "SharePoint", "Params": [ [ "SqlInstance", "The target SQL Server instance", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", "", false, "false", "" ], [ "ConfigDatabase", "The name of the SharePoint Configuration database. Defaults to SharePoint_Config.", "", false, "false", "SharePoint_Config" ], [ "InputObject", "Allows piping from Get-DbaDatabase.", "", 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": "Returns databases that are part of a SharePoint Farm.", "Name": "Get-DbaDbSharePoint", "Links": "https://dbatools.io/Get-DbaDbSharePoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbSharePoint -SqlInstance sqlcluster\nReturns databases that are part of a SharePoint Farm, as found in SharePoint_Config on sqlcluster\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sqlcluster -Database SharePoint_Config_2016 | Get-DbaDbSharePoint\nReturns databases that are part of a SharePoint Farm, as found in SharePoint_Config_2016 on sqlcluster", "Syntax": "Get-DbaDbSharePoint [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-ConfigDatabase] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbSnapshot", "Description": "Retrieves the list of database snapshot available, along with their base (the db they are the snapshot of) and creation time", "Tags": "Snapshot", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "Credential", false, "false", "" ], [ "Database", "Return information for only specific databases", "Databases", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "Snapshot", "Return information for only specific snapshots", "", false, "false", "" ], [ "ExcludeSnapshot", "The snapshot(s) to exclude - this list is auto-populated from the server", "", 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": "Get-DbaDatabaseSnapshot", "Author": "Simone Bizzotto (@niphlod)", "Synopsis": "Get database snapshots with details", "Name": "Get-DbaDbSnapshot", "Links": "https://dbatools.io/Get-DbaDbSnapshot", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sqlserver2014a\nReturns a custom object displaying Server, Database, DatabaseCreated, SnapshotOf, SizeMB, DatabaseCreated\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting\nReturns information for database snapshots having HR and Accounting as base dbs\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sqlserver2014a -Snapshot HR_snapshot, Accounting_snapshot\nReturns information for database snapshots HR_snapshot and Accounting_snapshot", "Syntax": "Get-DbaDbSnapshot [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Snapshot] \u003cObject[]\u003e] [[-ExcludeSnapshot] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbSpace", "Description": "This function returns database file space information for a SQL Instance or group of SQL Instances. Information is based on a query against sys.database_files and the FILEPROPERTY function to query and return information.\n\nFile free space script borrowed and modified from Glenn Berry\u0027s DMV scripts (http://www.sqlskills.com/blogs/glenn/category/dmv-queries/)", "Tags": [ "Database", "Space", "Storage" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "IncludeSystemDBs", "If this switch is enabled, system databases will be processed. By default, only user databases are processed.", "", 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": "Get-DbaDatabaseFreeSpace,Get-DbaDatabaseSpace", "Author": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Returns database file space information for database files on a SQL instance.", "Name": "Get-DbaDbSpace", "Links": "https://dbatools.io/Get-DbaDbSpace", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbSpace -SqlInstance localhost\nReturns all user database files and free space information for the localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbSpace -SqlInstance localhost | Where-Object {$_.PercentUsed -gt 80}\nReturns all user database files and free space information for the local host. Filters the output object by any files that have a percent used of greater than 80%.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaDbSpace\nReturns all user database files and free space information for the localhost and localhost\\namedinstance SQL Server instances. Processes data via the pipeline.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbSpace -SqlInstance localhost -Database db1, db2\nReturns database files and free space information for the db1 and db2 on localhost.", "Syntax": "Get-DbaDbSpace [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbState", "Description": "Gets some common \"states\" on databases:\n- \"RW\" options : READ_ONLY or READ_WRITE\n- \"Status\" options : ONLINE, OFFLINE, EMERGENCY, RESTORING\n- \"Access\" options : SINGLE_USER, RESTRICTED_USER, MULTI_USER\n\nReturns an object with SqlInstance, Database, RW, Status, Access", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "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", "" ], [ "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": "Get-DbaDatabaseState", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Gets various options for databases, hereby called \"states\"", "Name": "Get-DbaDbState", "Links": "https://dbatools.io/Get-DbaDbState", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbState -SqlInstance sqlserver2014a\nGets options for all databases of the sqlserver2014a instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbState -SqlInstance sqlserver2014a -Database HR, Accounting\nGets options for both HR and Accounting database of the sqlserver2014a instance\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbState -SqlInstance sqlserver2014a -Exclude HR\nGets options for all databases of the sqlserver2014a instance except HR\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027sqlserver2014a\u0027, \u0027sqlserver2014b\u0027 | Get-DbaDbState\nGets options for all databases of sqlserver2014a and sqlserver2014b instances", "Syntax": "Get-DbaDbState [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbStoredProcedure", "Description": "Gets database Stored Procedures", "Tags": [ "Database", "StoredProcedure", "Proc" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get Stored Procedures from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", false, "false", "" ], [ "ExcludeSystemSp", "This switch removes all system objects from the Stored Procedure collection", "", 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": "Klaas Vandenberghe (@PowerDbaKlaas)", "Synopsis": "Gets database Stored Procedures", "Name": "Get-DbaDbStoredProcedure", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance sql2016\nGets all database Stored Procedures\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance Server1 -Database db1\nGets the Stored Procedures for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance Server1 -ExcludeDatabase db1\nGets the Stored Procedures for all databases except db1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance Server1 -ExcludeSystemSp\nGets the Stored Procedures for all databases that are not system objects\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbStoredProcedure\nGets the Stored Procedures for the databases on Sql1 and Sql2/sqlexpress", "Syntax": "Get-DbaDbStoredProcedure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemSp] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbTable", "Description": "Shows table information around table row and data sizes and if it has any table type information.", "Tags": [ "Database", "Tables" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input.", "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", "" ], [ "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", "" ], [ "IncludeSystemDBs", "Switch parameter that when used will display system database information", "", false, "false", "False" ], [ "Table", "Define a specific table you would like to query. You can specify up to three-part name like db.sch.tbl.\nIf the object has special characters please wrap them in square brackets [ ].\r\nUsing dbo.First.Table will try to find table named \u0027Table\u0027 on schema \u0027First\u0027 and database \u0027dbo\u0027.\r\nThe correct way to find table named \u0027First.Table\u0027 on schema \u0027dbo\u0027 is by passing dbo.[First.Table]\r\nAny actual usage of the ] must be escaped by duplicating the ] character.\r\nThe correct way to find a table Name] in schema Schema.Name is by passing [Schema.Name].[Name]]]", "", 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": "Get-DbaTable", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Returns a summary of information on the tables", "Name": "Get-DbaDbTable", "Links": "https://dbatools.io/Get-DbaDbTable", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Database Test1\nReturn all tables in the Test1 database\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Database MyDB -Table MyTable\nReturn only information on the table MyTable from the database MyDB\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Table MyTable\nReturns information on table called MyTable if it exists in any database on the server, under any schema\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Table dbo.[First.Table]\nReturns information on table called First.Table on schema dbo if it exists in any database on the server\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaDbTable -Database DBA -Table Commandlog\nReturns information on the CommandLog table in the DBA database on both instances localhost and the named instance localhost\\namedinstance\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Table \"[[DbName]]].[Schema.With.Dots].[`\"[Process]]`\"]\" -Verbose\nFor the instance Dev01 Returns information for a table named: \"[Process]\" in schema named: Schema.With.Dots in database named: [DbName]\r\nThe Table name, Schema name and Database name must be wrapped in square brackets [ ]\r\nSpecial charcters like \" must be escaped by a ` charcter.\r\nIn addition any actual instance of the ] character must be escaped by being duplicated.", "Syntax": "Get-DbaDbTable [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [[-Table] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbTrigger", "Description": "Get all existing database triggers on one or more SQL instances.", "Tags": [ "Database", "Trigger" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "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", "" ], [ "InputObject", "Allow pipedline input from Get-DbaDatabase", "", 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/ca", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Get all existing database triggers on one or more SQL instances.", "Name": "Get-DbaDbTrigger", "Links": "https://dbatools.io/Get-DbaDbTrigger", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbTrigger -SqlInstance sql2017\nReturns all database triggers\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017 -Database supa | Get-DbaDbTrigger\nReturns all triggers for database supa on sql2017\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbTrigger -SqlInstance sql2017 -Database supa\nReturns all triggers for database supa on sql2017", "Syntax": "Get-DbaDbTrigger [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbUdf", "Description": "Gets database User Defined Functions", "Tags": [ "Security", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get User Defined Functions from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", false, "false", "" ], [ "ExcludeSystemUdf", "This switch removes all system objects from the UDF collection", "", 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": "Get-DbaDatabaseUdf", "Author": "Klaas Vandenberghe (@PowerDbaKlaas)", "Synopsis": "Gets database User Defined Functions", "Name": "Get-DbaDbUdf", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance sql2016\nGets all database User Defined Functions\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance Server1 -Database db1\nGets the User Defined Functions for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance Server1 -ExcludeDatabase db1\nGets the User Defined Functions for all databases except db1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance Server1 -ExcludeSystemUdf\nGets the User Defined Functions for all databases that are not system objects (there can be 100+ system User Defined Functions in each DB)\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbUdf\nGets the User Defined Functions for the databases on Sql1 and Sql2/sqlexpress", "Syntax": "Get-DbaDbUdf [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemUdf] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbUser", "Description": "Gets database users", "Tags": [ "Security", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "To get users from specific database(s)", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server", "", false, "false", "" ], [ "ExcludeSystemUser", "This switch removes all system objects from the user collection", "", 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": "Get-DbaDatabaseUser", "Author": "Klaas Vandenberghe (@PowerDbaKlaas)", "Synopsis": "Gets database users", "Name": "Get-DbaDbUser", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbUser -SqlInstance sql2016\nGets all database users\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbUser -SqlInstance Server1 -Database db1\nGets the users for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbUser -SqlInstance Server1 -ExcludeDatabase db1\nGets the users for all databases except db1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbUser -SqlInstance Server1 -ExcludeSystemUser\nGets the users for all databases that are not system objects, like \u0027dbo\u0027, \u0027guest\u0027 or \u0027INFORMATION_SCHEMA\u0027\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbUser\nGets the users for the databases on Sql1 and Sql2/sqlexpress", "Syntax": "Get-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemUser] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbView", "Description": "Gets database views for each SqlInstance.", "Tags": [ "Security", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "Database", "To get views from specific database(s) - this list is auto populated from the server.", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto populated from the server.", "", false, "false", "" ], [ "ExcludeSystemView", "This switch removes all system objects from the view collection.", "", 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": "Get-DbaDatabaseView", "Author": "Klaas Vandenberghe (@PowerDbaKlaas)", "Synopsis": "Gets database views for each SqlInstance.", "Name": "Get-DbaDbView", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbView -SqlInstance sql2016\nGets all database views\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbView -SqlInstance Server1 -Database db1\nGets the views for the db1 database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbView -SqlInstance Server1 -ExcludeDatabase db1\nGets the views for all databases except db1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbView -SqlInstance Server1 -ExcludeSystemView\nGets the views for all databases that are not system objects (there can be 400+ system views in each DB)\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbView\nGets the views for the databases on Sql1 and Sql2/sqlexpress", "Syntax": "Get-DbaDbView [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemView] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDbVirtualLogFile", "Description": "Having a transaction log file with too many virtual log files (VLFs) can hurt database performance.\n\nToo many VLFs can cause transaction log backups to slow down and can also slow down database recovery and, in extreme cases, even affect insert/update/delete performance.\n\nReferences:\nhttp://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\nhttp://blogs.msdn.com/b/saponsqlserver/archive/2012/02/22/too-many-virtual-log-files-vlfs-can-cause-slow-database-recovery.aspx\n\nIf you\u0027ve got a high number of VLFs, you can use Expand-SqlTLogResponsibly to reduce the number.", "Tags": [ "VLF", "Database", "LogFile" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "IncludeSystemDBs", "If this switch is enabled, system database information will be displayed.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns database virtual log file information for database files on a SQL instance.", "Name": "Get-DbaDbVirtualLogFile", "Links": "https://dbatools.io/Get-DbaDbVirtualLogFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDbVirtualLogFile -SqlInstance sqlcluster\nReturns all user database virtual log file details for the sqlcluster instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDbVirtualLogFile -SqlInstance sqlserver | Group-Object -Property Database | Where-Object Count -gt 50\nReturns user databases that have 50 or more VLFs.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sqlserver\u0027,\u0027sqlcluster\u0027 | Get-DbaDbVirtualLogFile\nReturns all VLF information for the sqlserver and sqlcluster SQL Server instances. Processes data via the pipeline.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbVirtualLogFile -SqlInstance sqlcluster -Database db1, db2\nReturns the VLF counts for the db1 and db2 databases on sqlcluster.", "Syntax": "Get-DbaDbVirtualLogFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDefaultPath", "Description": "Gets the default SQL Server paths for data, logs and backups", "Tags": "Config", "Params": [ [ "SqlInstance", "TThe target SQL Server instance or instances.", "ServerInstance,Instance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "Credential", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the default SQL Server paths for data, logs and backups", "Name": "Get-DbaDefaultPath", "Links": "https://dbatools.io/Get-DbaDefaultPath", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDefaultPath -SqlInstance sql01\\sharepoint\nReturns the default file paths for sql01\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaDefaultPath\nReturns the default file paths for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"", "Syntax": "Get-DbaDefaultPath [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDependency", "Description": "This function recursively finds all objects that depends on the input.\nIt will then retrieve rich information from them, including their creation scripts and the order in which it should be applied.\n\nBy using the \u0027Parents\u0027 switch, the function will instead retrieve all items that the input depends on (including their creation scripts).\n\nFor more details on dependency, see:\nhttps://technet.microsoft.com/en-us/library/ms345449(v=sql.105).aspx", "Tags": [ "Database", "Dependent", "Dependency", "Object" ], "Params": [ [ "InputObject", "The SMO object to parse", "", false, "true (ByValue)", "" ], [ "AllowSystemObjects", "Normally, system objects are ignored by this function as dependencies.\r\nThis switch overrides that behavior.", "", false, "false", "False" ], [ "Parents", "Causes the function to retrieve all objects that the input depends on, rather than retrieving everything that depends on the input.", "", false, "false", "False" ], [ "IncludeSelf", "Includes the object whose dependencies are retrieves itself.\r\nUseful when exporting an entire logic structure in order to recreate it in another database.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Finds object dependencies and their relevant creation scripts.", "Name": "Get-DbaDependency", "Links": "https://dbatools.io/Get-DbaDependency", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$table = (Get-DbaDatabase -SqlInstance sql2012 -Database Northwind).tables | Where Name -eq Customers\nPS C:\\\u003e $table | Get-DbaDependency\nReturns everything that depends on the \"Customers\" table", "Syntax": "Get-DbaDependency [[-InputObject] \u003cObject\u003e] [-AllowSystemObjects] [-Parents] [-IncludeSelf] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDeprecatedFeature", "Description": "Displays information relating to deprecated features for SQL Server 2005 and above.", "Tags": "Deprecated", "Params": [ [ "SqlInstance", "The target SQL Server instance", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", "", 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": "Displays information relating to deprecated features for SQL Server 2005 and above.", "Name": "Get-DbaDeprecatedFeature", "Links": "https://dbatools.io/Get-DbaDeprecatedFeature", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDeprecatedFeature -SqlInstance sql2008, sqlserver2012\nCheck deprecated features for all databases on the servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDeprecatedFeature -SqlInstance sql2008\nCheck deprecated features on server sql2008.", "Syntax": "Get-DbaDeprecatedFeature [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDetachedDatabaseInfo", "Description": "Gathers the following information from detached database files: database name, SQL Server version (compatibility level), collation, and file structure.\n\n\"Data files\" and \"Log file\" report the structure of the data and log files as they were when the database was detached. \"Database version\" is the compatibility level.\n\nMDF files are most easily read by using a SQL Server to interpret them. Because of this, you must specify a SQL Server and the path must be relative to the SQL Server.", "Tags": [ "Database", "Detach" ], "Params": [ [ "SqlInstance", "Source SQL Server. This instance must be online and is required to parse the information contained with in the detached database file.\nThis function will not attach the database file, it will only use SQL Server to read its contents.", "ServerInstance,SqlServer", true, "false", "" ], [ "Path", "Specifies the path to the MDF file to be read. This path must be readable by the SQL Server service account. Ideally, the MDF will be located on the SQL Server itself, or on a network share to which \r\nthe SQL Server service account has access.", "Mdf", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Get detailed information about detached SQL Server database files.", "Name": "Get-DbaDetachedDatabaseInfo", "Links": "https://dbatools.io/Get-DbaDetachedDatabaseInfo", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDetachedDatabaseInfo -SqlInstance sql2016 -Path M:\\Archive\\mydb.mdf\nReturns information about the detached database file M:\\Archive\\mydb.mdf using the SQL Server instance sql2016. The M drive is relative to the SQL Server instance.", "Syntax": "Get-DbaDetachedDatabaseInfo [-SqlInstance] \u003cDbaInstanceParameter\u003e [-Path] \u003cString\u003e [[-SqlCredential] \u003cPSCredential\u003e] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDiskSpace", "Description": "Returns a custom object with server name, name of disk, label of disk, total size, free size, percent free, block size and filesystem.\n\nBy default, this function only shows drives of types 2 and 3 (removable disk and local disk).\n\nRequires Windows administrator access on SQL Servers", "Tags": [ "Storage", "Disk" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "ServerInstance,SqlInstance,SqlServer", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", false, "false", "" ], [ "Unit", "This parameter has been deprecated and will be removed in 1.0.0\r\nAll properties previously generated through this command are present at the same time, but hidden by default.", "", false, "false", "GB" ], [ "CheckForSql", "If this switch is enabled, disks will be checked for SQL Server data and log files. Windows Authentication is always used for this.", "", false, "false", "False" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "ExcludeDrive", "Filter out drives - format is C:\\", "", false, "false", "" ], [ "CheckFragmentation", "If this switch is enabled, fragmentation of all filesystems will be checked.\nThis will increase the runtime of the function by seconds or even minutes per volume.", "Detailed,AllDrives", false, "false", "False" ], [ "Force", "Enabling this switch will cause the command to include ALL drives.\r\nBy default, only local disks and removable disks are shown, and hidden volumes are excluded.", "", 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": "Get-DiskSpace", "Author": "Chrissy LeMaire (@cl), netnerds.net | Jakob Bindslet", "Synopsis": "Displays disk information for all local disk on a server.", "Name": "Get-DbaDiskSpace", "Links": "https://dbatools.io/Get-DbaDiskSpace", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042\nGet disk space for the server srv0042.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042 -Unit MB\nGet disk space for the server srv0042 and displays in megabytes (MB).\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042, srv0007 -Unit TB\nGet disk space from two servers and displays in terabytes (TB).\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042 -Force\nGet all disk and volume space information.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042 -ExcludeDrive \u0027C:\\\u0027\nGet all disk and volume space information.", "Syntax": "Get-DbaDiskSpace [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Unit] \u003cString\u003e] [-CheckForSql] [[-SqlCredential] \u003cPSCredential\u003e] [[-ExcludeDrive] \u003cString[]\u003e] [-CheckFragmentation] [-Force] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaDump", "Description": "The type of dump included in the search include minidump, all-thread dump, or a full dump. The files have an extendion of .mdmp.", "Tags": [ "Engine", "Corruption" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Locate a SQL Server that has generated any memory dump files.", "Name": "Get-DbaDump", "Links": "https://dbatools.io/Get-DbaDump", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDump -SqlInstance sql2016\nShows the detailed information for memory dump(s) located on sql2016 instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDump -SqlInstance sql2016 -SqlCredential sqladmin\nShows the detailed information for memory dump(s) located on sql2016 instance. Logs into the SQL Server using the SQL login \u0027sqladmin\u0027", "Syntax": "Get-DbaDump [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaEndpoint", "Description": "Returns endpoint objects from a SQL Server instance.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Endpoint", "Return only specific endpoints.", "", false, "false", "" ], [ "Type", "Return only specific types of endpoints. Options include: DatabaseMirroring, ServiceBroker, Soap, and TSql.", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Returns endpoint objects from a SQL Server instance.", "Name": "Get-DbaEndpoint", "Links": "https://dbatools.io/Get-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance localhost\nReturns all endpoints on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance localhost, sql2016\nReturns all endpoints for the local and sql2016 SQL Server instances", "Syntax": "Get-DbaEndpoint [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Endpoint \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaErrorLog", "Description": "Gets the \"SQL Error Log\" of an instance. Returns all 10 error logs by default.", "Tags": [ "Instance", "ErrorLog" ], "Params": [ [ "SqlInstance", "TThe target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "Credential", false, "false", "" ], [ "LogNumber", "An Int32 value that specifies the index number of the error log required.\r\nError logs are listed 0 through 99, where 0 is the current error log and 99 is potential oldest log file.\nSQL Server errorlog rollover defaults to 6, but can be increased to 99. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/scm-services-configure-sql-server-error-logs", "", false, "false", "" ], [ "Source", "Filter results based on the Source of the error (e.g. Logon, Server, etc.)", "", false, "false", "" ], [ "Text", "Filter results based on a pattern of text (e.g. \"login failed\", \"error: 12345\").", "", false, "false", "" ], [ "After", "Filter the results based on datetime value.", "", false, "false", "" ], [ "Before", "Filter the results based on datetime value.", "", 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": "Get-DbaLog", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the \"SQL Error Log\" of an instance", "Name": "Get-DbaErrorLog", "Links": "https://dbatools.io/Get-DbaErrorLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint\nReturns every log entry from sql01\\sharepoint SQL Server instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -LogNumber 3, 6\nReturns all log entries for log number 3 and 6 on sql01\\sharepoint SQL Server instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -Source Logon\nReturns every log entry, with a source of Logon, from sql01\\sharepoint SQL Server instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -LogNumber 3 -Text \"login failed\"\nReturns every log entry for log number 3, with \"login failed\" in the text, from sql01\\sharepoint SQL Server instance.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\nPS C:\\\u003e $servers | Get-DbaErrorLog -LogNumber 0\nReturns the most recent SQL Server error logs for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -After \u00272016-11-14 00:00:00\u0027\nReturns every log entry found after the date 14 November 2016 from sql101\\sharepoint SQL Server instance.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -Before \u00272016-08-16 00:00:00\u0027\nReturns every log entry found before the date 16 August 2016 from sql101\\sharepoint SQL Server instance.", "Syntax": "Get-DbaErrorLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-LogNumber] \u003cInt32[]\u003e] [[-Source] \u003cObject[]\u003e] [[-Text] \u003cString\u003e] [[-After] \u003cDateTime\u003e] [[-Before] \u003cDateTime\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaErrorLogConfig", "Description": "Pulls the configuration for the ErrorLog on a given SQL Server instance.\n\nIncludes error log path, number of log files configured and size (SQL Server 2012+ only)", "Tags": [ "Instance", "ErrorLog" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Pulls the configuration for the ErrorLog on a given SQL Server instance", "Name": "Get-DbaErrorLogConfig", "Links": "https://dbatools.io/Get-DbaErrorLogConfig", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaErrorLogConfig -SqlInstance server2017,server2014\nReturns error log configuration for server2017 and server2014", "Syntax": "Get-DbaErrorLogConfig [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaEstimatedCompletionTime", "Description": "Gets execution and estimated completion time information for queries\n\nPercent complete will show for the following commands\n\nALTER INDEX REORGANIZE\nAUTO_SHRINK option with ALTER DATABASE\nBACKUP DATABASE\nDBCC CHECKDB\nDBCC CHECKFILEGROUP\nDBCC CHECKTABLE\nDBCC INDEXDEFRAG\nDBCC SHRINKDATABASE\nDBCC SHRINKFILE\nRECOVERY\nRESTORE DATABASE\nROLLBACK\nTDE ENCRYPTION\n\nFor additional information, check out https://blogs.sentryone.com/loriedwards/patience-dm-exec-requests/ and https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-requests-transact-sql", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "SqlCredential 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", "" ], [ "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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets execution and estimated completion time information for queries", "Name": "Get-DbaEstimatedCompletionTime", "Links": "https://dbatools.io/Get-DbaEstimatedCompletionTime", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016\nGets estimated completion times for queries performed against the entire server\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016 | Select *\nGets estimated completion times for queries performed against the entire server PLUS the SQL query text of each command\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016 | Where-Object { $_.Text -match \u0027somequerytext\u0027 }\nGets results for commands whose queries only match specific text (match is like LIKE but way more powerful)\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016 -Database Northwind,pubs,Adventureworks2014\nGets estimated completion times for queries performed against the Northwind, pubs, and Adventureworks2014 databases", "Syntax": "Get-DbaEstimatedCompletionTime [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaExecutionPlan", "Description": "Gets execution plans and metadata. Can pipe to Export-DbaExecutionPlan\n\nThanks to following for the queries:\nhttps://www.simple-talk.com/sql/t-sql-programming/dmvs-for-query-plan-metadata/\nhttp://www.scarydba.com/2017/02/13/export-plans-cache-sqlplan-file/", "Tags": "Performance", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "Credential", false, "false", "" ], [ "Database", "Return execution plans and metadata for only specific databases.", "", false, "false", "" ], [ "ExcludeDatabase", "Return execution plans and metadata for all but these specific databases", "", false, "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", "" ], [ "ExcludeEmptyQueryPlan", "Exclude results with empty query plan", "", false, "false", "False" ], [ "Force", "Returns a ton of raw information about the execution plans", "", 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": "Gets execution plans and metadata", "Name": "Get-DbaExecutionPlan", "Links": "https://dbatools.io/Get-DbaExecutionPlan", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a\nGets all execution plans on sqlserver2014a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a -Database db1, db2 -SinceLastExecution \u00272016-07-01 10:47:00\u0027\nGets all execution plans for databases db1 and db2 on sqlserver2014a since July 1, 2016 at 10:47 AM.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a, sql2016 -Exclude db1 | Format-Table\nGets execution plan info for all databases except db1 on sqlserver2014a and sql2016 and makes the output pretty\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sql2014 -Database AdventureWorks2014, pubs -Force\nGets super detailed information for execution plans on only for AdventureWorks2014 and pubs\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers = \"sqlserver2014a\",\"sql2016t\"\nPS C:\\\u003e $servers | Get-DbaExecutionPlan -Force\nGets super detailed information for execution plans on sqlserver2014a and sql2016", "Syntax": "Get-DbaExecutionPlan [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-SinceCreation] \u003cDateTime\u003e] [[-SinceLastExecution] \u003cDateTime\u003e] [-ExcludeEmptyQueryPlan] [-Force] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaFeature", "Description": "Runs the SQL Server feature discovery report (setup.exe /Action=RunDiscovery)\n\nInspired by Dave Mason\u0027s (@BeginTry) post at\nhttps://itsalljustelectrons.blogspot.be/2018/04/SQL-Server-Discovery-Report.html\n\nAssumptions:\n1. The sub-folder \"Microsoft SQL Server\" exists in $env:ProgramFiles,\neven if SQL was installed to a non-default path. This has been\nverified on SQL 2008R2 and SQL 2012. Further verification may be needed.\n2. The discovery report displays installed components for the version of SQL\nServer associated with setup.exe, along with installed components of all\nlesser versions of SQL Server that are installed.", "Tags": [ "Feature", "Component" ], "Params": [ [ "ComputerName", "The target computer. If the target is not localhost, it must have PowerShell remoting enabled.\nNote that this is not the SqlInstance, but rather the ComputerName", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$cred = Get-Credential, then pass $cred object to the -Credential parameter.", "", 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": "Get-DbaSqlFeature", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Runs the SQL Server feature discovery report (setup.exe /Action=RunDiscovery)", "Name": "Get-DbaFeature", "Links": "https://dbatools.io/Get-DbaFeature", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaFeature -ComputerName sql2017, sql2016, sql2005\nGets all SQL Server features for all instances on sql2017, sql2016 and sql2005.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaFeature -Verbose\nGets all SQL Server features for all instances on localhost. Outputs to screen if no instances are found.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaFeature -ComputerName sql2017 -Credential ad\\sqldba\nGets all SQL Server features for all instances on sql2017 using the ad\\sqladmin credential (which has access to the Windows Server).", "Syntax": "Get-DbaFeature [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaFile", "Description": "This command searches all specified directories, allowing a DBA to see file information on a server without direct access\n\nYou can filter by extension using the -FileType parameter. By default, the default data directory will be returned. You can provide and additional paths to search using the -Path parameter.\n\nThanks to serg-52 for the query: https://www.sqlservercentral.com/Forums/Topic1642213-391-1.aspx", "Tags": "Discovery", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using alternative credentials", "", false, "false", "" ], [ "Path", "Used to specify extra directories to search in addition to the default data directory.", "", false, "false", "" ], [ "FileType", "Used to specify filter by filetype. No dot required, just pass the extension.", "", false, "false", "" ], [ "Depth", "Used to specify recursive folder depth. Default is 1, non-recursive.", "", false, "false", "1" ], [ "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": "Brandon Abshire, netnerds.net", "Synopsis": "Get-DbaFile finds files in any directory specified on a remote SQL Server", "Name": "Get-DbaFile", "Links": "https://dbatools.io/Get-DbaFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaFile -SqlInstance sqlserver2014a -Path E:\\Dir1\nLogs into the SQL Server \"sqlserver2014a\" using Windows credentials and searches E:\\Dir for all files\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaFile -SqlInstance sqlserver2014a -SqlCredential $cred -Path \u0027E:\\sql files\u0027\nLogs into the SQL Server \"sqlserver2014a\" using alternative credentials and returns all files in \u0027E:\\sql files\u0027\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$all = Get-DbaDefaultPath -SqlInstance sql2014\nPS C:\\\u003e Get-DbaFile -SqlInstance sql2014 -Path $all.Data, $all.Log, $all.Backup -Depth 3\nReturns the files in the default data, log and backup directories on sql2014, 3 directories deep (recursively).\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaFile -SqlInstance sql2014 -Path \u0027E:\\Dir1\u0027, \u0027E:\\Dir2\u0027\nReturns the files in \"E:\\Dir1\" and \"E:Dir2\" on sql2014\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaFile -SqlInstance sql2014, sql2016 -Path \u0027E:\\Dir1\u0027 -FileType fsf, mld\nFinds files in E:\\Dir1 ending with \".fsf\" and \".mld\" for both the servers sql2014 and sql2016.", "Syntax": "Get-DbaFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString[]\u003e] [[-FileType] \u003cString[]\u003e] [[-Depth] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaFilestream", "Description": "Returns the status of Filestream on specified SQL Server for both the Service and Instance levels.", "Tags": "Filestream", "Params": [ [ "SqlInstance", "SQL Server name or SMO object representing the SQL Server to connect to. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "", false, "true (ByValue)", "" ], [ "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 Windows server using alternative credentials.", "", 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": "Stuart Moore ( @napalmgram ) | Chrissy LeMaire ( @cl )", "Synopsis": "Returns the status of Filestream on specified SQL Server for both the Service and Instance levels.", "Name": "Get-DbaFilestream", "Links": "https://dbatools.io/Get-DbaFilestream", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaFilestream -SqlInstance server1\\instance2\nWill return the status of Filestream configuration for the service and instance server1\\instance2\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaFilestream -SqlInstance server1\\instance2 -SqlCredential sqladmin\nPrompts for the password to the SQL Login \"sqladmin\" then returns the status of Filestream configuration for the service and instance server1\\instance2", "Syntax": "Get-DbaFilestream [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaForceNetworkEncryption", "Description": "Gets Force Encryption settings for a SQL Server instance. Note that this requires access to the Windows Server - not the SQL instance itself.\n\nThis setting is found in Configuration Manager.", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "ServerInstance,SqlServer,ComputerName", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the computer (not sql instance) using alternative Windows credentials", "", 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": "Gets Force Encryption settings for a SQL Server instance", "Name": "Get-DbaForceNetworkEncryption", "Links": "https://dbatools.io/Get-DbaForceNetworkEncryption", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaForceNetworkEncryption\nGets Force Encryption properties on the default (MSSQLSERVER) instance on localhost - requires (and checks for) RunAs admin.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2\nGets Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both login and view the registry.", "Syntax": "Get-DbaForceNetworkEncryption [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaHelpIndex", "Description": "This function will return detailed information on indexes (and optionally statistics) for all indexes in a database, or a given index should one be passed along.\nAs this uses SQL Server DMVs to access the data it will only work in 2005 and up (sorry folks still running SQL Server 2000).\nFor performance reasons certain statistics information will not be returned from SQL Server 2005 if an ObjectName is not provided.\n\nThe data includes:\n- ObjectName: the table containing the index\n- IndexType: clustered/non-clustered/columnstore and whether the index is unique/primary key\n- KeyColumns: the key columns of the index\n- IncludeColumns: any include columns in the index\n- FilterDefinition: any filter that may have been used in the index\n- DataCompression: row/page/none depending upon whether or not compression has been used\n- IndexReads: the number of reads of the index since last restart or index rebuild\n- IndexUpdates: the number of writes to the index since last restart or index rebuild\n- SizeKB: the size the index in KB\n- IndexRows: the number of the rows in the index (note filtered indexes will have fewer rows than exist in the table)\n- IndexLookups: the number of lookups that have been performed (only applicable for the heap or clustered index)\n- MostRecentlyUsed: when the index was most recently queried (default to 1900 for when never read)\n- StatsSampleRows: the number of rows queried when the statistics were built/rebuilt (not included in SQL Server 2005 unless ObjectName is specified)\n- StatsRowMods: the number of changes to the statistics since the last rebuild\n- HistogramSteps: the number of steps in the statistics histogram (not included in SQL Server 2005 unless ObjectName is specified)\n- StatsLastUpdated: when the statistics were last rebuilt (not included in SQL Server 2005 unless ObjectName is specified)", "Tags": "Index", "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)", "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", "" ], [ "InputObject", "Allows piping from Get-DbaDatabase", "", false, "true (ByValue)", "" ], [ "ObjectName", "The name of a table for which you want to obtain the index information. If the two part naming convention for an object is not used it will use the default schema for the executing user. If not \r\npassed it will return data on all indexes in a given database.", "", false, "false", "" ], [ "IncludeStats", "If this switch is enabled, statistics as well as indexes will be returned in the output (statistics information such as the StatsRowMods will always be returned for indexes).", "", false, "false", "False" ], [ "IncludeDataTypes", "If this switch is enabled, the output will include the data type of each column that makes up a part of the index definition (key and include columns).", "", false, "false", "False" ], [ "Raw", "If this switch is enabled, results may be less user-readable but more suitable for processing by other code.", "", false, "false", "False" ], [ "IncludeFragmentation", "If this switch is enabled, the output will include fragmentation information.", "", 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": "Nic Cain, https://sirsql.net/", "Synopsis": "Returns size, row and configuration information for indexes in databases.", "Name": "Get-DbaHelpIndex", "Links": "https://dbatools.io/Get-DbaHelpIndex", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB\nReturns information on all indexes on the MyDB database on the localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB,MyDB2\nReturns information on all indexes on the MyDB \u0026 MyDB2 databases.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1\nReturns index information on the object dbo.Table1 in the database MyDB.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1 -IncludeStats\nReturns information on the indexes and statistics for the table dbo.Table1 in the MyDB database.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1 -IncludeDataTypes\nReturns the index information for the table dbo.Table1 in the MyDB database, and includes the data types for the key and include columns.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1 -Raw\nReturns the index information for the table dbo.Table1 in the MyDB database, and returns the numerical data without localized separators.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -IncludeStats -Raw\nReturns the index information for all indexes in the MyDB database as well as their statistics, and formats the numerical data without localized separators.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -IncludeFragmentation\nReturns the index information for all indexes in the MyDB database as well as their fragmentation\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017 -Database MyDB | Get-DbaHelpIndex\nReturns the index information for all indexes in the MyDB database", "Syntax": "Get-DbaHelpIndex [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [[-ObjectName] \u003cString\u003e] [-IncludeStats] [-IncludeDataTypes] [-Raw] [-IncludeFragmentation] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaInstanceProperty", "Description": "The Get-DbaInstanceProperty command gets SQL Server instance properties from the SMO object sqlserver.", "Tags": [ "Instance", "Configure", "Configuration" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "InstanceProperty", "SQL Server instance property(ies) to include.", "", false, "false", "" ], [ "ExcludeInstanceProperty", "SQL Server instance property(ies) to exclude.", "", 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": "Get-DbaSqlInstanceProperty", "Author": "Klaas Vandenberghe (@powerdbaklaas)", "Synopsis": "Gets SQL Server instance properties of one or more instance(s) of SQL Server.", "Name": "Get-DbaInstanceProperty", "Links": "https://dbatools.io/Get-DbaInstanceProperty", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance localhost\nReturns SQL Server instance properties on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance sql2, sql4\\sqlexpress\nReturns SQL Server instance properties on default instance on sql2 and sqlexpress instance on sql4\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sql2\u0027,\u0027sql4\u0027 | Get-DbaInstanceProperty\nReturns SQL Server instance properties on sql2 and sql4\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance sql2,sql4 -InstanceProperty DefaultFile\nReturns SQL Server instance property DefaultFile on instance sql2 and sql4\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance sql2,sql4 -ExcludeInstanceProperty DefaultFile\nReturns all SQL Server instance properties except DefaultFile on instance sql2 and sql4\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaInstanceProperty -SqlInstance sql2 -SqlCredential $cred\nConnects using sqladmin credential and returns SQL Server instance properties from sql2", "Syntax": "Get-DbaInstanceProperty [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-InstanceProperty \u003cObject[]\u003e] [-ExcludeInstanceProperty \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaInstanceUserOption", "Description": "The Get-DbaInstanceUserOption command gets SQL Instance user options from the SMO object sqlserver.", "Tags": [ "Instance", "Configure", "UserOption" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.\r\nThis can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "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": "Get-DbaSqlInstanceUserOption", "Author": "Klaas Vandenberghe (@powerdbaklaas)", "Synopsis": "Gets SQL Instance user options of one or more instance(s) of SQL Server.", "Name": "Get-DbaInstanceUserOption", "Links": "https://dbatools.io/Get-DbaInstanceUserOption", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaInstanceUserOption -SqlInstance localhost\nReturns SQL Instance user options on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaInstanceUserOption -SqlInstance sql2, sql4\\sqlexpress\nReturns SQL Instance user options on default instance on sql2 and sqlexpress instance on sql4\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sql2\u0027,\u0027sql4\u0027 | Get-DbaInstanceUserOption\nReturns SQL Instance user options on sql2 and sql4", "Syntax": "Get-DbaInstanceUserOption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaIoLatency", "Description": "This command is based off of Paul Randal\u0027s post \"Advanced SQL Server performance tuning\"\n\nReturns both raw and aggregate information\n\nReference: https://www.sqlskills.com/blogs/paul/how-to-examine-io-subsystem-latencies-from-within-sql-server/\n https://www.sqlskills.com/blogs/paul/capturing-io-latencies-period-time/", "Tags": "IOLatency", "Params": [ [ "SqlInstance", "The SQL Server instance. Server version must be SQL Server version 2008 or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Patrick Flynn (@sqllensman)", "Synopsis": "Displays IO subsystem latency statistics from sys.dm_io_virtual_file_stats. Works on SQL Server 2005 and above.", "Name": "Get-DbaIoLatency", "Links": "https://dbatools.io/Get-DbaIoLatency", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaIoLatency -SqlInstance sql2008, sqlserver2012\nGet IO subsystem latency statistics for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$output = Get-DbaIoLatency -SqlInstance sql2008 | Select * | ConvertTo-DbaDataTable\nCollects all IO subsystem latency statistics on server sql2008 into a Data Table.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sql2008\u0027,\u0027sqlserver2012\u0027 | Get-DbaIoLatency\nGet IO subsystem latency statistics for servers sql2008 and sqlserver2012 via pipline\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaIoLatency -SqlInstance sql2008 -SqlCredential $cred\nConnects using sqladmin credential and returns IO subsystem latency statistics from sql2008", "Syntax": "Get-DbaIoLatency [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaLastBackup", "Description": "Retrieves and compares the date/time for the last known backups, as well as the creation date/time for the database.\n\nDefault output includes columns Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup, SinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated.", "Tags": [ "DisasterRecovery", "Backup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "Database", "Specifies one or more database(s) to process. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Specifies one or more database(s) to exclude from processing.", "", false, "false", "" ], [ "EnableException", "If this switch is enabled exceptions will be thrown to the caller, which will need to perform its own exception processing. Otherwise, the function will try to catch the exception, interpret it and \r\nprovide a friendly error message.", "Silent", false, "false", "False" ] ], "Alias": "", "Author": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Get date/time for last known backups of databases.", "Name": "Get-DbaLastBackup", "Links": "https://dbatools.io/Get-DbaLastBackup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987\nReturns a custom object displaying Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup, SinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987\nReturns a custom object with Server name, Database name, and the date the last time backups were performed.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987 | Select *\nReturns a custom object with Server name, Database name, and the date the last time backups were performed, and also recoverymodel and calculations on how long ago backups were taken and what the \r\nstatus is.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987 | Select * | Out-Gridview\nReturns a gridview displaying Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup, SinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated.", "Syntax": "Get-DbaLastBackup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaLastGoodCheckDb", "Description": "Retrieves and compares the date/time for the last known good DBCC CHECKDB, as well as the creation date/time for the database.\n\nThis function supports SQL Server 2005 and higher.\n\nPlease note that this script uses the DBCC DBINFO() WITH TABLERESULTS. DBCC DBINFO has several known weak points, such as:\n- DBCC DBINFO is an undocumented feature/command.\n- The LastKnowGood timestamp is updated when a DBCC CHECKFILEGROUP is performed.\n- The LastKnowGood timestamp is updated when a DBCC CHECKDB WITH PHYSICAL_ONLY is performed.\n- The LastKnowGood timestamp does not get updated when a database in READ_ONLY.\n\nAn empty ($null) LastGoodCheckDb result indicates that a good DBCC CHECKDB has never been performed.\n\nSQL Server 2008R2 has a \"bug\" that causes each databases to possess two dbi_dbccLastKnownGood fields, instead of the normal one.\n\nThis script will only display this function to only display the newest timestamp. If -Verbose is specified, the function will announce every time more than one dbi_dbccLastKnownGood fields is encountered.", "Tags": [ "CHECKDB", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "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", "" ], [ "Database", "Specifies one or more database(s) to process. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Specifies one or more database(s) to exclude from processing.", "", 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": "Jakob Bindslet (jakob@bindslet.dk)", "Synopsis": "Get date/time for last known good DBCC CHECKDB", "Name": "Get-DbaLastGoodCheckDb", "Links": "https://dbatools.io/Get-DbaLastGoodCheckDb", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaLastGoodCheckDb -SqlInstance ServerA\\sql987\nReturns a custom object displaying Server, Database, DatabaseCreated, LastGoodCheckDb, DaysSinceDbCreated, DaysSinceLastGoodCheckDb, Status and DataPurityEnabled\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaLastGoodCheckDb -SqlInstance ServerA\\sql987 -SqlCredential sqladmin | Format-Table -AutoSize\nReturns a formatted table displaying Server, Database, DatabaseCreated, LastGoodCheckDb, DaysSinceDbCreated, DaysSinceLastGoodCheckDb, Status and DataPurityEnabled. Authenticates using SQL Server \r\nauthentication.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLastGoodCheckDb -SqlInstance sql2016 -ExcludeDatabase \"TempDB\" | Format-Table -AutoSize\nReturns a formatted table displaying Server, Database, DatabaseCreated, LastGoodCheckDb, DaysSinceDbCreated, DaysSinceLastGoodCheckDb, Status and DataPurityEnabled. All databases except for \"TempDB\" \r\nwill be displayed in the output.", "Syntax": "Get-DbaLastGoodCheckDb [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaLatchStatistic", "Description": "This command is based off of Paul Randal\u0027s post \"Advanced SQL Server performance tuning\"\n\nReturns:\n LatchClass\n WaitSeconds\n WaitCount\n Percentage\n AverageWaitSeconds\n URL\n\nReference: https://www.sqlskills.com/blogs/paul/advanced-performance-troubleshooting-waits-latches-spinlocks/\n https://www.sqlskills.com/blogs/paul/most-common-latch-classes-and-what-they-mean/", "Tags": [ "LatchStatistics", "Waits" ], "Params": [ [ "SqlInstance", "The SQL Server instance. Server version must be SQL Server version 2005 or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Threshold", "Threshold, in percentage of all latch stats on the system. Default per Paul\u0027s post is 95%.", "", false, "false", "95" ], [ "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": "Patrick Flynn (@sqllensman)", "Synopsis": "Displays latch statistics from sys.dm_os_latch_stats", "Name": "Get-DbaLatchStatistic", "Links": "https://dbatools.io/Get-DbaLatchStatistic", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaLatchStatistic -SqlInstance sql2008, sqlserver2012\nCheck latch statistics for servers sql2008 and sqlserver2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaLatchStatistic -SqlInstance sql2008 -Threshold 98\nCheck latch statistics on server sql2008 for thresholds above 98%\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$output = Get-DbaLatchStatistic -SqlInstance sql2008 -Threshold 100 | Select * | ConvertTo-DbaDataTable\nCollects all latch statistics on server sql2008 into a Data Table.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027sql2008\u0027,\u0027sqlserver2012\u0027 | Get-DbaLatchStatistic\nGet latch statistics for servers sql2008 and sqlserver2012 via pipline\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaLatchStatistic -SqlInstance sql2008 -SqlCredential $cred\nConnects using sqladmin credential and returns latch statistics from sql2008\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$output = Get-DbaLatchStatistic -SqlInstance sql2008\nPS C:\\\u003e $output\r\nPS C:\\\u003e foreach ($row in ($output | Sort-Object -Unique Url)) { Start-Process ($row).Url }\nDisplays the output then loads the associated sqlskills website for each result. Opens one tab per unique URL.", "Syntax": "Get-DbaLatchStatistic [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Threshold] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaLinkedServer", "Description": "Retrieves information about each linked server on the instance(s).", "Tags": [ "LinkedServer", "Linked" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple 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", "" ], [ "LinkedServer", "The linked server(s) to process - this list is auto-populated from the server. If unspecified, all linked servers will be processed.", "", false, "false", "" ], [ "ExcludeLinkedServer", "The linked server(s) to exclude - this list is auto-populated from the server", "", 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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Gets all linked servers and a summary of information from the linked servers listed.", "Name": "Get-DbaLinkedServer", "Links": "https://dbatools.io/Get-DbaLinkedServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaLinkedServer -SqlInstance DEV01\nReturns all linked servers for the SQL Server instance DEV01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance DEV01 -Group SQLDEV | Get-DbaLinkedServer | Out-GridView\nReturns all linked servers for a group of servers from SQL Server Central Management Server (CMS). Send output to GridView.", "Syntax": "Get-DbaLinkedServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-LinkedServer] \u003cObject[]\u003e] [[-ExcludeLinkedServer] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaLocaleSetting", "Description": "Gets the Locale settings on one or more computers.\n\nRequires Local Admin rights on destination computer(s).", "Tags": "OS", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Gets the Locale settings on a computer.", "Name": "Get-DbaLocaleSetting", "Links": "https://dbatools.io/Get-DbaLocaleSetting", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaLocaleSetting -ComputerName sqlserver2014a\nGets the Locale settings on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaLocaleSetting\nGets the Locale settings on computers sql1, sql2 and sql3.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLocaleSetting -ComputerName sql1,sql2 -SqlCredential $credential | Out-Gridview\nGets the Locale settings on computers sql1 and sql2 using SQL Authentication to authenticate to the servers, and shows them in a grid view.", "Syntax": "Get-DbaLocaleSetting [[-ComputerName] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaLogin", "Description": "The Get-DbaLogin function returns an SMO Login object for the logins passed, if there are no users passed it will return all logins.", "Tags": [ "Login", "Security" ], "Params": [ [ "SqlInstance", "TThe target SQL Server instance or instances.You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "", false, "false", "" ], [ "Login", "The login(s) to process - this list is auto-populated from the server. If unspecified, all logins will be processed.", "", false, "false", "" ], [ "IncludeFilter", "A list of logins to include - accepts wildcard patterns", "", false, "false", "" ], [ "ExcludeLogin", "The login(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "ExcludeFilter", "A list of logins to exclude - accepts wildcard patterns", "", false, "false", "" ], [ "NoSystem", "A Switch to remove System Logins from the output.", "", false, "false", "False" ], [ "SQLLogins", "A Switch to return Logins of type SQLLogin only.", "", false, "false", "False" ], [ "WindowsLogins", "A Switch to return Logins of type Windows only.", "", false, "false", "False" ], [ "HasAccess", "A Switch to return Logins that have access to the instance of SQL Server.", "", false, "false", "False" ], [ "Locked", "A Switch to return locked Logins.", "", false, "false", "False" ], [ "Disabled", "A Switch to return disabled Logins.", "", 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": "Mitchell Hamann (@SirCaptainMitch) | Rob Sewell (@SQLDBaWithBeard)", "Synopsis": "Function to get an SMO login object of the logins for a given SQL Instance. Takes a server object from the pipe", "Name": "Get-DbaLogin", "Links": "https://dbatools.io/Get-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016\nGets all the logins from server sql2016 using NT authentication and returns the SMO login objects\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SqlCredential $sqlcred\nGets all the logins for a given SQL Server using a passed credential object and returns the SMO login objects\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SqlCredential $sqlcred -Login dbatoolsuser,TheCaptain\nGet specific logins from server sql2016 returned as SMO login objects.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -IncludeFilter \u0027##*\u0027,\u0027NT *\u0027\nGet all user objects from server sql2016 beginning with \u0027##\u0027 or \u0027NT \u0027, returned as SMO login objects.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -ExcludeLogin dbatoolsuser\nGet all user objects from server sql2016 except the login dbatoolsuser, returned as SMO login objects.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -WindowsLogins\nGet all user objects from server sql2016 that are Windows Logins\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -WindowsLogins -IncludeFilter *Rob*\nGet all user objects from server sql2016 that are Windows Logins and have Rob in the name\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SQLLogins\nGet all user objects from server sql2016 that are SQLLogins\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SQLLogins -IncludeFilter *Rob*\nGet all user objects from server sql2016 that are SQLLogins and have Rob in the name\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -NoSystem\nGet all user objects from server sql2016 that are not system objects\n-------------------------- EXAMPLE 11 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -ExcludeFilter \u0027##*\u0027,\u0027NT *\u0027\nGet all user objects from server sql2016 except any beginning with \u0027##\u0027 or \u0027NT \u0027, returned as SMO login objects.\n-------------------------- EXAMPLE 12 --------------------------\nPS C:\\\u003e\u0027sql2016\u0027, \u0027sql2014\u0027 | Get-DbaLogin -SqlCredential $sqlcred\nUsing Get-DbaLogin on the pipeline, you can also specify which names you would like with -Login.\n-------------------------- EXAMPLE 13 --------------------------\nPS C:\\\u003e\u0027sql2016\u0027, \u0027sql2014\u0027 | Get-DbaLogin -SqlCredential $sqlcred -Locked\nUsing Get-DbaLogin on the pipeline to get all locked logins on servers sql2016 and sql2014.\n-------------------------- EXAMPLE 14 --------------------------\nPS C:\\\u003e\u0027sql2016\u0027, \u0027sql2014\u0027 | Get-DbaLogin -SqlCredential $sqlcred -HasAccess -Disabled\nUsing Get-DbaLogin on the pipeline to get all Disabled logins that have access on servers sql2016 or sql2014.", "Syntax": "Get-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-IncludeFilter \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeFilter \u003cObject[]\u003e] [-NoSystem] [-SQLLogins] [-WindowsLogins] [-HasAccess] [-Locked] [-Disabled] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaMaintenanceSolutionLog", "Description": "Ola wrote a .sql script to get the content from the commandLog table. However, if LogToTable=\u0027N\u0027, there will be no logging in that table. This function reads the text files that are written in the SQL Instance\u0027s Log directory.", "Tags": [ "Ola", "Maintenance" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "LogType", "Accepts \u0027IndexOptimize\u0027, \u0027DatabaseBackup\u0027, \u0027DatabaseIntegrityCheck\u0027. ATM only IndexOptimize parsing is available", "", false, "false", "IndexOptimize" ], [ "Since", "Consider only files generated since this date", "", false, "false", "" ], [ "Path", "Where to search for log files. By default it\u0027s the SQL instance errorlogpath path", "", 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": "Klaas Vandenberghe (@powerdbaklaas) | Simone Bizzotto ( @niphlod )", "Synopsis": "Reads the log files generated by the IndexOptimize Agent Job from Ola Hallengren\u0027s MaintenanceSolution.", "Name": "Get-DbaMaintenanceSolutionLog", "Links": "https://dbatools.io/Get-DbaMaintenanceSolutionLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a\nGets the outcome of the IndexOptimize job on sql instance sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -SqlCredential $credential\nGets the outcome of the IndexOptimize job on sqlserver2014a, using SQL Authentication.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sqlserver2014a\u0027, \u0027sqlserver2020test\u0027 | Get-DbaMaintenanceSolutionLog\nGets the outcome of the IndexOptimize job on sqlserver2014a and sqlserver2020test.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -Path \u0027D:\\logs\\maintenancesolution\\\u0027\nGets the outcome of the IndexOptimize job on sqlserver2014a, reading the log files in their custom location.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -Since \u00272017-07-18\u0027\nGets the outcome of the IndexOptimize job on sqlserver2014a, starting from july 18, 2017.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -LogType IndexOptimize\nGets the outcome of the IndexOptimize job on sqlserver2014a, the other options are not yet available! sorry", "Syntax": "Get-DbaMaintenanceSolutionLog [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-LogType] \u003cString[]\u003e] [[-Since] \u003cDateTime\u003e] [[-Path] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaManagementObject", "Description": "The Get-DbaManagementObject returns an object with the Version and the\nAdd-Type Load Template for each version on the server.", "Tags": "SMO", "Params": [ [ "ComputerName", "The name of the Windows Server(s) you would like to check.", "ServerInstance,SqlServer,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "This command uses Windows credentials. This parameter allows you to connect remotely as a different user.", "", false, "false", "" ], [ "VersionNumber", "This is the specific version number you are looking for. The function will look\r\nfor that version only.", "", false, "false", "0" ], [ "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": "Get-DbaSqlManagementObject", "Author": "Ben Miller (@DBAduck), http://dbaduck.com", "Synopsis": "Gets SQL Mangaement Object versions installed on the machine.", "Name": "Get-DbaManagementObject", "Links": "https://dbatools.io/Get-DbaManagementObject", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaManagementObject\nReturns all versions of SMO on the computer\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaManagementObject -VersionNumber 13\nReturns just the version specified. If the version does not exist then it will return nothing.", "Syntax": "Get-DbaManagementObject [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-VersionNumber] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaMaxMemory", "Description": "This command retrieves the SQL Server \u0027Max Server Memory\u0027 configuration setting as well as the total physical installed on the server.\n\nResults are turned in megabytes (MB).", "Tags": [ "MaxMemory", "Memory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Get-SqlMaxMemory", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the \u0027Max Server Memory\u0027 configuration setting and the memory of the server. Works on SQL Server 2000-2014.", "Name": "Get-DbaMaxMemory", "Links": "https://dbatools.io/Get-DbaMaxMemory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaMaxMemory -SqlInstance sqlcluster, sqlserver2012\nGet memory settings for instances \"sqlcluster\" and \"sqlserver2012\". Returns results in megabytes (MB).\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlcluster | Get-DbaMaxMemory | Where-Object { $_.MaxValue -gt $_.Total }\nFind all servers in Server Central Management Server that have \u0027Max Server Memory\u0027 set to higher than the total memory of the server (think 2147483647)\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eFind-DbaInstance -ComputerName localhost | Get-DbaMaxMemory | Format-Table -AutoSize\nScans localhost for instances using the browser service, traverses all instances and displays memory settings in a formatted table.", "Syntax": "Get-DbaMaxMemory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaMemoryCondition", "Description": "The information from SQL Server ring buffers can be used to determine the memory conditions on the server when paging occurs.\n\nThis command is based on a query provided by Microsoft support.\nReference KB article: https://support.microsoft.com/en-us/help/918483/how-to-reduce-paging-of-buffer-pool-memory-in-the-64-bit-version-of-sq", "Tags": "Memory", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential).", "", 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": "IJeb Reitsma", "Synopsis": "Determine the memory conditions from SQL Server ring buffers.", "Name": "Get-DbaMemoryCondition", "Links": "https://dbatools.io/Get-DbaMemoryCondition", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaMemoryCondition -SqlInstance sqlserver2014a\nReturns the memory conditions for the selected instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a -Group GroupName | Get-DbaMemoryCondition | Out-GridView\nReturns the memory conditions for a group of servers from SQL Server Central Management Server (CMS). Send output to GridView.", "Syntax": "Get-DbaMemoryCondition [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaMemoryUsage", "Description": "Retrieves the amount of memory per performance counter. Default output includes columns Server, counter instance, counter, number of pages, memory in KB, memory in MB\nSSAS and SSIS are included.\n\nSSRS does not have memory counters, only memory shrinks and memory pressure state.\n\nThis function requires local admin role on the targeted computers.", "Tags": "Memory", "Params": [ [ "ComputerName", "The Windows Server that you are connecting to. Note that this will return all instances, but Out-GridView makes it easy to filter to specific instances.", "Host,cn,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the SQL Server as a different user", "", false, "false", "" ], [ "Simple", "Shows a simplified set of counters. Excludes only totals for Plancounters and BufManpagecounters", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Get amount of memory in use by *all* SQL Server components and instances", "Name": "Get-DbaMemoryUsage", "Links": "https://dbatools.io/Get-DbaMemoryUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaMemoryUsage -ComputerName ServerA\nReturns a custom object displaying Server, counter instance, counter, number of pages, memory in KB, memory in MB\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaMemoryUsage -ComputerName ServerA\\sql987 -Simple\nReturns a custom object with Server, counter instance, counter, number of pages, memory in KB, memory in MB\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaMemoryUsage -ComputerName ServerA\\sql987 | Out-Gridview\nReturns a gridview displaying Server, counter instance, counter, number of pages, memory in KB, memory in MB", "Syntax": "Get-DbaMemoryUsage [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Simple] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaModule", "Description": "Quickly find modules (Stored Procs, Functions, Views, Constraints, Rules, Triggers, etc) that have been modified in a database, or across all databases.\nResults will exclude the module definition, but can be queried explicitly.", "Tags": [ "StoredProcedure", "Trigger" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "Database", "The database(s) to process. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude.", "", false, "false", "" ], [ "ModifiedSince", "DateTime value to use as minimum modified date of module.", "", false, "false", "1900-01-01" ], [ "Type", "Limit by specific type of module. Valid choices include: View, TableValuedFunction, DefaultConstraint, StoredProcedure, Rule, InlineTableValuedFunction, Trigger, ScalarFunction", "", false, "false", "" ], [ "NoSystemDb", "Allows you to suppress output on system databases", "", false, "false", "False" ], [ "NoSystemObjects", "Allows you to suppress output on system objects", "", 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": "Get-DbaSqlModule", "Author": "Brandon Abshire, netnerds.net", "Synopsis": "Displays all objects in sys.sys_modules after specified modification date. Works on SQL Server 2008 and above.", "Name": "Get-DbaModule", "Links": "https://dbatools.io/Get-DbaModule", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaModule -SqlInstance sql2008, sqlserver2012\nReturn all modules for servers sql2008 and sqlserver2012 sorted by Database, Modify_Date ASC.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaModule -SqlInstance sql2008, sqlserver2012 | Select *\nShows hidden definition column (informative wall of text).\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaModule -SqlInstance sql2008 -Database TestDB -ModifiedSince \"2017-01-01 10:00:00\"\nReturn all modules on server sql2008 for only the TestDB database with a modified date after 1 January 2017 10:00:00 AM.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaModule -SqlInstance sql2008 -Type View, Trigger, ScalarFunction\nReturn all modules on server sql2008 for all databases that are triggers, views or scalar functions.", "Syntax": "Get-DbaModule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-ModifiedSince] \u003cDateTime\u003e] [[-Type] \u003cString[]\u003e] [-NoSystemDb] [-NoSystemObjects] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaMsdtc", "Description": "Returns a custom object with Computer name, state of the MSDTC Service, security settings of MSDTC and CID\u0027s\n\nRequires: Windows administrator access on Servers", "Tags": [ "Msdtc", "dtc" ], "Params": [ [ "ComputerName", "The target computer.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ] ], "Alias": "", "Author": "Klaas Vandenberghe (@powerdbaklaas)", "Synopsis": "Displays information about the Distributed Transaction Coordinator (MSDTC) on a server", "Name": "Get-DbaMsdtc", "Links": "https://dbatools.io/Get-DbaMsdtc", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaMsdtc -ComputerName srv0042\nGet DTC status for the server srv0042\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$Computers = (Get-Content D:\\configfiles\\SQL\\MySQLInstances.txt | % {$_.split(\u0027\\\u0027)[0]})\nPS C:\\\u003e $Computers | Get-DbaMsdtc\nGet DTC status for all the computers in a .txt file\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaMsdtc -Computername $Computers | where { $_.dtcservicestate -ne \u0027running\u0027 }\nGet DTC status for all the computers where the MSDTC Service is not running\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaMsdtc -ComputerName srv0042 | Out-Gridview\nGet DTC status for the computer srv0042 and show in a grid view", "Syntax": "Get-DbaMsdtc [[-ComputerName] \u003cString[]\u003e] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaNetworkActivity", "Description": "Gets the Current traffic on every Network Interface on a computer.\nSee https://msdn.microsoft.com/en-us/library/aa394293(v=vs.85).aspx\n\nRequires Local Admin rights on destination computer(s).", "Tags": "Network", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Gets the Current traffic on every Network Interface on a computer.", "Name": "Get-DbaNetworkActivity", "Links": "https://dbatools.io/Get-DbaNetworkActivity", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaNetworkActivity -ComputerName sqlserver2014a\nGets the Current traffic on every Network Interface on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaNetworkActivity\nGets the Current traffic on every Network Interface on computers sql1, sql2 and sql3.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaNetworkActivity -ComputerName sql1,sql2 | Out-Gridview\nGets the Current traffic on every Network Interface on computers sql1 and sql2, and shows them in a grid view.", "Syntax": "Get-DbaNetworkActivity [[-ComputerName] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaNetworkCertificate", "Description": "Gets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption", "Tags": "Certificate", "Params": [ [ "ComputerName", "The target SQL Server instance or instances. Defaults to localhost. If target is a cluster, you must specify the distinct nodes.", "ServerInstance,SqlServer,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative credentials.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Simplifies finding computer certificates that are candidates for using with SQL Server\u0027s network encryption", "Name": "Get-DbaNetworkCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaNetworkCertificate\nGets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaNetworkCertificate -ComputerName sql2016\nGets computer certificates on sql2016 that are being used for SQL Server network encryption", "Syntax": "Get-DbaNetworkCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaOpenTransaction", "Description": "This command is based on open transaction script published by Paul Randal.\nReference: https://www.sqlskills.com/blogs/paul/script-open-transactions-with-text-and-plans/", "Tags": [ "Database", "Process", "Session", "ActivityMonitor" ], "Params": [ [ "SqlInstance", "The SQL Server instance", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Connect using alternative credentials", "", 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": "Displays all open transactions.", "Name": "Get-DbaOpenTransaction", "Links": "https://dbatools.io/Get-DbaOpenTransaction", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaOpenTransaction -SqlInstance sqlserver2014a\nReturns open transactions for sqlserver2014a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaOpenTransaction -SqlInstance sqlserver2014a -SqlCredential sqladmin\nLogs into sqlserver2014a using the login \"sqladmin\"", "Syntax": "Get-DbaOpenTransaction [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaOperatingSystem", "Description": "Gets operating system information from the server and returns as an object.", "Tags": [ "ServerInfo", "OperatingSystem" ], "Params": [ [ "ComputerName", "Target computer(s). If no computer name is specified, the local computer is targeted", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Alternate credential object to use for accessing the target computer(s).", "", 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": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Gets operating system information from the server.", "Name": "Get-DbaOperatingSystem", "Links": "https://dbatools.io/Get-DbaOperatingSystem", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaOperatingSystem\nReturns information about the local computer\u0027s operating system\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaOperatingSystem -ComputerName sql2016\nReturns information about the sql2016\u0027s operating system\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\nPS C:\\\u003e \u0027sql2016\u0027, \u0027sql2017\u0027 | Get-DbaOperatingSystem -Credential $wincred\nReturns information about the sql2016 and sql2017 operating systems using alternative Windows credentials\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-Content .\\servers.txt | Get-DbaOperatingSystem\nReturns information about all the servers operating system that are stored in the file. Every line in the file can only contain one hostname for a server.", "Syntax": "Get-DbaOperatingSystem [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaOrphanUser", "Description": "An orphan user is defined by a user that does not have their matching login. (Login property = \"\").", "Tags": [ "Orphan", "Database", "User", "Security", "Login" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server", "", 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": "Claudio Silva (@ClaudioESSilva) | Garry Bargsley (@gbargsley) | Simone Bizzotto (@niphlod)", "Synopsis": "Get orphaned users.", "Name": "Get-DbaOrphanUser", "Links": "https://dbatools.io/Get-DbaOrphanUser", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaOrphanUser -SqlInstance localhost\\sql2016\nFinds all orphan users without matching Logins in all databases present on server \u0027localhost\\sql2016\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaOrphanUser -SqlInstance localhost\\sql2016 -SqlCredential $cred\nFinds all orphan users without matching Logins in all databases present on server \u0027localhost\\sql2016\u0027. SQL Server authentication will be used in connecting to the server.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaOrphanUser -SqlInstance localhost\\sql2016 -Database db1\nFinds orphan users without matching Logins in the db1 database present on server \u0027localhost\\sql2016\u0027.", "Syntax": "Get-DbaOrphanUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPageFileSetting", "Description": "This command uses CIM (or other, related computer management tools) to detect the page file configuration of the target computer(s).\n\nNote that this may require local administrator privileges for the relevant computers.", "Tags": "CIM", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.\r\nThis can be the name of a computer, a SMO object, an IP address, an AD Computer object, a connection string or a SQL Instance.", "cn,host,ServerInstance,Server,SqlServer", false, "true (ByValue, ByPropertyName)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the Computer as a different user", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Returns information on the page file configuration of the target computer.", "Name": "Get-DbaPageFileSetting", "Links": "https://dbatools.io/Get-DbaPageFileSetting", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPageFileSetting -ComputerName ServerA,ServerB\nReturns a custom object displaying ComputerName, AutoPageFile, FileName, Status, LastModified, LastAccessed, AllocatedBaseSize, InitialSize, MaximumSize, PeakUsage, CurrentUsage for ServerA and \r\nServerB\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027ServerA\u0027 | Get-DbaPageFileSetting\nReturns a custom object displaying ComputerName, AutoPageFile, FileName, Status, LastModified, LastAccessed, AllocatedBaseSize, InitialSize, MaximumSize, PeakUsage, CurrentUsage for ServerA", "Syntax": "Get-DbaPageFileSetting [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPbmCategory", "Description": "Returns policy categories from policy based management from an instance.", "Tags": [ "Policy", "PolicyBasedManagement", "PBM" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "Category", "Filters results to only show specific condition", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaPbmStore", "", false, "true (ByValue)", "" ], [ "ExcludeSystemObject", "By default system objects are include. Use this parameter to exclude them.", "", 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": "Returns policy categories from policy based management from an instance.", "Name": "Get-DbaPbmCategory", "Links": "https://dbatools.io/Get-DbaPbmCategory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPbmCategory -SqlInstance sql2016\nReturns all policy categories from the sql2016 PBM server\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPbmCategory -SqlInstance sql2016 -SqlCredential $cred\nUses a credential $cred to connect and return all policy categories from the sql2016 PBM server", "Syntax": "Get-DbaPbmCategory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-ExcludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPbmCategorySubscription", "Description": "Returns policy category subscriptions from policy based management from an instance.", "Tags": [ "Policy", "PolicyBasedManagement", "PBM" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaPbmStore", "", 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": "Returns policy category subscriptions from policy based management from an instance.", "Name": "Get-DbaPbmCategorySubscription", "Links": "https://dbatools.io/Get-DbaPbmCategorySubscription", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPbmCategorySubscription -SqlInstance sql2016\nReturns all policy category subscriptions from the sql2016 PBM server\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPbmCategorySubscription -SqlInstance sql2016 -SqlCredential $cred\nUses a credential $cred to connect and return all policy category subscriptions from the sql2016 PBM server", "Syntax": "Get-DbaPbmCategorySubscription [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPbmCondition", "Description": "Returns conditions from policy based management from an instance.", "Tags": [ "Policy", "PolicyBasedManagement", "PBM" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "Condition", "Filters results to only show specific condition", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaPbmStore", "", false, "true (ByValue)", "" ], [ "IncludeSystemObject", "By default system objects are filtered out. Use this parameter to include them.", "", 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": "Returns conditions from policy based management from an instance.", "Name": "Get-DbaPbmCondition", "Links": "https://dbatools.io/Get-DbaPbmCondition", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPbmCondition -SqlInstance sql2016\nReturns all conditions from the sql2016 PBM server\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPbmCondition -SqlInstance sql2016 -SqlCredential $cred\nUses a credential $cred to connect and return all conditions from the sql2016 PBM server", "Syntax": "Get-DbaPbmCondition [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Condition] \u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-IncludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPbmObjectSet", "Description": "Returns object sets from policy based management.", "Tags": [ "Policy", "PolicyBasedManagement", "PBM" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "ObjectSet", "Filters results to only show specific object set", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaPbmStore", "", false, "true (ByValue)", "" ], [ "IncludeSystemObject", "By default system objects are filtered out. Use this parameter to include them.", "", 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": "Returns object sets from policy based management.", "Name": "Get-DbaPbmObjectSet", "Links": "https://dbatools.io/Get-DbaPbmObjectSet", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPbmObjectSet -SqlInstance sql2016\nReturns all object sets from the sql2016 PBM instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPbmObjectSet -SqlInstance sql2016 -SqlCredential $cred\nUses a credential $cred to connect and return all object sets from the sql2016 PBM instance", "Syntax": "Get-DbaPbmObjectSet [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-ObjectSet] \u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-IncludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPbmPolicy", "Description": "Returns details of policies with the option to filter on Category and SystemObjects.", "Tags": [ "Policy", "PolicyBasedManagement", "PBM" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "Policy", "Filters results to only show specific policy", "", false, "false", "" ], [ "Category", "Filters results to only show policies in the category selected", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaPbmStore", "", false, "true (ByValue)", "" ], [ "IncludeSystemObject", "By default system objects are filtered out. Use this parameter to INCLUDE them .", "", 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": "Get-DbaPolicy", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Returns policies from Policy-Based Management from an instance.", "Name": "Get-DbaPbmPolicy", "Links": "https://dbatools.io/Get-DbaPbmPolicy", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPbmPolicy -SqlInstance sql2016\nReturns all policies from sql2016 server\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPbmPolicy -SqlInstance sql2016 -SqlCredential $cred\nUses a credential $cred to connect and return all policies from sql2016 instance\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPbmPolicy -SqlInstance sql2016 -Category MorningCheck\nReturns all policies from sql2016 server that part of the PolicyCategory MorningCheck", "Syntax": "Get-DbaPbmPolicy [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Policy] \u003cString[]\u003e] [[-Category] \u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-IncludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPbmStore", "Description": "Returns the policy based management store.", "Tags": [ "Policy", "PolicyBasedManagement", "PBM" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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)", "Credential", 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": "Returns the policy based management store.", "Name": "Get-DbaPbmStore", "Links": "https://dbatools.io/Get-DbaPbmStore", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPbmStore -SqlInstance sql2016\nReturn the policy store from the sql2016 instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPbmStore -SqlInstance sql2016 -SqlCredential $cred\nUses a credential $cred to connect and return the policy store from the sql2016 instance", "Syntax": "Get-DbaPbmStore [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPermission", "Description": "Retrieves a list of permissions\n\nPermissions link principals to securables.\nPrincipals exist on Windows, Instance and Database level.\nSecurables exist on Instance and Database level.\nA permission state can be GRANT, DENY or REVOKE.\nThe permission type can be SELECT, CONNECT, EXECUTE and more.\n\nSee https://msdn.microsoft.com/en-us/library/ms191291.aspx for more information", "Tags": [ "Permissions", "Databases" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "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", "" ], [ "Database", "Specifies one or more database(s) to process. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Specifies one or more database(s) to exclude from processing.", "", false, "false", "" ], [ "IncludeServerLevel", "If this switch is enabled, information about Server Level Permissions will be output.", "", false, "false", "False" ], [ "NoSystemObjects", "If this switch is enabled, permissions on system securables will be excluded.", "", false, "false", "False" ], [ "EnableException", "If this switch is enabled exceptions will be thrown to the caller, which will need to perform its own exception processing. Otherwise, the function will try to catch the exception, interpret it and \r\nprovide a friendly error message.", "Silent", false, "false", "False" ] ], "Alias": "", "Author": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Get a list of Server and Database level permissions", "Name": "Get-DbaPermission", "Links": "https://dbatools.io/Get-DbaPermission", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPermission -SqlInstance ServerA\\sql987\nReturns a custom object with Server name, Database name, permission state, permission type, grantee and securable.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPermission -SqlInstance ServerA\\sql987 | Format-Table -AutoSize\nReturns a formatted table displaying Server, Database, permission state, permission type, grantee, granteetype, securable and securabletype.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPermission -SqlInstance ServerA\\sql987 -NoSystemObjects -IncludeServerLevel\nReturns a custom object with Server name, Database name, permission state, permission type, grantee and securable\r\nin all databases and on the server level, but not on system securables.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPermission -SqlInstance sql2016 -Database master\nReturns a custom object with permissions for the master database.", "Syntax": "Get-DbaPermission [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeServerLevel] [-NoSystemObjects] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPfAvailableCounter", "Description": "Gathers list of all available counters on local or remote machines. Note, if you pass a credential object, it will be included in the output for easy reuse in your next piped command.\n\nThanks to Daniel Streefkerk for this super fast way of counters\nhttps://daniel.streefkerkonline.com/2016/02/18/use-powershell-to-list-all-windows-performance-counters-and-their-numeric-ids", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:ComputerName" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "", false, "false", "" ], [ "Pattern", "Specify a pattern for filtering.", "", 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": "Gathers list of all available counters on local or remote machines.", "Name": "Get-DbaPfAvailableCounter", "Links": "https://dbatools.io/Get-DbaPfAvailableCounter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPfAvailableCounter\nGets all available counters on the local machine.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfAvailableCounter -Pattern *sql*\nGets all counters matching sql on the local machine.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfAvailableCounter -ComputerName sql2017 -Pattern *sql*\nGets all counters matching sql on the remote server sql2017.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfAvailableCounter -Pattern *sql*\nGets all counters matching sql on the local machine.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaPfAvailableCounter -Pattern *sql* | Add-DbaPfDataCollectorCounter -CollectorSet \u0027Test Collector Set\u0027 -Collector DataCollector01\nAdds all counters matching \"sql\" to the DataCollector01 within the \u0027Test Collector Set\u0027 CollectorSet.", "Syntax": "Get-DbaPfAvailableCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Pattern] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPfDataCollector", "Description": "Gets Performance Monitor Data Collectors.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "", false, "false", "" ], [ "CollectorSet", "The Collector Set name.", "DataCollectorSet", false, "false", "" ], [ "Collector", "The Collector name.", "DataCollector", false, "false", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSet 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": "Gets Performance Monitor Data Collectors.", "Name": "Get-DbaPfDataCollector", "Links": "https://dbatools.io/Get-DbaPfDataCollector", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollector\nGets all Collectors on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollector -ComputerName sql2017\nGets all Collectors on sql2017.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollector -ComputerName sql2017, sql2016 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nGets all Collectors for the \u0027System Correlation\u0027 CollectorSet on sql2017 and sql2016 using alternative credentials.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Get-DbaPfDataCollector\nGets all Collectors for the \u0027System Correlation\u0027 CollectorSet.", "Syntax": "Get-DbaPfDataCollector [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPfDataCollectorCounter", "Description": "Gets Performance Counters.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "", false, "false", "" ], [ "CollectorSet", "The Collector Set name.", "DataCollectorSet", false, "false", "" ], [ "Collector", "The Collector name.", "DataCollector", false, "false", "" ], [ "Counter", "The Counter name to capture. This must be in the form of \u0027\\Processor(_Total)\\% Processor Time\u0027.", "", false, "false", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSet 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": "Gets Performance Counters.", "Name": "Get-DbaPfDataCollectorCounter", "Links": "https://dbatools.io/Get-DbaPfDataCollectorCounter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounter\nGets all counters for all Collector Sets on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017\nGets all counters for all Collector Sets on on sql2017.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017 -Counter \u0027\\Processor(_Total)\\% Processor Time\u0027\nGets the \u0027\\Processor(_Total)\\% Processor Time\u0027 counter on sql2017.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017, sql2016 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nGets all counters for the \u0027System Correlation\u0027 CollectorSet on sql2017 and sql2016 using alternative credentials.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Get-DbaPfDataCollector | Get-DbaPfDataCollectorCounter\nGets all counters for the \u0027System Correlation\u0027 CollectorSet.", "Syntax": "Get-DbaPfDataCollectorCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [[-Counter] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPfDataCollectorCounterSample", "Description": "Gets Performance Counter Samples.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "", false, "false", "" ], [ "CollectorSet", "The Collector Set name.", "DataCollectorSet", false, "false", "" ], [ "Collector", "The Collector name.", "DataCollector", false, "false", "" ], [ "Counter", "The Counter name. This must be in the form of \u0027\\Processor(_Total)\\% Processor Time\u0027.", "", false, "false", "" ], [ "Continuous", "If this switch is enabled, samples will be retrieved continuously until you press CTRL+C. By default, this command gets only one counter sample. You can use the SampleInterval parameter to set the \r\ninterval for continuous sampling.", "", false, "false", "False" ], [ "ListSet", "Gets the specified performance counter sets on the computers. Enter the names of the counter sets. Wildcards are permitted.", "", false, "false", "" ], [ "MaxSamples", "Specifies the number of samples to get from each counter. The default is 1 sample. To get samples continuously (no maximum sample size), use the Continuous parameter.\nTo collect a very large data set, consider running a Get-DbaPfDataCollectorCounterSample command as a Windows PowerShell background job.", "", false, "false", "0" ], [ "SampleInterval", "Specifies the time between samples in seconds. The minimum value and the default value are 1 second.", "", false, "false", "0" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorCounter 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": "Gets Performance Counter Samples.", "Name": "Get-DbaPfDataCollectorCounterSample", "Links": "https://dbatools.io/Get-DbaPfDataCollectorCounterSample", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample\nGets a single sample for all counters for all Collector Sets on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -Counter \u0027\\Processor(_Total)\\% Processor Time\u0027\nGets a single sample for all counters for all Collector Sets on localhost.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017, sql2016 | Out-GridView -PassThru | Get-DbaPfDataCollectorCounterSample -MaxSamples 10\nGets 10 samples for all counters for all Collector Sets for servers sql2016 and sql2017.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -ComputerName sql2017\nGets a single sample for all counters for all Collector Sets on sql2017.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -ComputerName sql2017, sql2016 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nGets a single sample for all counters for the \u0027System Correlation\u0027 CollectorSet on sql2017 and sql2016 using alternative credentials.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -CollectorSet \u0027System Correlation\u0027\nGets a single sample for all counters for the \u0027System Correlation\u0027 CollectorSet.", "Syntax": "Get-DbaPfDataCollectorCounterSample [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [[-Counter] \u003cString[]\u003e] [-Continuous] [[-ListSet]] [[-MaxSamples] \u003cInt32\u003e] [[-SampleInterval] \u003cInt32\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPfDataCollectorSet", "Description": "Gets Performance Monitor Data Collector Set.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "", false, "false", "" ], [ "CollectorSet", "The Collector set name.", "DataCollectorSet", 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": "Gets Performance Monitor Data Collector Set.", "Name": "Get-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Get-DbaPfDataCollectorSet", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet\nGets all Collector Sets on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2017\nGets all Collector Sets on sql2017.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2017 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nGets the \u0027System Correlation\u0027 CollectorSet on sql2017 using alternative credentials.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet | Select-Object *\nDisplays extra columns and also exposes the original COM object in DataCollectorSetObject.", "Syntax": "Get-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPfDataCollectorSetTemplate", "Description": "Parses Perf Monitor XML templates. Defaults to parsing templates in the dbatools template repository (\\bin\\perfmontemplates\\).", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "Path", "The path to the template directory. Defaults to the dbatools template repository (\\bin\\perfmontemplates\\).", "", false, "false", "\"$script:PSModuleRoot\\bin\\perfmontemplates\\collectorsets\"" ], [ "Pattern", "Specify a pattern for filtering. Alternatively, you can use Out-GridView -Passthru to select objects and pipe them to Import-DbaPfDataCollectorSetTemplate.", "", false, "false", "" ], [ "Template", "Specifies one or more of the templates provided by dbatools. Press tab to cycle through the list to the options.", "", 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": "Parses Perf Monitor templates. Defaults to parsing templates in the dbatools template repository (\\bin\\perfmontemplates\\).", "Name": "Get-DbaPfDataCollectorSetTemplate", "Links": "https://dbatools.io/Get-DbaPfDataCollectorSetTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate\nReturns information about all the templates in the local dbatools repository.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate | Out-GridView -PassThru | Import-DbaPfDataCollectorSetTemplate -ComputerName sql2017 | Start-DbaPfDataCollectorSet\nAllows you to select a template, then deploys it to sql2017 and immediately starts the DataCollectorSet.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate | Select-Object *\nReturns more information about the template, including the full path/filename.", "Syntax": "Get-DbaPfDataCollectorSetTemplate [[-Path] \u003cString[]\u003e] [[-Pattern] \u003cString\u003e] [[-Template] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPlanCache", "Description": "Checks adhoc and prepared plan cache for each database, if over 100 MB you should consider using Remove-DbaQueryPlan to clear the plan caches or turning on \"optimize for adhoc workloads\" configuration if running 2008 or later.\n\nReferences: https://www.sqlskills.com/blogs/kimberly/plan-cache-adhoc-workloads-and-clearing-the-single-use-plan-cache-bloat/\n\nNote: This command returns results from all SQL server instances on the destination server but the process column is specific to -SqlInstance passed.", "Tags": "Memory", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Tracy Boggiano, databasesuperhero.com", "Synopsis": "Provides information about adhoc and prepared plan cache usage", "Name": "Get-DbaPlanCache", "Links": "https://dbatools.io/Get-DbaPlanCache", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPlanCache -SqlInstance sql2017\nReturns the single use plan cache usage information for SQL Server instance 2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPlanCache -SqlInstance sql2017 -SqlCredential sqladmin\nReturns the single use plan cache usage information for SQL Server instance 2017 using login \u0027sqladmin\u0027", "Syntax": "Get-DbaPlanCache [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPowerPlan", "Description": "Gets the Power Plan settings on a computer against best practices recommendations.", "Tags": "PowerPlan", "Params": [ [ "ComputerName", "The server(s) to check Power Plan settings on.", "ServerInstance,SqlServer,SqlInstance", true, "true (ByValue)", "" ], [ "Credential", "Specifies a PSCredential object to use in authenticating to the server(s), instead of the current user account.", "", 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": "Gets the Power Plan settings for compliance with best practices, which recommend High Performance for SQL Server.", "Name": "Get-DbaPowerPlan", "Links": "https://dbatools.io/Get-DbaPowerPlan", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPowerPlan -ComputerName sql2017\nGets the Power Plan settings for sql2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPowerPlan -ComputerName sql2017 -Credential ad\\admin\nGets the Power Plan settings for sql2017 using an alternative credential", "Syntax": "Get-DbaPowerPlan [-ComputerName] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaPrivilege", "Description": "Gets the users with local privileges \u0027Lock Pages in Memory\u0027, \u0027Instant File Initialization\u0027, \u0027Logon as Batch\u0027 on one or more computers.\n\nRequires Local Admin rights on destination computer(s).", "Tags": "Privilege", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Gets the users with local privileges on one or more computers.", "Name": "Get-DbaPrivilege", "Links": "https://dbatools.io/Get-DbaPrivilege", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaPrivilege -ComputerName sqlserver2014a\nGets the local privileges on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaPrivilege\nGets the local privileges on computers sql1, sql2 and sql3.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPrivilege -ComputerName sql1,sql2 | Out-GridView\nGets the local privileges on computers sql1 and sql2, and shows them in a grid view.", "Syntax": "Get-DbaPrivilege [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaProcess", "Description": "This command displays processes associated with a spid, login, host, program or database.\n\nThanks to Michael J Swart at https://sqlperformance.com/2017/07/sql-performance/find-database-connection-leaks for the query to get the last executed SQL statement, minutesasleep and host process ID.", "Tags": [ "Process", "Session", "ActivityMonitor" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "Spid", "Specifies one or more process IDs (Spid) to be displayed. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "ExcludeSpid", "Specifies one ore more process IDs to exclude from display. Options for this parameter are auto-populated from the server.\nThis is the last filter to run, so even if a Spid matches another filter, it will be excluded by this filter.", "", false, "false", "" ], [ "Database", "Specifies one or more databases with active processes to look for. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "Login", "Specifies one or more Login names with active processes to look for. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "Hostname", "Specifies one or more hostnames with active processes to look for. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "Program", "Specifies one or more program names with active processes to look for. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "NoSystemSpid", "If this switch is enabled, system Spids will be ignored.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "This command displays SQL Server processes.", "Name": "Get-DbaProcess", "Links": "https://dbatools.io/Get-DbaProcess", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -Login base\\ctrlb, sa\nShows information about the processes for base\\ctrlb and sa on sqlserver2014a. Windows Authentication is used in connecting to sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -SqlCredential $credential -Spid 56, 77\nShows information about the processes for spid 56 and 57. Uses alternative (SQL or Windows) credentials to authenticate to sqlserver2014a.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -Program \u0027Microsoft SQL Server Management Studio\u0027\nShows information about the processes that were created in Microsoft SQL Server Management Studio.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -Host workstationx, server100\nShows information about the processes that were initiated by hosts (computers/clients) workstationx and server 1000.", "Syntax": "Get-DbaProcess [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Spid] \u003cInt32[]\u003e] [[-ExcludeSpid] \u003cInt32[]\u003e] [[-Database] \u003cString[]\u003e] [[-Login] \u003cString[]\u003e] [[-Hostname] \u003cString[]\u003e] [[-Program] \u003cString[]\u003e] [-NoSystemSpid] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaProductKey", "Description": "Using a string of servers, a text file, or Central Management Server to provide a list of servers, this script will go to each server and get the product key for all installed instances. Clustered instances are supported as well. Requires regular user access to the SQL instances, SMO installed locally, Remote Registry enabled and accessible by the account running the script.\n\nUses key decoder by Jakob Bindslet (http://goo.gl/1jiwcB)", "Tags": "ProductKey", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlInstances", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "SqlCms", "Deprecated, pipe in from Get-DbaCmsRegServer", "", false, "false", "" ], [ "ServersFromFile", "Deprecated, pipe in from Get-Content", "", 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": "Get-DbaSqlProductKey,Get-SqlServerKey", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets SQL Server Product Keys from local or destination SQL Servers. Works with SQL Server 2005-2016", "Name": "Get-DbaProductKey", "Links": "https://dbatools.io/Get-DbaProductKey", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaProductKey -SqlInstance winxp, sqlservera, sqlserver2014a, win2k8\nGets SQL Server versions, editions and product keys for all instances within each server or workstation.", "Syntax": "Get-DbaProductKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-SqlCms] \u003cString\u003e] [[-ServersFromFile] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaQueryExecutionTime", "Description": "Quickly find slow query executions within a database. Results will include stored procedures and individual SQL statements.", "Tags": [ "Query", "Performance" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", 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", "" ], [ "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", "" ], [ "MaxResultsPerDb", "Allows you to limit the number of results returned, as many systems can have very large amounts of query plans. Default value is 100 results.", "", false, "false", "100" ], [ "MinExecs", "Allows you to limit the scope to queries that have been executed a minimum number of time. Default value is 100 executions.", "", false, "false", "100" ], [ "MinExecMs", "Allows you to limit the scope to queries with a specified average execution time. Default value is 500 (ms).", "", false, "false", "500" ], [ "NoSystemDb", "Allows you to suppress output on system databases", "", 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": "Brandon Abshire, netnerds.net", "Synopsis": "Displays Stored Procedures and Ad hoc queries with the highest execution times. Works on SQL Server 2008 and above.", "Name": "Get-DbaQueryExecutionTime", "Links": "https://dbatools.io/Get-DbaQueryExecutionTime", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaQueryExecutionTime -SqlInstance sql2008, sqlserver2012\nReturn the top 100 slowest stored procedures or statements for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaQueryExecutionTime -SqlInstance sql2008 -Database TestDB\nReturn the top 100 slowest stored procedures or statements on server sql2008 for only the TestDB database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaQueryExecutionTime -SqlInstance sql2008 -Database TestDB -MaxResultsPerDb 100 -MinExecs 200 -MinExecMs 1000\nReturn the top 100 slowest stored procedures or statements on server sql2008 for only the TestDB database, limiting results to queries with more than 200 total executions and an execution time over \r\n1000ms or higher.", "Syntax": "Get-DbaQueryExecutionTime [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [[-MaxResultsPerDb] \u003cInt32\u003e] [[-MinExecs] \u003cInt32\u003e] [[-MinExecMs] \u003cInt32\u003e] [[-NoSystemDb]] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRegistryRoot", "Description": "Uses SQL WMI to find the Registry Root of each SQL Server instance on a computer", "Tags": [ "Configuration", "Registry" ], "Params": [ [ "ComputerName", "The target computer. This is not a SQL Server service, though if you pass a named SQL instance, it\u0027ll parse properly down to the computer name", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative Windows credentials", "", 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": "Get-DbaSqlRegistryRoot", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Uses SQL WMI to find the Registry Root of each SQL Server instance on a computer", "Name": "Get-DbaRegistryRoot", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRegistryRoot\nGets the registry root for all instances on localhost\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaRegistryRoot -ComputerName server1\nGets the registry root for all instances on server1", "Syntax": "Get-DbaRegistryRoot [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRepDistributor", "Description": "This function locates and enumerates distributor information for a given SQL Server instance.", "Tags": "Replication", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Get-DbaDistributor", "Author": "William Durkin (@sql_williamd)", "Synopsis": "Gets the information about a replication distributor for a given SQL Server instance.", "Name": "Get-DbaRepDistributor", "Links": "https://dbatools.io/Get-DbaRepDistributor", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRepDistributor -SqlInstance sql2008, sqlserver2012\nRetrieve distributor information for servers sql2008 and sqlserver2012.", "Syntax": "Get-DbaRepDistributor [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRepPublication", "Description": "Quickly find all transactional, merge, and snapshot publications on a specific server or database.", "Tags": "Replication", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "Database", "The database(s) to process. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "PublicationType", "Limit by specific type of publication. Valid choices include: Transactional, Merge, Snapshot", "", false, "false", "" ], [ "EnableException", "byng 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": "Colin Douglas", "Synopsis": "Displays all publications for a server or database.", "Name": "Get-DbaRepPublication", "Links": "https://dbatools.io/Get-DbaRepPublication", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRepPublication -SqlInstance sql2008, sqlserver2012\nReturn all publications for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaRepPublication -SqlInstance sql2008 -Database TestDB\nReturn all publications on server sql2008 for only the TestDB database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaRepPublication -SqlInstance sql2008 -PublicationType Transactional\nReturn all publications on server sql2008 for all databases that have Transactional publications", "Syntax": "Get-DbaRepPublication [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Database] \u003cObject[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-PublicationType] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRepServer", "Description": "Gets a replication server object", "Tags": "Replication", "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "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": "Gets a replication server object", "Name": "Get-DbaRepServer", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRepServer -SqlInstance sql2016\nGets the replication server object for sql2016 using Windows authentication\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaRepServer -SqlInstance sql2016 -SqlCredential repadmin\nGets the replication server object for sql2016 using SQL authentication", "Syntax": "Get-DbaRepServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaResourceGovernor", "Description": "Gets the Resource Governor object", "Tags": "ResourceGovernor", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", 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": "Gets the Resource Governor object", "Name": "Get-DbaResourceGovernor", "Links": "https://dbatools.io/Get-DbaResourceGovernor", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaResourceGovernor -SqlInstance sql2016\nGets the resource governor object of the SqlInstance sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor\nGets the resource governor object on Sql1 and Sql2/sqlexpress instances", "Syntax": "Get-DbaResourceGovernor [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRgClassifierFunction", "Description": "Gets the Resource Governor custom classifier Function which is used for customize the workload groups usage", "Tags": [ "Migration", "ResourceGovernor" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "InputObject", "Allows input to be piped from Get-DbaResourceGovernor", "", 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": "Alessandro Alpi (@suxstellino), alessandroalpi.blog", "Synopsis": "Gets the Resource Governor custom classifier Function", "Name": "Get-DbaRgClassifierFunction", "Links": "https://dbatools.io/Get-DbaRgClassifierFunction", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRgClassifierFunction -SqlInstance sql2016\nGets the classifier function from sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor | Get-DbaRgClassifierFunction\nGets the classifier function object on Sql1 and Sql2/sqlexpress instances", "Syntax": "Get-DbaRgClassifierFunction [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \u003cResourceGovernor[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRgResourcePool", "Description": "Gets Resource Governor Pool objects, including internal or external", "Tags": "ResourceGovernor", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", false, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Type", "Internal or External", "", false, "false", "Internal" ], [ "InputObject", "Allows input to be piped from Get-DbaResourceGovernor", "", 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": "Gets Resource Governor Pool objects, including internal or external", "Name": "Get-DbaRgResourcePool", "Links": "https://dbatools.io/Get-DbaRgResourcePool", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRgResourcePool -SqlInstance sql2016\nGets the internal resource pools on sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor | Get-DbaRgResourcePool\nGets the internal resource pools on Sql1 and Sql2/sqlexpress instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor | Get-DbaRgResourcePool -Type External\nGets the external resource pools on Sql1 and Sql2/sqlexpress instances", "Syntax": "Get-DbaRgResourcePool [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Type] \u003cString\u003e] [[-InputObject] \u003cResourceGovernor[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRgWorkloadGroup", "Description": "Gets all Resource Governor Pool objects, including both internal and external", "Tags": "ResourceGovernor", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", false, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "InputObject", "Allows input to be piped from Get-DbaRgResourcePool", "", 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": "Gets all Resource Governor Pool objects, including both internal and external", "Name": "Get-DbaRgWorkloadGroup", "Links": "https://dbatools.io/Get-DbaRgWorkloadGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRgWorkloadGroup -SqlInstance sql2017\nGets the workload groups on sql2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaResourceGovernor -SqlInstance sql2017 | Get-DbaRgResourcePool | Get-DbaRgWorkloadGroup\nGets the workload groups on sql2017", "Syntax": "Get-DbaRgWorkloadGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \u003cResourcePool[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaRunningJob", "Description": "This function returns agent jobs that active on the SQL Server instance when calling the command", "Tags": [ "Agent", "Job" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", false, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaAgentJob", "", 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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Returns all non-idle Agent jobs running on the server", "Name": "Get-DbaRunningJob", "Links": "https://dbatools.io/Get-DbaRunningJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaRunningJob -SqlInstance sql2017\nReturns any active jobs on sql2017\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2017, sql2019 | Get-DbaRunningJob\nReturns all active jobs on multiple instances piped into the function.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers | Get-DbaRunningJob\nReturns all active jobs on multiple instances piped into the function.", "Syntax": "Get-DbaRunningJob [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \u003cJob[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSchemaChangeHistory", "Description": "Queries the default system trace for any DDL changes in the specified time frame\nOnly works with SQL 2005 and later, as the system trace didn\u0027t exist before then", "Tags": [ "Migration", "Backup", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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)", "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", "" ], [ "Since", "A date from which DDL changes should be returned. Default is to start at the beginning of the current trace file", "", false, "false", "" ], [ "Object", "The name of a SQL Server object you want to look for changes on", "", 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": "Stuart Moore (@napalmgram - http://stuart-moore.com)", "Synopsis": "Gets DDL changes logged in the system trace.", "Name": "Get-DbaSchemaChangeHistory", "Links": "https://dbatools.io/Get-DbaSchemaChangeHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost\nReturns all DDL changes made in all databases on the SQL Server instance localhost since the system trace began\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost -Since (Get-Date).AddDays(-7)\nReturns all DDL changes made in all databases on the SQL Server instance localhost in the last 7 days\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance, Prod -Since (Get-Date).AddDays(-7)\nReturns all DDL changes made in the Prod and Finance databases on the SQL Server instance localhost in the last 7 days\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance -Object AccountsTable -Since (Get-Date).AddDays(-7)\nReturns all DDL changes made to the AccountsTable object in the Finance database on the SQL Server instance localhost in the last 7 days", "Syntax": "Get-DbaSchemaChangeHistory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-Since \u003cDbaDateTime\u003e] [-Object \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerAudit", "Description": "The Get-DbaServerAudit command gets SQL Security Audit information for each instance(s) of SQL Server.", "Tags": [ "Audit", "Security", "SqlAudit" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", 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", "" ], [ "Audit", "Return only specific audits", "", false, "false", "" ], [ "ExcludeAudit", "Exclude specific audits", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Security Audit information for each instance(s) of SQL Server.", "Name": "Get-DbaServerAudit", "Links": "https://dbatools.io/Get-DbaServerAudit", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerAudit -SqlInstance localhost\nReturns all Security Audits on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaServerAudit -SqlInstance localhost, sql2016\nReturns all Security Audits for the local and sql2016 SQL Server instances", "Syntax": "Get-DbaServerAudit [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Audit \u003cString[]\u003e] [-ExcludeAudit \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerAuditSpecification", "Description": "The Get-DbaServerAuditSpecification command gets SQL Security Audit Specification information for each instance(s) of SQL Server.", "Tags": [ "Audit", "Security", "SqlAudit" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Security Audit Specification information for each instance(s) of SQL Server.", "Name": "Get-DbaServerAuditSpecification", "Links": "https://dbatools.io/Get-DbaServerAuditSpecification", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerAuditSpecification -SqlInstance localhost\nReturns all Security Audit Specifications on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaServerAuditSpecification -SqlInstance localhost, sql2016\nReturns all Security Audit Specifications for the local and sql2016 SQL Server instances", "Syntax": "Get-DbaServerAuditSpecification [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerInstallDate", "Description": "This command returns:\nSqlInstallDate\nWindowsInstallDate (use -IncludeWindows)", "Tags": "Install", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,ComputerName", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server using SQL Authentication as a different user", "", false, "false", "" ], [ "Credential", "Credential object used to connect to the SQL Server as a different Windows user", "", false, "false", "" ], [ "IncludeWindows", "Includes the Windows Server Install date information", "", 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": "Mitchell Hamann (@SirCaptainMitch), mitchellhamann.com", "Synopsis": "Returns the install date of a SQL Instance and Windows Server.", "Name": "Get-DbaServerInstallDate", "Links": "https://dbatools.io/Get-DbaServerInstallDate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance SqlBox1\\Instance2\nReturns an object with SQL Instance Install date as a string.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance winserver\\sqlexpress, sql2016\nReturns an object with SQL Instance Install date as a string for both SQLInstances that are passed to the cmdlet.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sqlserver2014a\u0027, \u0027sql2016\u0027 | Get-DbaServerInstallDate\nReturns an object with SQL Instance Install date as a string for both SQLInstances that are passed to the cmdlet via the pipeline.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance sqlserver2014a, sql2016 -IncludeWindows\nReturns an object with the Windows Install date and the SQL install date as a string.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2014 | Get-DbaServerInstallDate\nReturns an object with SQL Instance install date as a string for every server listed in the Central Management Server on sql2014", "Syntax": "Get-DbaServerInstallDate [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-IncludeWindows] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerProtocol", "Description": "Gets the SQL Server related server protocols on one or more computers.\n\nRequires Local Admin rights on destination computer(s).\nThe server protocols can be enabled and disabled when retrieved via WSMan.", "Tags": "Protocol", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", 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": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Gets the SQL Server related server protocols on a computer.", "Name": "Get-DbaServerProtocol", "Links": "https://dbatools.io/Get-DbaServerProtocol", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerProtocol -ComputerName sqlserver2014a\nGets the SQL Server related server protocols on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaServerProtocol\nGets the SQL Server related server protocols on computers sql1, sql2 and sql3.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaServerProtocol -ComputerName sql1,sql2 | Out-GridView\nGets the SQL Server related server protocols on computers sql1 and sql2, and shows them in a grid view.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e(Get-DbaServerProtocol -ComputerName sql1 | Where { $_.DisplayName = \u0027via\u0027 }).Disable()\nDisables the VIA ServerNetworkProtocol on computer sql1.\r\nIf successful, return code 0 is shown.", "Syntax": "Get-DbaServerProtocol [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerRole", "Description": "Gets the list of server-level roles for SQL Server instance.", "Tags": [ "ServerRole", "Security" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2005 or higher.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "ServerRole", "Server-Level role to filter results to that role only.", "", false, "false", "" ], [ "ExcludeServerRole", "Server-Level role to exclude from results.", "", false, "false", "" ], [ "ExcludeFixedRole", "Filter the fixed server-level roles. Only applies to SQL Server 2017 that supports creation of server-level roles.", "", false, "false", "False" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because \r\nit basically disables advanced scripting. Using 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": "Shawn Melton (@wsmelton)", "Synopsis": "Gets the list of server-level roles.", "Name": "Get-DbaServerRole", "Links": "https://dbatools.io/Get-DbaServerRole", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerRole -SqlInstance sql2016a\nOutputs list of server-level roles for sql2016a instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaServerRole -SqlInstance sql2017a -ExcludeFixedRole\nOutputs the server-level role(s) that are not fixed roles on sql2017a instance.", "Syntax": "Get-DbaServerRole [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-ServerRole \u003cString[]\u003e] [-ExcludeServerRole \u003cString[]\u003e] [-ExcludeFixedRole] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerRoleMember", "Description": "The Get-DbaServerRoleMember returns connected SMO object for server roles for each instance(s) of SQL Server.", "Tags": [ "ServerRole", "Security", "Login" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", "Credential", false, "false", "" ], [ "ServerRole", "The role(s) to process. If unspecified, all roles will be processed.", "", false, "false", "" ], [ "ExcludeServerRole", "The role(s) to exclude.", "", false, "false", "" ], [ "Login", "The login(s) to process. If unspecified, all logins will be processed.", "", false, "false", "" ], [ "ExcludeFixedRole", "Filter the fixed server-level roles. Only applies to SQL Server 2017 that supports creation of server-level roles.", "", 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": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Get members of server roles for each instance(s) of SQL Server.", "Name": "Get-DbaServerRoleMember", "Links": "https://dbatools.io/Get-DbaServerRoleMember", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerRoleMember -SqlInstance localhost\nReturns all members of all server roles on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaServerRoleMember -SqlInstance localhost, sql2016\nReturns all members of all server roles on the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$servers = Get-Content C:\\servers.txt\nPS C:\\\u003e $servers | Get-DbaServerRoleMember\nReturns all members of all server roles for every server in C:\\servers.txt\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaServerRoleMember -SqlInstance localhost -ServerRole \u0027sysadmin\u0027, \u0027dbcreator\u0027\nReturns all members of the sysadmin or dbcreator roles on localhost.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaServerRoleMember -SqlInstance localhost -ExcludeServerRole \u0027sysadmin\u0027\nReturns all members of server-level roles other than sysadmin.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaServerRoleMember -SqlInstance sql2017a -ExcludeFixedRole\nReturns all members of server-level role(s) that are not fixed roles on sql2017a instance.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaServerRoleMember -SqlInstance localhost -Login \u0027MyFriendlyDeveloper\u0027\nReturns all server-level role(s) for the MyFriendlyDeveloper login on localhost.", "Syntax": "Get-DbaServerRoleMember [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-ServerRole \u003cString[]\u003e] [-ExcludeServerRole \u003cString[]\u003e] [-Login \u003cObject[]\u003e] [-ExcludeFixedRole] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaServerTrigger", "Description": "Get all existing server triggers on one or more SQL instances.", "Tags": [ "Database", "Trigger" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "", 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": "Get all existing server triggers on one or more SQL instances.", "Name": "Get-DbaServerTrigger", "Links": "https://dbatools.io/Get-DbaServerTrigger", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaServerTrigger -SqlInstance sql2017\nReturns all server triggers on sql2017", "Syntax": "Get-DbaServerTrigger [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaService", "Description": "Gets the SQL Server related services on one or more computers.\n\nRequires Local Admin rights on destination computer(s).", "Tags": [ "Service", "SqlServer", "Instance", "Connect" ], "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "InstanceName", "Only returns services that belong to the specific instances.", "Instance", false, "false", "" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", false, "false", "" ], [ "Type", "Use -Type to collect only services of the desired SqlServiceType.\r\nCan be one of the following: \"Agent\",\"Browser\",\"Engine\",\"FullText\",\"SSAS\",\"SSIS\",\"SSRS\"", "", false, "false", "" ], [ "ServiceName", "Can be used to specify service names explicitly, without looking for service types/instances.", "", false, "false", "" ], [ "AdvancedProperties", "Collect additional properties from the SqlServiceAdvancedProperty Namespace\r\nThis collects information about Version, Service Pack Level\", SkuName, Clustered status and the Cluster Service Name\r\nThis adds additional overhead to the command.", "", 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": "Get-DbaSqlService", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Gets the SQL Server related services on a computer.", "Name": "Get-DbaService", "Links": "https://dbatools.io/Get-DbaService", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaService -ComputerName sqlserver2014a\nGets the SQL Server related services on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaService -AdvancedProperties\nGets the SQL Server related services on computers sql1, sql2 and sql3. Includes Advanced Properties from the SqlServiceAdvancedProperty Namespace\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$cred = Get-Credential WindowsUser\nPS C:\\\u003e Get-DbaService -ComputerName sql1,sql2 -Credential $cred | Out-GridView\nGets the SQL Server related services on computers sql1 and sql2 via the user WindowsUser, and shows them in a grid view.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaService -ComputerName sql1,sql2 -InstanceName MSSQLSERVER\nGets the SQL Server related services related to the default instance MSSQLSERVER on computers sql1 and sql2.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaService -ComputerName $MyServers -Type SSRS\nGets the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$MyServers = Get-Content .\\servers.txt\nPS C:\\\u003e Get-DbaService -ComputerName $MyServers -ServiceName MSSQLSERVER,SQLSERVERAGENT\nGets the SQL Server related services with ServiceName MSSQLSERVER or SQLSERVERAGENT for all the servers that are stored in the file. Every line in the file can only contain one hostname for a server.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$services = Get-DbaService -ComputerName sql1 -Type Agent,Engine\nPS C:\\\u003e $services.ChangeStartMode(\u0027Manual\u0027)\nGets the SQL Server related services of types Sql Agent and DB Engine on computer sql1 and changes their startup mode to \u0027Manual\u0027.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003e(Get-DbaService -ComputerName sql1 -Type Engine).Restart($true)\nCalls a Restart method for each Engine service on computer sql1.", "Syntax": "Get-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Credential \u003cPSCredential\u003e] [-Type \u003cString[]\u003e] [-AdvancedProperties] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-ServiceName \u003cString[]\u003e] [-AdvancedProperties] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSpConfigure", "Description": "This function returns server level system configuration (sys.configuration/sp_configure) information. The information is gathered through SMO Configuration.Properties.\nThe data includes the default value for each configuration, for quick identification of values that may have been changed.", "Tags": [ "SpConfig", "Configure", "Configuration" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "Return only specific configurations. Name can be either values from (sys.configuration/sp_configure) or from SMO object", "Config,ConfigName", false, "false", "" ], [ "ExcludeName", "Exclude specific configurations. Name can be either values from (sys.configuration/sp_configure) or from SMO object", "", 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": "Nic Cain, https://sirsql.net/", "Synopsis": "Returns all server level system configuration (sys.configuration/sp_configure) information", "Name": "Get-DbaSpConfigure", "Links": "https://dbatools.io/Get-DbaSpConfigure", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance localhost\nReturns all system configuration information on the localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaSpConfigure\nReturns system configuration information on multiple instances piped into the function\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance sql2012 -Name \u0027max server memory (MB)\u0027\nReturns only the system configuration for MaxServerMemory on sql2012.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance sql2012 -ExcludeName \u0027max server memory (MB)\u0027, RemoteAccess | Out-GridView\nReturns system configuration information on sql2012 but excludes for max server memory (MB) and remote access. Values returned in grid view\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$cred = Get-Credential SqlCredential\nPS C:\\\u003e \u0027sql2012\u0027 | Get-DbaSpConfigure -SqlCredential $cred -Name RemoteAccess, \u0027max server memory (MB)\u0027 -ExcludeName \u0027remote access\u0027 | Out-GridView\nReturns system configuration information on sql2012 using SQL Server Authentication. Only MaxServerMemory is returned as RemoteAccess was also excluded.", "Syntax": "Get-DbaSpConfigure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Name \u003cString[]\u003e] [-ExcludeName \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSpinLockStatistic", "Description": "This command is based off of Paul Randal\u0027s post \"Advanced SQL Server performance tuning\"\n\nReturns:\n SpinLockName\n Collisions\n Spins\n SpinsPerCollision\n SleepTime\n Backoffs\n\nReference: https://www.sqlskills.com/blogs/paul/advanced-performance-troubleshooting-waits-latches-spinlocks/", "Tags": [ "SpinLockStatistics", "Waits" ], "Params": [ [ "SqlInstance", "The SQL Server instance. Server version must be SQL Server version 2008 or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Patrick Flynn (@sqllensman)", "Synopsis": "Displays information from sys.dm_os_spinlock_stats. Works on SQL Server 2008 and above.", "Name": "Get-DbaSpinLockStatistic", "Links": "https://dbatools.io/Get-DbaSpinLockStatistic", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSpinLockStatistic -SqlInstance sql2008, sqlserver2012\nGet SpinLock Statistics for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$output = Get-DbaSpinLockStatistic -SqlInstance sql2008 | Select * | ConvertTo-DbaDataTable\nCollects all SpinLock Statistics on server sql2008 into a Data Table.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027sql2008\u0027,\u0027sqlserver2012\u0027 | Get-DbaSpinLockStatistic\nGet SpinLock Statistics for servers sql2008 and sqlserver2012 via pipline\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Get-DbaSpinLockStatistic -SqlInstance sql2008 -SqlCredential $cred\nConnects using sqladmin credential and returns SpinLock Statistics from sql2008", "Syntax": "Get-DbaSpinLockStatistic [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSpn", "Description": "Get a list of set SPNs. SPNs are set at the AD account level. You can either retrieve set SPNs for a computer, or any SPNs set for\na given active directory account. You can query one, or both. You\u0027ll get a list of every SPN found for either search term.", "Tags": "SPN", "Params": [ [ "ComputerName", "The servers you want to return set SPNs for. This is defaulted automatically to localhost.", "", false, "true (ByValue)", "" ], [ "AccountName", "The accounts you want to retrieve set SPNs for.", "", false, "false", "" ], [ "Credential", "User credential to connect to the remote servers or active directory.", "", 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": "Drew Furgiuele (@pittfurg), http://www.port1433.com", "Synopsis": "Returns a list of set service principal names for a given computer/AD account", "Name": "Get-DbaSpn", "Links": "https://dbatools.io/Get-DbaSpn", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSpn -ComputerName SQLSERVERA -Credential ad\\sqldba\nReturns a custom object with SearchTerm (ServerName) and the SPNs that were found\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaSpn -AccountName domain\\account -Credential ad\\sqldba\nReturns a custom object with SearchTerm (domain account) and the SPNs that were found\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaSpn -ComputerName SQLSERVERA,SQLSERVERB -Credential ad\\sqldba\nReturns a custom object with SearchTerm (ServerName) and the SPNs that were found for multiple computers", "Syntax": "Get-DbaSpn [[-ComputerName] \u003cString[]\u003e] [[-AccountName] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSsisEnvironmentVariable", "Description": "This command gets all variables from specified environment from SSIS Catalog. All sensitive values are decrypted.\nThe function communicates directly with SSISDB database, \"SQL Server Integration Services\" service isn\u0027t queried there.\nEach parameter (besides SqlInstance and SqlCredential) acts as the filter to only include or exclude particular element", "Tags": [ "SSIS", "SSISDB", "Variable" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.\r\nThis can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "SqlServer,ServerInstance", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Environment", "The SSIS Environments names that we want to get variables from", "", false, "false", "" ], [ "EnvironmentExclude", "The SSIS Environments to exclude. Acts as a filter for environments, best used without \u0027Environment\u0027 parameter\r\nto get variables for all environments but excluded ones", "", false, "false", "" ], [ "Folder", "The Folders names that contain the environments", "", false, "false", "" ], [ "FolderExclude", "The Folders names to exclude. Acts as a filter for folders containing environments, best user without \u0027Folder\u0027 parameter\r\nto get variables for all folders but excluded ones", "", 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": "Bartosz Ratajczyk (@b_ratajczyk)", "Synopsis": "This command gets specified SSIS Environment and all its variables", "Name": "Get-DbaSsisEnvironmentVariable", "Links": "https://dbatools.io/Get-DbaSsisEnvironmentVariable", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV -Folder DWH_ETL\nGets variables of \u0027DEV\u0027 environment located in \u0027DWH_ETL\u0027 folder on \u0027localhost\u0027 Server\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV -Folder DWH_ETL, DEV2, QA\nGets variables of \u0027DEV\u0027 environment(s) located in folders \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV -FolderExclude DWH_ETL, DEV2, QA\nGets variables of \u0027DEV\u0027 environments located in folders other than \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV, PROD -Folder DWH_ETL, DEV2, QA\nGets variables of \u0027DEV\u0027 and \u0027PROD\u0027 environment(s) located in folders \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -EnvironmentExclude DEV, PROD -Folder DWH_ETL, DEV2, QA\nGets variables of environments other than \u0027DEV\u0027 and \u0027PROD\u0027 located in folders \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -EnvironmentExclude DEV, PROD -FolderExclude DWH_ETL, DEV2, QA\nGets variables of environments other than \u0027DEV\u0027 and \u0027PROD\u0027 located in folders other than \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e\u0027localhost\u0027 | Get-DbaSsisEnvironmentVariable -EnvironmentExclude DEV, PROD\nGets all SSIS environments except \u0027DEV\u0027 and \u0027PROD\u0027 from \u0027localhost\u0027 server. The server name comes from pipeline\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003e\u0027SRV1\u0027, \u0027SRV3\u0027 | Get-DbaSsisEnvironmentVariable\nGets all SSIS environments from \u0027SRV1\u0027 and \u0027SRV3\u0027 servers. The server\u0027s names come from pipeline\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003e\u0027SRV1\u0027, \u0027SRV2\u0027 | Get-DbaSsisEnvironmentVariable DEV | Out-GridView\nGets all variables from \u0027DEV\u0027 Environment(s) on servers \u0027SRV1\u0027 and \u0027SRV2\u0027 and outputs it as the GridView.\r\nThe server names come from the pipeline.\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003e\u0027localhost\u0027 | Get-DbaSsisEnvironmentVariable -EnvironmentExclude DEV, PROD | Select-Object -Property Name, Value | Where-Object {$_.Name -match \u0027^a\u0027} | Out-GridView\nGets all variables from Environments other than \u0027DEV\u0027 and \u0027PROD\u0027 on \u0027localhost\u0027 server,\r\nselects Name and Value properties for variables that names start with letter \u0027a\u0027 and outputs it as the GridView", "Syntax": "Get-DbaSsisEnvironmentVariable [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Environment] \u003cObject[]\u003e] [[-EnvironmentExclude] \u003cObject[]\u003e] [[-Folder] \u003cObject[]\u003e] [[-FolderExclude] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSsisExecutionHistory", "Description": "This command gets execution history for SSIS executison given one or more instances and can be filtered by Project, Environment,Folder or Status.", "Tags": [ "Migration", "SSIS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.\r\nThis can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Since", "Datetime object used to narrow the results to a date", "", false, "false", "" ], [ "Status", "Specifies a filter by status (created,running,cancelled,failed,pending,halted,succeeded,stopping,completed)", "", false, "false", "" ], [ "Project", "Specifies a filter by project", "", false, "false", "" ], [ "Folder", "Specifies a filter by folder", "", false, "false", "" ], [ "Environment", "Specifies a filter by environment", "", 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": "Chris Tucker (@ChrisTuc47368095)", "Synopsis": "Get-DbaSsisHistory Retreives SSIS project and package execution History, and environments from one SQL Server to another.", "Name": "Get-DbaSsisExecutionHistory", "Links": "https://dbatools.io/Get-DbaSsisExecutionHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSsisExecutionHistory -SqlInstance SMTQ01 -Folder SMTQ_PRC\nGet all history items for SMTQ01 in folder SMTQ_PRC.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaSsisExecutionHistory -SqlInstance SMTQ01 -Status Failed,Cancelled\nGets all failed or canceled executions for SMTQ01.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaSsisExecutionHistory -SqlInstance SMTQ01,SMTQ02 -Status Failed,Cancelled -Whatif\nShows what would happen if the command were executed and would return the SQL statement that would be executed per instance.", "Syntax": "Get-DbaSsisExecutionHistory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Since] \u003cDateTime\u003e] [[-Status] \u003cString[]\u003e] [[-Project] \u003cString[]\u003e] [[-Folder] \u003cString[]\u003e] [[-Environment] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaStartupParameter", "Description": "Displays values for a detailed list of SQL Server Startup Parameters including Master Data Path, Master Log path, Error Log, Trace Flags, Parameter String and much more.\n\nThis command relies on remote Windows Server (SQL WMI/WinRm) access. You can pass alternative Windows credentials by using the -Credential parameter.\n\nSee https://msdn.microsoft.com/en-us/library/ms190737.aspx for more information.", "Tags": [ "WSMan", "SQLWMI", "Memory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Credential", "Allows you to login to servers using alternate Windows credentials.\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "SqlCredential", false, "false", "" ], [ "Simple", "If this switch is enabled, simplified output will be produced including only Server, Master Data Path, Master Log path, ErrorLog, TraceFlags and ParameterString.", "", false, "false", "False" ], [ "EnableException", "If this switch is enabled, exceptions will be thrown to the caller, which will need to perform its own exception processing. Otherwise, the function will try to catch the exception, interpret it and \r\nprovide a friendly error message.", "Silent", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Displays values for a detailed list of SQL Server Startup Parameters.", "Name": "Get-DbaStartupParameter", "Links": "https://dbatools.io/Get-DbaStartupParameter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaStartupParameter -SqlInstance sql2014\nLogs into SQL WMI as the current user then displays the values for numerous startup parameters.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\nPS C:\\\u003e Get-DbaStartupParameter -SqlInstance sql2014 -Credential $wincred -Simple\nLogs in to WMI using the ad\\sqladmin credential and gathers simplified information about the SQL Server Startup Parameters.", "Syntax": "Get-DbaStartupParameter [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Simple] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaSuspectPage", "Description": "This function returns any records that were stored due to suspect pages in databases on a SQL Server Instance.", "Tags": [ "Pages", "DBCC" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Database", "The database to return. If unspecified, all records will be returned.", "", false, "false", "" ], [ "SqlCredential", "A credential to use to connect to the SQL Instance rather than using Windows Authentication", "", 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": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Returns data that is stored in SQL for Suspect Pages on the specified SQL Server Instance", "Name": "Get-DbaSuspectPage", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaSuspectPage -SqlInstance sql2016\nRetrieve any records stored for Suspect Pages on the sql2016 SQL Server.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaSuspectPage -SqlInstance sql2016 -Database Test\nRetrieve any records stored for Suspect Pages on the sql2016 SQL Server and the Test database only.", "Syntax": "Get-DbaSuspectPage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Database \u003cObject\u003e] [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaTcpPort", "Description": "By default, this function returns just the TCP port used by the specified SQL Server.\n\nIf -All is specified, the server name, IPAddress (ipv4 and ipv6), port number and an indicator of whether or not the port assignment is static are returned.\n\nRemote sqlwmi is used by default. If this doesn\u0027t work, then remoting is used. If neither work, it defaults to T-SQL which can provide only the port.", "Tags": [ "SQLWMI", "tcp" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to connect to servers using alternate Windows credentials\n$scred = Get-Credential, then pass $scred object to the -SqlCredential parameter.", "Credential", false, "false", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release. Use All instead.", "", false, "false", "False" ], [ "All", "If this switch is enabled, an object with server name, IPAddress (ipv4 and ipv6), port and static ($true/$false) for one or more SQL Servers is returned.", "", false, "false", "False" ], [ "ExcludeIpv6", "If this switch is enabled, IPv6 information is excluded from All output.", "Ipv4", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns the TCP port used by the specified SQL Server.", "Name": "Get-DbaTcpPort", "Links": "https://dbatools.io/Get-DbaTcpPort", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaTcpPort -SqlInstance sqlserver2014a\nReturns just the port number for the default instance on sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaTcpPort -SqlInstance winserver\\sqlexpress, sql2016\nReturns an object with server name and port number for the sqlexpress on winserver and the default instance on sql2016.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTcpPort -SqlInstance sqlserver2014a, sql2016 -All\nReturns an object with server name, IPAddress (ipv4 and ipv6), port and static ($true/$false) for sqlserver2014a and sql2016.\nRemote sqlwmi is used by default. If this doesn\u0027t work, then remoting is used. If neither work, it defaults to T-SQL which can provide only the port.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2014 | Get-DbaTcpPort -ExcludeIpv6 -All\nReturns an object with server name, IPAddress (just ipv4), port and static ($true/$false) for every server listed in the Central Management Server on sql2014.", "Syntax": "Get-DbaTcpPort [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Detailed] [-All] [-ExcludeIpv6] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaTempdbUsage", "Description": "This function queries DMVs for running sessions using tempdb and returns results if those sessions have user or internal space allocated or deallocated against them.", "Tags": [ "Tempdb", "Space" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "If you want to use alternative credentials to connect to the server.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Tempdb usage for running queries.", "Name": "Get-DbaTempdbUsage", "Links": "https://dbatools.io/Get-DbaTempdbUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaTempdbUsage -SqlInstance localhost\\SQLDEV2K14\nGets tempdb usage for localhost\\SQLDEV2K14", "Syntax": "Get-DbaTempdbUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbatoolsConfig", "Description": "Retrieves configuration elements by name.\nCan be used to search the existing configuration list.", "Tags": [ "Config", "Module" ], "Params": [ [ "FullName", "Default: \"*\"\r\nSearch for configurations using the full name", "", false, "false", "*" ], [ "Name", "Default: \"*\"\r\nThe name of the configuration element(s) to retrieve.\r\nMay be any string, supports wildcards.", "", false, "false", "*" ], [ "Module", "Default: \"*\"\r\nSearch configuration by module.", "", false, "false", "*" ], [ "Force", "Overrides the default behavior and also displays hidden configuration values.", "", false, "false", "False" ] ], "Alias": "Get-DbaConfig", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Retrieves configuration elements by name.", "Name": "Get-DbatoolsConfig", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbatoolsConfig \u0027Mail.To\u0027\nRetrieves the configuration element for the key \"Mail.To\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbatoolsConfig -Force\nRetrieve all configuration elements from all modules, even hidden ones.", "Syntax": "Get-DbatoolsConfig [[-FullName] \u003cString\u003e] [-Force] [\u003cCommonParameters\u003e]\nGet-DbatoolsConfig [[-Name] \u003cString\u003e] [[-Module] \u003cString\u003e] [-Force] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbatoolsConfigValue", "Description": "Returns the configuration value stored under the specified name.\nIt requires the full name (\u003cModule\u003e.\u003cName\u003e) and is usually only called by functions.", "Tags": [ "Config", "Module" ], "Params": [ [ "FullName", "The full name (\u003cModule\u003e.\u003cName\u003e) of the configured value to return.", "Name", true, "false", "" ], [ "Fallback", "A fallback value to use, if no value was registered to a specific configuration element.\r\nThis basically is a default value that only applies on a \"per call\" basis, rather than a system-wide default.", "", false, "false", "" ], [ "NotNull", "By default, this function returns null if one tries to retrieve the value from either a Configuration that does not exist or a Configuration whose value was set to null.\r\nHowever, sometimes it may be important that some value was returned.\r\nBy specifying this parameter, the function will throw an error if no value was found at all.", "", false, "false", "False" ] ], "Alias": "Get-DbaConfigValue", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Returns the configuration value stored under the specified name.", "Name": "Get-DbatoolsConfigValue", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbatoolsConfigValue -Name \u0027System.MailServer\u0027\nReturns the configured value that was assigned to the key \u0027System.MailServer\u0027\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbatoolsConfigValue -Name \u0027Default.CoffeeMilk\u0027 -Fallback 0\nReturns the configured value for \u0027Default.CoffeeMilk\u0027. If no such value is configured, it returns \u00270\u0027 instead.", "Syntax": "Get-DbatoolsConfigValue [-FullName] \u003cString\u003e [[-Fallback] \u003cObject\u003e] [-NotNull] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbatoolsLog", "Description": "Returns log entries for dbatools. Handy when debugging or developing a script using it.", "Tags": "Debug", "Params": [ [ "FunctionName", "Default: \"*\"\r\nOnly messages written by similar functions will be returned.", "", false, "false", "*" ], [ "ModuleName", "Default: \"*\"\r\nOnly messages written by commands from similar modules will be returned.", "", false, "false", "*" ], [ "Target", "Only messags handling the specified target will be returned.", "", false, "false", "" ], [ "Tag", "Only messages containing one of these tags will be returned.", "", false, "false", "" ], [ "Last", "Only messages written by the last X executions will be returned.\r\nUses Get-History to determine execution. Ignores Get-message commands.\r\nBy default, this will also include messages from other runspaces. If your command executes in parallel, that\u0027s useful.\r\nIf it doesn\u0027t and you were offloading executions to other runspaces, consider also filtering by runspace using \u0027-Runspace\u0027", "", false, "false", "0" ], [ "Skip", "How many executions to skip when specifying \u0027-Last\u0027.\r\nHas no effect without the \u0027-Last\u0027 parameter.", "", false, "false", "0" ], [ "Runspace", "The guid of the runspace to return messages from.\r\nBy default, messages from all runspaces are returned.\r\nRun the following line to see the list of guids:\nGet-Runspace | ft Id, Name, InstanceId -Autosize", "", false, "false", "" ], [ "Level", "Limit the message selection by level.\r\nMessage levels have a numeric value, making it easier to select a range:\n-Level (1..6)\nWill select the first 6 levels (Critical - SomewhatVerbose).", "", false, "false", "" ], [ "Errors", "Instead of log entries, the error entries will be retrieved", "", false, "false", "False" ] ], "Alias": "", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Returns log entries for dbatools", "Name": "Get-DbatoolsLog", "Links": "https://dbatools.io/Get-DbatoolsLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbatoolsLog\nReturns all log entries currently in memory.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbatoolsLog -Target \"a\" -Last 1 -Skip 1\nReturns all log entries that targeted the object \"a\" in the second last execution sent.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbatoolsLog -Tag \"fail\" -Last 5\nReturns all log entries within the last 5 executions that contained the tag \"fail\"", "Syntax": "Get-DbatoolsLog [[-FunctionName] \u003cString\u003e] [[-ModuleName] \u003cString\u003e] [[-Target] \u003cObject\u003e] [[-Tag] \u003cString[]\u003e] [[-Last] \u003cInt32\u003e] [[-Skip] \u003cInt32\u003e] [[-Runspace] \u003cGuid\u003e] [[-Level] {Critical | Important | Output | Significant | VeryVerbose | Verbose | SomewhatVerbose | System | Debug | InternalComment | Warning}] [-Errors] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaTopResourceUsage", "Description": "Returns the top 20 resource consumers for cached queries based on four different metrics: duration, frequency, IO, and CPU.\n\nThis command is based off of queries provided by Michael J. Swart at http://michaeljswart.com/go/Top20\n\nPer Michael: \"I\u0027ve posted queries like this before, and others have written many other versions of this query. All these queries are based on sys.dm_exec_query_stats.\"", "Tags": [ "Query", "Performance" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "Type", "By default, all Types run but you can specify one or more of the following: Duration, Frequency, IO, or CPU", "", false, "false", "All" ], [ "Limit", "By default, these query the Top 20 worst offenders (though more than 20 results can be returned if each of the top 20 have more than 1 subsequent result)", "", false, "false", "20" ], [ "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" ], [ "ExcludeSystem", "This will exclude system objects like replication procedures from being returned.", "", false, "false", "False" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns the top 20 resource consumers for cached queries based on four different metrics: duration, frequency, IO, and CPU.", "Name": "Get-DbaTopResourceUsage", "Links": "https://dbatools.io/Get-DbaTopResourceUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2008, sql2012\nReturn the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and sql2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2008 -Type Duration, Frequency -Database TestDB\nReturn the highest usage by duration (top 20) and frequency (top 20) for the TestDB on sql2008\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2016 -Limit 30\nReturn the highest usage by duration (top 30) and frequency (top 30) for the TestDB on sql2016\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2008, sql2012 -ExcludeSystem\nReturn the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and sql2012 without any System Objects\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2016| Select-Object *\nReturn all the columns plus the QueryPlan column", "Syntax": "Get-DbaTopResourceUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-Type \u003cString[]\u003e] [-Limit \u003cInt32\u003e] [-EnableException] [-ExcludeSystem] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaTrace", "Description": "This function returns a list of traces on a SQL Server instance and identifies the default trace file", "Tags": [ "Security", "Trace" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "A credential to use to connect to the SQL Instance rather than using Windows Authentication", "", false, "false", "" ], [ "Id", "The id(s) of the Trace", "", false, "false", "" ], [ "Default", "Switch that will only return the information for the default system trace", "", 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": "Get-DbaTraceFile", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets a list of trace(s) from specified SQL Server Instance", "Name": "Get-DbaTrace", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2016\nLists all the trace files on the sql2016 SQL Server.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2016 -Default\nLists the default trace information on the sql2016 SQL Server.", "Syntax": "Get-DbaTrace [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Id \u003cInt32[]\u003e] [-Default] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaTraceFlag", "Description": "Returns Trace Flags that are enabled globally on each instance(s) of SQL Server as an object.", "Tags": "TraceFlag", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "TraceFlag", "Use this switch to filter to a specific Trace Flag.", "", 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": "Kevin Bullen (@sqlpadawan)", "Synopsis": "Get global Trace Flag(s) information for each instance(s) of SQL Server.", "Name": "Get-DbaTraceFlag", "Links": "https://dbatools.io/Get-DbaTraceFlag", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaTraceFlag -SqlInstance localhost\nReturns all Trace Flag information on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaTraceFlag -SqlInstance localhost, sql2016\nReturns all Trace Flag(s) for the local and sql2016 SQL Server instances\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTraceFlag -SqlInstance localhost -TraceFlag 4199,3205\nReturns Trace Flag status for TF 4199 and 3205 for the local SQL Server instance if they are enabled.", "Syntax": "Get-DbaTraceFlag [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-TraceFlag \u003cInt32[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaUptime", "Description": "By default, this command returns for each SQL Server instance passed in:\nSQL Instance last startup time, Uptime as a PS TimeSpan, Uptime as a formatted string\nHosting Windows server last startup time, Uptime as a PS TimeSpan, Uptime as a formatted string", "Tags": "CIM", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,ComputerName", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins instead of Windows Authentication (AKA Integrated or Trusted). To use:\n$scred = Get-Credential, then pass $scred object to the -SqlCredential parameter.\nWindows Authentication will be used if SqlCredential is not specified. SQL Server does not accept Windows credentials being passed as credentials.\nTo connect to SQL Server as a different Windows user, run PowerShell as that user.", "", false, "false", "" ], [ "Credential", "Allows you to login to the computer (not SQL Server instance) using alternative Windows credentials.", "", 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": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Returns the uptime of the SQL Server instance, and if required the hosting windows server", "Name": "Get-DbaUptime", "Links": "https://dbatools.io/Get-DbaUptime", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaUptime -SqlInstance SqlBox1\\Instance2\nReturns an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot time, host uptime as TimeSpan objects and host uptime as a string for the sqlexpress \r\ninstance on winserver\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaUptime -SqlInstance winserver\\sqlexpress, sql2016\nReturns an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot time, host uptime as TimeSpan objects and host uptime as a string for the sqlexpress \r\ninstance on host winserver and the default instance on host sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2014 | Get-DbaUptime\nReturns an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot time, host uptime as TimeSpan objects and host uptime as a string for every server \r\nlisted in the Central Management Server on sql2014", "Syntax": "Get-DbaUptime [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaUserPermission", "Description": "This command will display all server logins, server level securable, database logins and database securables.\n\nDISA STIG implementators will find this command useful as it uses Permissions.sql provided by DISA.\n\nNote that if you Ctrl-C out of this command and end it prematurely, it will leave behind a STIG schema in tempdb.", "Tags": [ "Discovery", "Permissions", "Security" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "ExcludeSystemDatabase", "Allows you to suppress output on system databases", "", false, "false", "False" ], [ "IncludePublicGuest", "Allows you to include output for public and guest grants.", "", false, "false", "False" ], [ "IncludeSystemObjects", "Allows you to include output on sys schema objects.", "", 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": "Get-DbaUserLevelPermission", "Author": "Brandon Abshire, netnerds.net", "Synopsis": "Displays detailed permissions information for the server and database roles and securables.", "Name": "Get-DbaUserPermission", "Links": "https://dbatools.io/Get-DbaUserPermission", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaUserPermission -SqlInstance sql2008, sqlserver2012\nCheck server and database permissions for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaUserPermission -SqlInstance sql2008 -Database TestDB\nCheck server and database permissions on server sql2008 for only the TestDB database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaUserPermission -SqlInstance sql2008 -Database TestDB -IncludePublicGuest -IncludeSystemObjects\nCheck server and database permissions on server sql2008 for only the TestDB database,\r\nincluding public and guest grants, and sys schema objects.", "Syntax": "Get-DbaUserPermission [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [[-ExcludeSystemDatabase]] [-IncludePublicGuest] [-IncludeSystemObjects] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWaitingTask", "Description": "This command is based on waiting task T-SQL script published by Paul Randal.\nReference: https://www.sqlskills.com/blogs/paul/updated-sys-dm_os_waiting_tasks-script-2/", "Tags": [ "Waits", "Task", "WaitTask" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version XXXX or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Spid", "Find the waiting task of one or more specific process ids", "", false, "true (ByPropertyName)", "" ], [ "IncludeSystemSpid", "If this switch is enabled, the output will include the system sessions.", "", 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": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Displays waiting task.", "Name": "Get-DbaWaitingTask", "Links": "https://dbatools.io/Get-DbaWaitingTask", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWaitingTask -SqlInstance sqlserver2014a\nReturns the waiting task for all sessions on sqlserver2014a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWaitingTask -SqlInstance sqlserver2014a -IncludeSystemSpid\nReturns the waiting task for all sessions (user and system) on sqlserver2014a", "Syntax": "Get-DbaWaitingTask [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cObject[]\u003e] [-IncludeSystemSpid] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWaitResource", "Description": "Given a wait resource in the form of \u0027PAGE: 10:1:9180084\u0027 returns the database, data file and the system object which is being waited up.\n\nGiven a wait resource in the form of \u0027KEY: 7:35457594073541168 (de21f92a1572)\u0027, returns the database, object and index that is being waited on, With the -row switch the row data will also be returned.", "Tags": [ "Pages", "DBCC" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "", false, "false", "" ], [ "WaitResource", "The wait resource value as supplied in sys.dm_exec_requests", "", true, "true (ByValue)", "" ], [ "Row", "If this switch provided also returns the value of the row being waited on with KEY wait resources", "", false, "false", "False" ], [ "EnableException", "Replaces user friendly yellow warnings with bloody red exceptions of doom!\r\nUse this if you want the function to throw terminating errors you want to catch.", "", false, "false", "False" ] ], "Alias": "", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Returns the resource being waited upon", "Name": "Get-DbaWaitResource", "Links": "https://dbatools.io/Get-DbaWaitResource", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWaitResource -SqlInstance server1 -WaitResource \u0027PAGE: 10:1:9180084\u0027\nWill return an object containing; database name, data file name, schema name and the object which owns the resource\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWaitResource -SqlInstance server2 -WaitResource \u0027KEY: 7:35457594073541168 (de21f92a1572)\u0027\nWill return an object containing; database name, schema name and index name which is being waited on.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaWaitResource -SqlInstance server2 -WaitResource \u0027KEY: 7:35457594073541168 (de21f92a1572)\u0027 -row\nWill return an object containing; database name, schema name and index name which is being waited on, and in addition the contents of the locked row at the time the command is run.", "Syntax": "Get-DbaWaitResource [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-WaitResource] \u003cString\u003e [-Row] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWaitStatistic", "Description": "This command is based off of Paul Randal\u0027s post \"Wait statistics, or please tell me where it hurts\"\n\nReturns:\nWaitType\nCategory\nWaitSeconds\nResourceSeconds\nSignalSeconds\nWaitCount\nPercentage\nAverageWaitSeconds\nAverageResourceSeconds\nAverageSignalSeconds\nURL\n\nReference: https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/", "Tags": "WaitStatistic", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2005 or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Threshold", "Threshold, in percentage of all waits on the system. Default per Paul\u0027s post is 95%.", "", false, "false", "95" ], [ "IncludeIgnorable", "Some waits are no big deal and can be safely ignored in most circumstances. If you\u0027ve got weird issues with mirroring or AGs.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Displays wait statistics", "Name": "Get-DbaWaitStatistic", "Links": "https://dbatools.io/Get-DbaWaitStatistic", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWaitStatistic -SqlInstance sql2008, sqlserver2012\nCheck wait statistics for servers sql2008 and sqlserver2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWaitStatistic -SqlInstance sql2008 -Threshold 98 -IncludeIgnorable\nCheck wait statistics on server sql2008 for thresholds above 98% and include wait stats that are most often, but not always, ignorable\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaWaitStatistic -SqlInstance sql2008 | Select *\nShows detailed notes, if available, from Paul\u0027s post\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$output = Get-DbaWaitStatistic -SqlInstance sql2008 -Threshold 100 -IncludeIgnorable | Select-Object * | ConvertTo-DbaDataTable\nCollects all Wait Statistics (including ignorable waits) on server sql2008 into a Data Table.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$output = Get-DbaWaitStatistic -SqlInstance sql2008\nPS C:\\\u003e foreach ($row in ($output | Sort-Object -Unique Url)) { Start-Process ($row).Url }\nDisplays the output then loads the associated sqlskills website for each result. Opens one tab per unique URL.", "Syntax": "Get-DbaWaitStatistic [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Threshold] \u003cInt32\u003e] [-IncludeIgnorable] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWindowsLog", "Description": "Gets Windows Application events associated with an instance", "Tags": "Logging", "Params": [ [ "SqlInstance", "The instance(s) to retrieve the event logs from", "ServerInstance,SqlServer", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Start", "Default: 1970\r\nRetrieve all events starting from this timestamp.", "", false, "false", "1/1/1970 00:00:00" ], [ "End", "Default: Now\r\nRetrieve all events that happened before this timestamp", "", false, "false", "(Get-Date)" ], [ "Credential", "Credential to be used to connect to the Server. Note this is a Windows credential, as this command requires we communicate with the computer and not with the SQL instance.", "", false, "false", "" ], [ "MaxThreads", "Default: Unlimited\r\nThe maximum number of parallel threads used on the local computer.\r\nGiven that those will mostly be waiting for the remote system, there is usually no need to limit this.", "", false, "false", "0" ], [ "MaxRemoteThreads", "Default: 2\r\nThe maximum number of parallel threads that are executed on the target sql server.\r\nThese processes will cause considerable CPU load, so a low limit is advisable in most scenarios.\r\nAny value lower than 1 disables the limit", "", false, "false", "2" ], [ "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": "Drew Furgiuele | Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Gets Windows Application events associated with an instance", "Name": "Get-DbaWindowsLog", "Links": "https://dbatools.io/Get-DbaWindowsLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$ErrorLogs = Get-DbaWindowsLog -SqlInstance sql01\\sharepoint\nPS C:\\\u003e $ErrorLogs | Where-Object ErrorNumber -eq 18456\nReturns all lines in the errorlogs that have event number 18456 in them\nThis exists to ignore the Script Analyzer rule for Start-Runspace", "Syntax": "Get-DbaWindowsLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Start] \u003cDateTime\u003e] [[-End] \u003cDateTime\u003e] [[-Credential] \u003cPSCredential\u003e] [[-MaxThreads] \u003cInt32\u003e] [[-MaxRemoteThreads] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcAvailableDisk", "Description": "Gets information about the disks that can support Failover Clustering and are visible to all nodes, but are not yet part of the set of clustered disks.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about the disks that can support Failover Clustering and are visible to all nodes, but are not yet part of the set of clustered disks.", "Name": "Get-DbaWsfcAvailableDisk", "Links": "https://dbatools.io/Get-DbaWsfcAvailableDisk", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcAvailableDisk -ComputerName cluster01\nGets available disks from the failover cluster cluster01", "Syntax": "Get-DbaWsfcAvailableDisk [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcCluster", "Description": "Gets information about one or more failover clusters in a given domain.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more failover clusters in a given domain.", "Name": "Get-DbaWsfcCluster", "Links": "https://dbatools.io/Get-DbaWsfcCluster", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcCluster -ComputerName cluster01\nGets failover cluster information about cluster01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWsfcCluster -ComputerName cluster01 | Select *\nShows all cluster values, including the ones not shown in the default view", "Syntax": "Get-DbaWsfcCluster [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcDisk", "Description": "Gets information about the clustered disks on one or more failover clusters in a given domain.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about the clustered disks on one or more failover clusters in a given domain.", "Name": "Get-DbaWsfcDisk", "Links": "https://dbatools.io/Get-DbaWsfcDisk", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcDisk -ComputerName cluster01\nGets disk information from the failover cluster cluster01", "Syntax": "Get-DbaWsfcDisk [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcNetwork", "Description": "Gets information about one or more networks in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a Network or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more networks in a failover cluster.", "Name": "Get-DbaWsfcNetwork", "Links": "https://dbatools.io/Get-DbaWsfcNetwork", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcNetwork -ComputerName cluster01\nGets network information from the failover cluster cluster01", "Syntax": "Get-DbaWsfcNetwork [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcNetworkInterface", "Description": "Gets information about one or more network adapters in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a Network or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more network adapters in a failover cluster.", "Name": "Get-DbaWsfcNetworkInterface", "Links": "https://dbatools.io/Get-DbaWsfcNetworkInterface", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcNetworkInterface -ComputerName cluster01\nGets network interface information from the failover cluster cluster01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWsfcNetworkInterface -ComputerName cluster01 | Select *\nShows all network interface values, including the ones not shown in the default view", "Syntax": "Get-DbaWsfcNetworkInterface [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcNode", "Description": "Gets information about one or more nodes, or servers, in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more nodes, or servers, in a failover cluster.", "Name": "Get-DbaWsfcNode", "Links": "https://dbatools.io/Get-DbaWsfcNode", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcNode -ComputerName cluster01\nGets node information from the failover cluster cluster01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWsfcNode -ComputerName cluster01 | Select-Object *\nShows all node values, including the ones not shown in the default view", "Syntax": "Get-DbaWsfcNode [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcResource", "Description": "Gets information about one or more resources in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more resources in a failover cluster.", "Name": "Get-DbaWsfcResource", "Links": "https://dbatools.io/Get-DbaWsfcResource", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcResource -ComputerName cluster01\nGets resource information from the failover cluster cluster01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWsfcResource -ComputerName cluster01 | Select *\nShows all resource values, including the ones not shown in the default view", "Syntax": "Get-DbaWsfcResource [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcResourceType", "Description": "Gets information about one or more resource types in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more resource types in a failover cluster.", "Name": "Get-DbaWsfcResourceType", "Links": "https://dbatools.io/Get-DbaWsfcResourceType", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcResourceType -ComputerName cluster01\nGets resource type information from the failover cluster cluster01", "Syntax": "Get-DbaWsfcResourceType [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcRole", "Description": "Gets information about one or more clustered roles (resource groups) in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a Role or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about one or more clustered roles (resource groups) in a failover cluster.", "Name": "Get-DbaWsfcRole", "Links": "https://dbatools.io/Get-DbaWsfcRole", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcRole -ComputerName cluster01\nGets role information from the failover cluster cluster01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaWsfcRole -ComputerName cluster01 | Select *\nShows all role values, including the ones not shown in the default view", "Syntax": "Get-DbaWsfcRole [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaWsfcSharedVolume", "Description": "Gets information about Cluster Shared Volumes in a failover cluster.\n\nAll Windows Server Failover Clustering (Wsfc) commands require local admin on each member node.", "Tags": [ "Cluster", "WSFC", "FCI", "HA" ], "Params": [ [ "ComputerName", "The target cluster name. Can be a node or the cluster name itself.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the cluster using alternative credentials.", "", 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": "Gets information about Cluster Shared Volumes in a failover cluster.", "Name": "Get-DbaWsfcSharedVolume", "Links": "https://dbatools.io/Get-DbaWsfcSharedVolume", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaWsfcSharedVolume -ComputerName cluster01\nGets shared volume (CSV) information from the failover cluster cluster01", "Syntax": "Get-DbaWsfcSharedVolume [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaXEObject", "Description": "This function returns a list of extended events objects exposed by event packages from specified SQL Server instance(s).", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Type", "Used to specify the type. Valid types include:\nAction\r\nEvent\r\nMap\r\nMessage\r\nPredicateComparator\r\nPredicateSource\r\nTarget\r\nType", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because \r\nit basically disables advanced scripting. Using 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": "Gets a list of extended events objects exposed by event packages from specified SQL Server instance(s).", "Name": "Get-DbaXEObject", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXEObject -SqlInstance sql2016\nLists all the XE Objects on the sql2016 SQL Server.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXEObject -SqlInstance sql2017 -Type Action, Event\nLists all the XE Objects of type Action and Event on the sql2017 SQL Server.", "Syntax": "Get-DbaXEObject [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaXESession", "Description": "Retrieves a list of Extended Events Sessions present on the specified SQL Server instance(s).", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "Only return specific sessions. Options for this parameter are auto-populated from the server.", "Sessions", 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": "Get-DbaXEventSession", "Author": "Klaas Vandenberghe (@PowerDBAKlaas)", "Synopsis": "Gets a list of Extended Events Sessions from the specified SQL Server instance(s).", "Name": "Get-DbaXESession", "Links": "https://dbatools.io/Get-DbaXESession", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance ServerA\\sql987\nReturns a custom object with ComputerName, SQLInstance, Session, StartTime, Status and other properties.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance ServerA\\sql987 | Format-Table ComputerName, SqlInstance, Session, Status -AutoSize\nReturns a formatted table displaying ComputerName, SqlInstance, Session, and Status.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\u0027ServerA\\sql987\u0027,\u0027ServerB\u0027 | Get-DbaXESession\nReturns a custom object with ComputerName, SqlInstance, Session, StartTime, Status and other properties, from multiple SQL instances.", "Syntax": "Get-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Session] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaXESessionTarget", "Description": "Retrieves a list of Extended Events Session Targets from the specified SQL Server instance(s).", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "Only return a specific session. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "Target", "Only return a specific target.", "", false, "false", "" ], [ "InputObject", "Specifies an XE session returned by Get-DbaXESession to search.", "", 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" ] ], "Alias": "Get-DbaXEventSessionTarget", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Get a list of Extended Events Session Targets from the specified SQL Server instance(s).", "Name": "Get-DbaXESessionTarget", "Links": "https://dbatools.io/Get-DbaXESessionTarget", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXESessionTarget -SqlInstance ServerA\\sql987 -Session system_health\nShows targets for the system_health session on ServerA\\sql987.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2016 -Session system_health | Get-DbaXESessionTarget\nReturns the targets for the system_health session on sql2016.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2016 -Session system_health | Get-DbaXESessionTarget -Target package0.event_file\nReturn only the package0.event_file target for the system_health session on sql2016.", "Syntax": "Get-DbaXESessionTarget [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString[]\u003e] [-Target \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaXESessionTarget -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString[]\u003e] [-Target \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nGet-DbaXESessionTarget [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString[]\u003e] [-Target \u003cString[]\u003e] -InputObject \u003cSession[]\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaXESessionTemplate", "Description": "Parses Extended Event XML templates. Defaults to parsing templates in the dbatools template repository (\\bin\\xetemplates\\).\n\nThe default repository contains templates from:\nMicrosoft\u0027s Templates that come with SSMS\nJes Borland\u0027s \"Everyday Extended Events\" presentation and GitHub repository (https://github.com/grrlgeek/extended-events)\nChristian Grafe (@ChrGraefe) XE Repo: https://github.com/chrgraefe/sqlscripts/blob/master/XE-Events/\nErin Stellato\u0027s Blog: https://www.sqlskills.com/blogs/erin/\n\nSome profile templates converted using:\nsp_SQLskills_ConvertTraceToExtendedEvents.sql\nJonathan M. Kehayias, SQLskills.com\nhttp://sqlskills.com/blogs/jonathan", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "Path", "The path to the template directory. Defaults to the dbatools template repository (\\bin\\xetemplates\\).", "", false, "false", "\"$script:PSModuleRoot\\bin\\xetemplates\"" ], [ "Pattern", "Specify a pattern for filtering. Alternatively, you can use Out-GridView -Passthru to select objects and pipe them to Import-DbaXESessionTemplate", "", false, "false", "" ], [ "Template", "Specifies one or more of the templates provided by dbatools. Press tab to cycle through the list of options.", "", 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": "Parses Extended Event XML templates. Defaults to parsing templates in the dbatools template repository (\\bin\\xetemplates\\).", "Name": "Get-DbaXESessionTemplate", "Links": "https://dbatools.io/Get-DbaXESessionTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXESessionTemplate\nReturns information about all the templates in the local dbatools repository.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESessionTemplate | Out-GridView -PassThru | Import-DbaXESessionTemplate -SqlInstance sql2017 | Start-DbaXESession\nAllows you to select a Session template, then import it to the specified instance and start the session.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESessionTemplate -Path \"$home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates\"\nReturns information about all the templates in your local XEventTemplates repository.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaXESessionTemplate -Pattern duration\nReturns information about all the templates that match the word \"duration\" in the title, category or body.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaXESessionTemplate | Select-Object *\nReturns more information about the template, including the full path/filename.", "Syntax": "Get-DbaXESessionTemplate [[-Path] \u003cString[]\u003e] [[-Pattern] \u003cString\u003e] [[-Template] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaXESmartTarget", "Description": "Gets an XESmartTarget PowerShell job created by Start-DbaXESmartTarget.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "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) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "Gets an XESmartTarget PowerShell job created by Start-DbaXESmartTarget.", "Name": "Get-DbaXESmartTarget", "Links": "https://dbatools.io/Get-DbaXESmartTarget", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXESmartTarget\nGets an XESmartTarget PowerShell Job created by Start-DbaXESmartTarget.", "Syntax": "Get-DbaXESmartTarget [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Get-DbaXEStore", "Description": "Get a Extended Events store", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Get a Extended Events store", "Name": "Get-DbaXEStore", "Links": "https://dbatools.io/Get-DbaXEStore", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXEStore -SqlInstance ServerA\\sql987\nReturns an XEvent Store.", "Syntax": "Get-DbaXEStore [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Grant-DbaAgPermission", "Description": "Grants endpoint and availability group permissions to a login. If the account is a Windows login and does not exist, it will be automatically added.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Login", "The login or logins to modify.", "", false, "false", "" ], [ "AvailabilityGroup", "Only modify specific availability groups.", "", false, "false", "" ], [ "Type", "Specify type: Endpoint or AvailabilityGroup. Endpoint will modify the DatabaseMirror endpoint type.", "", true, "false", "" ], [ "Permission", "Grants one or more permissions:\r\n Alter\r\n Connect\r\n Control\r\n CreateSequence\r\n CreateAnyDatabase\r\n Delete\r\n Execute\r\n Impersonate\r\n Insert\r\n Receive\r\n References\r\n Select\r\n Send\r\n TakeOwnership\r\n Update\r\n ViewChangeTracking\r\n ViewDefinition\n CreateAnyDatabase\nConnect is default.", "", false, "false", "Connect" ], [ "InputObject", "Enables piping from Get-DbaLogin.", "", 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" ], [ "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": "Grants endpoint and availability group permissions to a login.", "Name": "Grant-DbaAgPermission", "Links": "https://dbatools.io/Grant-DbaAgPermission", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGrant-DbaAgPermission -SqlInstance sql2017a -Type AvailabilityGroup -AvailabilityGroup SharePoint -Login ad\\spservice -Permission CreateAnyDatabase\nAdds CreateAnyDatabase permissions to ad\\spservice on the SharePoint availability group on sql2017a. Does not prompt for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGrant-DbaAgPermission -SqlInstance sql2017a -Type AvailabilityGroup -AvailabilityGroup ag1, ag2 -Login ad\\spservice -Permission CreateAnyDatabase -Confirm\nAdds CreateAnyDatabase permissions to ad\\spservice on the ag1 and ag2 availability groups on sql2017a. Prompts for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2017a | Out-GridView -Passthru | Grant-DbaAgPermission -Type EndPoint\nGrants the selected logins Connect permissions on the DatabaseMirroring endpoint for sql2017a", "Syntax": "Grant-DbaAgPermission [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [-Type] \u003cString[]\u003e [[-Permission] \u003cString[]\u003e] [[-InputObject] \u003cLogin[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Import-DbaCmsRegServer", "Description": "Imports registered servers and registered server groups to SQL Server Central Management Server (CMS)", "Tags": [ "RegisteredServer", "CMS" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "Optional path to exported reg server XML", "FullName", 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)", "" ], [ "Group", "Imports to specific group", "", false, "false", "" ], [ "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": "Import-DbaRegisteredServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Imports registered servers and registered server groups to SQL Server Central Management Server (CMS)", "Name": "Import-DbaCmsRegServer", "Links": "https://dbatools.io/Import-DbaCmsRegServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-DbaCmsRegServer -SqlInstance sql2012 -Path C:\\temp\\corp-regservers.xml\nImports C:\\temp\\corp-regservers.xml to the CMS on sql2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eImport-DbaCmsRegServer -SqlInstance sql2008 -Group hr\\Seattle -Path C:\\temp\\Seattle.xml\nImports C:\\temp\\Seattle.xml to Seattle subgroup within the hr group on sql2008\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2008, sql2012 | Import-DbaCmsRegServer -SqlInstance sql2017\nImports all registered servers from sql2008 and sql2012 to sql2017\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sql2008 -Group hr\\Seattle | Import-DbaCmsRegServer -SqlInstance sql2017 -Group Seattle\nImports all registered servers from the hr\\Seattle group on sql2008 to the Seattle group on sql2017", "Syntax": "Import-DbaCmsRegServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [[-Group] \u003cObject\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Import-DbaCsvToSql", "Description": "Import-DbaCsvToSql takes advantage of .NET\u0027s super fast SqlBulkCopy class to import CSV files into SQL Server at up to 90,000 rows a second.\n\nThe entire import is contained within a transaction, so if a failure occurs or the script is aborted, no changes will persist.\n\nIf the table specified does not exist, it will be automatically created using best guessed data types. In addition, the destination table can be truncated prior to import.\n\nThe Query parameter will be used to import only the data returned from a SQL Query executed against the CSV file(s). This function supports a number of bulk copy options. Please see parameter list for details.", "Tags": "Migration", "Params": [ [ "Csv", "Specifies path to the CSV file(s) to be imported. Multiple files may be imported if they are formatted similarly.\nIf no file is specified, a dialog box will appear to select your file(s).", "", false, "false", "" ], [ "SqlInstance", "The SQL Server Instance to import data into.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Table", "Specifies the SQL table or view where CSV will be imported into.\nIf a table name is not specified, the table name will be automatically determined from the filename, and a prompt will appear to confirm the table name.\nIf a table does not currently exist, it will created. SQL datatypes are determined from the first row of the CSV that contains data (skips first row if -FirstRowColumns is specified). Datatypes used \r\nare: bigint, numeric, datetime and varchar(MAX).\nIf the automatically generated table datatypes do not work for you, please create the table prior to import.", "", false, "false", "" ], [ "Schema", "Specifies the schema in which the SQL table or view where CSV will be imported into resides. Default is dbo\nIf a schema name is not specified, and a CSV name with multiple dots is specified (ie; something.data.csv) then this will be interpreted as a request to import into a table [data] in the schema \r\n[something].\nIf a schema does not currently exist, it will be created, after a prompt to confirm this. Authorization will be set to dbo by default", "", false, "false", "dbo" ], [ "Truncate", "If this switch is enabled, the destination table will be truncated prior to import.", "", false, "false", "False" ], [ "Delimiter", "Specifies the delimiter used in the imported file(s). If no delimiter is specified, comma is assumed.\nValid delimiters are \u0027`t`, \u0027|\u0027, \u0027;\u0027,\u0027 \u0027 and \u0027,\u0027 (tab, pipe, semicolon, space, and comma).", "", false, "false", "," ], [ "SingleColumn", "Specifies that the file contains a single column of data", "", false, "false", "False" ], [ "FirstRowColumns", "If this switch is enabled, the first row in the file will be used as column names for the data being imported.\nIf the first row does not contain column names and -Query is specified, use field names \"column1, column2, column3\" and so on.", "", false, "false", "False" ], [ "Turbo", "If this switch is enabled, a Table Lock will be created for the import to make the import run as fast as possible. Depending upon the number of columns and datatypes, this may be over 90,000 records \r\nper second.\nThis switch cannot be used in conjunction with -Query.\nRemember the Turbo button? This one actually works. Turbo is mega fast, but may not handle some datatypes as well as other methods.\nIf your CSV file is rather vanilla and doesn\u0027t have a ton of NULLs, Turbo may work well for you.", "", false, "false", "False" ], [ "Safe", "If this switch is enabled, OleDb is used to import the records. By default, Import-DbaCsvToSql uses StreamReader for imports. StreamReader is super fast, but may not properly parse some files.\nWhen using OleDb the import will be slower but more predictable when it comes to parsing CSV files. A schema.ini is automatically generated for best results. If schema.ini currently exists in the \r\ndirectory, it will be moved to a temporary location, then moved back.\nOleDB also enables the script to use the -Query parameter, which enables you to import specific subsets of data within a CSV file. OleDB imports at up to 21,000 rows/sec.", "", false, "false", "False" ], [ "First", "Specifies the number of rows to import. If this parameter is omitted, the entire file is imported. Row counts start at the top of the file, but skip the first row if -FirstRowColumns is specified.\nUse -Query if you need advanced First (TOP) functionality.", "", false, "false", "0" ], [ "Query", "Specifies a query to execute against the CSV data to select/modify the data being imported.\nTo make command line queries easy, this module will convert the word \"csv\" to the actual CSV formatted table name. If the FirstRowColumns switch is not used, the query should use column1, column2, \r\ncolumn3, etc.\nCannot be used in conjunction with -Turbo or -First. When -Query is specified, the slower import method, OleDb, will be used.", "", false, "false", "select * from csv" ], [ "BatchSize", "Specifies the batch size for the import. Defaults to 50000.", "", false, "false", "50000" ], [ "NotifyAfter", "Specifies the import row count interval for reporting progress. A notification will be shown after each group of this many rows has been imported.", "", false, "false", "0" ], [ "TableLock", "If this switch is enabled, the SqlBulkCopy option to acquire a table lock will be used. This is automatically used if -Turbo is enabled.\nPer Microsoft \"Obtain a bulk update lock for the duration of the bulk copy operation. When not\r\nspecified, row locks are used.\"", "", false, "false", "False" ], [ "CheckConstraints", "If this switch is enabled, the SqlBulkCopy option to check constraints will be used.\nPer Microsoft \"Check constraints while data is being inserted. By default, constraints are not checked.\"", "", false, "false", "False" ], [ "FireTriggers", "If this switch is enabled, the SqlBulkCopy option to allow insert triggers to be executed will be used.\nPer Microsoft \"When specified, cause the server to fire the insert triggers for the rows being inserted into the database.\"", "", false, "false", "False" ], [ "KeepIdentity", "If this switch is enabled, the SqlBulkCopy option to keep identity values from the source will be used.\nPer Microsoft \"Preserve source identity values. When not specified, identity values are assigned by the destination.\"", "", false, "false", "False" ], [ "KeepNulls", "If this switch is enabled, the SqlBulkCopy option to keep NULL values in the table will be used.\nPer Microsoft \"Preserve null values in the destination table regardless of the settings for default values. When not specified, null values are replaced by default values where applicable.\"", "", false, "false", "False" ], [ "shellswitch", "[Parameter(DontShow)]", "", false, "false", "False" ], [ "SqlCredentialPath", "[Parameter(DontShow)]", "", false, "false", "" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Efficiently imports very large (and small) CSV files into SQL Server using only the .NET Framework and PowerShell.", "Name": "Import-DbaCsvToSql", "Links": "https://blog.netnerds.net/2015/09/Import-DbaCsvtosql-super-fast-csv-to-sql-server-import-powershell-module/", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv C:\\temp\\housing.csv -SqlInstance sql001 -Database markets\nImports the entire comma-delimited housing.csv to the SQL \"markets\" database on a SQL Server named sql001.\nSince a table name was not specified, the table name is automatically determined from filename as \"housing\" and a prompt will appear to confirm table name.\nThe first row is not skipped, as it does not contain column names.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv .\\housing.csv -SqlInstance sql001 -Database markets -Table housing -First 100000 -Safe -Delimiter \"`t\" -FirstRowColumns\nImports the first 100,000 rows of the tab delimited housing.csv file to the \"housing\" table in the \"markets\" database on a SQL Server named sql001. Since -Safe was specified, the OleDB method will be \r\nused for the bulk import. The first row is skipped, as it contains column names.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -csv C:\\temp\\huge.txt -SqlInstance sqlcluster -Database locations -Table latitudes -Delimiter \"|\" -Turbo\nImports all records from the pipe delimited huge.txt file using the fastest method possible into the latitudes table within the locations database. Obtains a table lock for the duration of the bulk \r\ncopy operation. This specific command has been used\r\nto import over 10.5 million rows in 2 minutes.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv C:\\temp\\housing.csv, .\\housing2.csv -SqlInstance sql001 -Database markets -Table housing -Delimiter \"`t\" -query \"select top 100000 column1, column3 from csv\" -Truncate\nTruncates the \"housing\" table, then imports columns 1 and 3 of the first 100000 rows of the tab-delimited housing.csv in the C:\\temp directory, and housing2.csv in the current directory. Since the \r\nquery is executed against both files, a total of 200,000 rows will be imported.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv C:\\temp\\housing.csv -SqlInstance sql001 -Database markets -Table housing -query \"select address, zip from csv where state = \u0027Louisiana\u0027\" -FirstRowColumns -Truncate \r\n-FireTriggers\nUses the first line to determine CSV column names. Truncates the \"housing\" table on the SQL Server, then imports the address and zip columns from all records in the housing.csv where the state equals \r\nLouisiana.\nTriggers are fired for all rows. Note that this does slightly slow down the import.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv c:\\temp\\SingleColumn.csv -SqlInstance sql001 -Database markets -Table TempTable -SingleColumn\nUpload the single column Csv SingleColumn.csv to Temptable which has just one column\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv \"\\\\FileServer\\To Import\\housing.csv\" -SqlInstance sql001 -Database markets\nImports the entire comma-delimited housing.csv located in the share named \"To Import\" on FileServer to the SQL \"markets\" database on a SQL Server named sql001.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eImport-DbaCsvToSql -Csv \u0027\\\\FileServer\\R$\\To Import\\housing.csv\u0027 -SqlInstance sql001 -Database markets\nImports the entire comma-delimited housing.csv located in the directory R:\\To Import on FileServer using the administrative share to the SQL \"markets\" database on a SQL Server named sql001.", "Syntax": "Import-DbaCsvToSql [-Csv \u003cString[]\u003e] -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cObject\u003e] [-Table \u003cString\u003e] [-Schema \u003cString\u003e] [-Truncate] [-Delimiter \u003cString\u003e] [-SingleColumn] [-FirstRowColumns] [-First \u003cInt32\u003e] [-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-TableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] [-shellswitch] [-SqlCredentialPath \u003cString\u003e] [\u003cCommonParameters\u003e]\nImport-DbaCsvToSql [-Csv \u003cString[]\u003e] -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cObject\u003e] [-Table \u003cString\u003e] [-Schema \u003cString\u003e] [-Truncate] [-Delimiter \u003cString\u003e] [-SingleColumn] [-FirstRowColumns] [-Turbo] [-First \u003cInt32\u003e] [-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-TableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] [-shellswitch] [-SqlCredentialPath \u003cString\u003e] [\u003cCommonParameters\u003e]\nImport-DbaCsvToSql [-Csv \u003cString[]\u003e] -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cObject\u003e] [-Table \u003cString\u003e] [-Schema \u003cString\u003e] [-Truncate] [-Delimiter \u003cString\u003e] [-SingleColumn] [-FirstRowColumns] [-Safe] [-First \u003cInt32\u003e] [-Query \u003cString\u003e] [-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-TableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] [-shellswitch] [-SqlCredentialPath \u003cString\u003e] [\u003cCommonParameters\u003e]" }, { "CommandName": "Import-DbaPfDataCollectorSetTemplate", "Description": "Imports a new Performance Monitor Data Collector Set Template either from the dbatools repository or a file you specify.\nWhen importing data collector sets from the local instance, Run As Admin is required.\n\nNote: The included counters will be added for all SQL instances on the machine by default.\nFor specific instances in addition to the default, use -Instance.\n\nSee https://msdn.microsoft.com/en-us/library/windows/desktop/aa371952 for more information", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to servers using alternative credentials. To use:\n$scred = Get-Credential, then pass $scred object to the -Credential parameter.", "", false, "false", "" ], [ "DisplayName", "Sets the display name of the data collector set.", "", false, "false", "" ], [ "SchedulesEnabled", "If this switch is enabled, sets a value that indicates whether the schedules are enabled.", "", false, "false", "False" ], [ "RootPath", "Sets the base path where the subdirectories are created.", "", false, "false", "" ], [ "Segment", "Sets a value that indicates whether PLA creates new logs if the maximum size or segment duration is reached before the data collector set is stopped.", "", false, "false", "False" ], [ "SegmentMaxDuration", "Sets the duration that the data collector set can run before it begins writing to new log files.", "", false, "false", "0" ], [ "SegmentMaxSize", "Sets the maximum size of any log file in the data collector set.", "", false, "false", "0" ], [ "Subdirectory", "Sets a base subdirectory of the root path where the next instance of the data collector set will write its logs.", "", false, "false", "" ], [ "SubdirectoryFormat", "Sets flags that describe how to decorate the subdirectory name. PLA appends the decoration to the folder name. For example, if you specify plaMonthDayHour, PLA appends the current month, day, and \r\nhour values to the folder name. If the folder name is MyFile, the result could be MyFile110816.", "", false, "false", "3" ], [ "SubdirectoryFormatPattern", "Sets a format pattern to use when decorating the folder name. Default is \u0027yyyyMMdd\\-NNNNNN\u0027.", "", false, "false", "yyyyMMdd\\-NNNNNN" ], [ "Task", "Sets the name of a Task Scheduler job to start each time the data collector set stops, including between segments.", "", false, "false", "" ], [ "TaskRunAsSelf", "If this switch is enabled, sets a value that determines whether the task runs as the data collector set user or as the user specified in the task.", "", false, "false", "False" ], [ "TaskArguments", "Sets the command-line arguments to pass to the Task Scheduler job specified in the IDataCollectorSet::Task property.\r\nSee https://msdn.microsoft.com/en-us/library/windows/desktop/aa371992 for more information.", "", false, "false", "" ], [ "TaskUserTextArguments", "Sets the command-line arguments that are substituted for the {usertext} substitution variable in the IDataCollectorSet::TaskArguments property.\r\nSee https://msdn.microsoft.com/en-us/library/windows/desktop/aa371993 for more information.", "", false, "false", "" ], [ "StopOnCompletion", "If this switch is enabled, sets a value that determines whether the data collector set stops when all the data collectors in the set are in a completed state.", "", false, "false", "False" ], [ "Path", "The path to the xml file or files.", "FullName", false, "true (ByPropertyName)", "" ], [ "Template", "From one or more of the templates from the dbatools repository. Press Tab to cycle through the available options.", "", false, "false", "" ], [ "Instance", "By default, the template will be applied to all instances. If you want to set specific ones in addition to the default, supply just the instance name.", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Imports a new Performance Monitor Data Collector Set Template either from the dbatools repository or a file you specify.", "Name": "Import-DbaPfDataCollectorSetTemplate", "Links": "https://dbatools.io/Import-DbaPfDataCollectorSetTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template \u0027Long Running Query\u0027\nCreates a new data collector set named \u0027Long Running Query\u0027 from the dbatools repository on the SQL Server sql2017.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template \u0027Long Running Query\u0027 -DisplayName \u0027New Long running query\u0027 -Confirm\nCreates a new data collector set named \"New Long Running Query\" using the \u0027Long Running Query\u0027 template. Forces a confirmation if the template exists.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2017 -Session db_ola_health | Remove-DbaPfDataCollectorSet\nImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template db_ola_health | Start-DbaPfDataCollectorSet\nImports a session if it exists, then recreates it using a template.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate | Out-GridView -PassThru | Import-DbaPfDataCollectorSetTemplate -ComputerName sql2017\nAllows you to select a Session template then import to an instance named sql2017.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template \u0027Long Running Query\u0027 -Instance SHAREPOINT\nCreates a new data collector set named \u0027Long Running Query\u0027 from the dbatools repository on the SQL Server sql2017 for both the default and the SHAREPOINT instance.\nIf you\u0027d like to remove counters for the default instance, use Remove-DbaPfDataCollectorCounter.", "Syntax": "Import-DbaPfDataCollectorSetTemplate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-DisplayName] \u003cString\u003e] [-SchedulesEnabled] [[-RootPath] \u003cString\u003e] [-Segment] [[-SegmentMaxDuration] \u003cInt32\u003e] [[-SegmentMaxSize] \u003cInt32\u003e] [[-Subdirectory] \u003cString\u003e] [[-SubdirectoryFormat] \u003cInt32\u003e] [[-SubdirectoryFormatPattern] \u003cString\u003e] [[-Task] \u003cString\u003e] [-TaskRunAsSelf] [[-TaskArguments] \u003cString\u003e] [[-TaskUserTextArguments] \u003cString\u003e] [-StopOnCompletion] [[-Path] \u003cString[]\u003e] [[-Template] \u003cString[]\u003e] [[-Instance] \u003cString[]\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]" }, { "CommandName": "Import-DbaSpConfigure", "Description": "Updates sp_configure settings on destination server.", "Tags": [ "SpConfig", "Configure", "Configuration" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", false, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "SqlInstance", "Specifies a SQL Server instance to set up sp_configure values on using a SQL file.", "ServerInstance,SqlServer", false, "false", "" ], [ "Path", "Specifies the path to a SQL script file holding sp_configure queries for each of the settings to be changed. Export-DbaSPConfigure creates a suitable file as its output.", "", false, "false", "" ], [ "SqlCredential", "Use this SQL credential if you are setting up sp_configure values from a SQL file.\nLogin to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Force", "If this switch is enabled, no version check between Source and Destination is performed. By default, the major and minor versions of Source and Destination must match when copying sp_configure \r\nsettings.", "", 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", "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": "Import-SqlSpConfigure", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Updates sp_configure settings on destination server.", "Name": "Import-DbaSpConfigure", "Links": "https://dbatools.io/Import-DbaSpConfigure", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-DbaSpConfigure -Source sqlserver -Destination sqlcluster\nImports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using Windows Authentication\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eImport-DbaSpConfigure -Source sqlserver -Destination sqlcluster -Force\nImports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using Windows Authentication. Will not do a version check between Source and Destination\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eImport-DbaSpConfigure -Source sqlserver -Destination sqlcluster -SourceSqlCredential $SourceSqlCredential -DestinationSqlCredential $DestinationSqlCredential\nImports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using the SQL credentials stored in the variables $SourceSqlCredential and \r\n$DestinationSqlCredential\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eImport-DbaSpConfigure -SqlInstance sqlserver -Path .\\spconfig.sql -SqlCredential $SqlCredential\nImports the sp_configure settings from the file .\\spconfig.sql and sets them on the sqlserver server using the SQL credential stored in the variable $SqlCredential", "Syntax": "Import-DbaSpConfigure [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nImport-DbaSpConfigure [-Source \u003cDbaInstanceParameter\u003e] [-Destination \u003cDbaInstanceParameter\u003e] [-SourceSqlCredential \u003cPSCredential\u003e] [-DestinationSqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nImport-DbaSpConfigure [-SqlInstance \u003cDbaInstanceParameter\u003e] [-Path \u003cString\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Import-DbaXESessionTemplate", "Description": "Imports a new XESession XML Template either from the dbatools repository or a file you specify.", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "The Name of the session to create.", "", false, "false", "" ], [ "Path", "The path to the xml file or files for the session(s).", "FullName", false, "true (ByPropertyName)", "" ], [ "Template", "Specifies the name of one of the templates from the dbatools repository. Press tab to cycle through the provided templates.", "", false, "false", "" ], [ "TargetFilePath", "By default, files will be created in the default xel directory. Use TargetFilePath to change all instances of\r\nfilename = \"file.xel\" to filename = \"$TargetFilePath\\file.xel\". Only specify the directory, not the file itself.\nThis path is relative to the destination directory", "", false, "false", "" ], [ "TargetFileMetadataPath", "By default, files will be created in the default xem directory. Use TargetFileMetadataPath to change all instances of\r\nfilename = \"file.xem\" to filename = \"$TargetFilePath\\file.xem\". Only specify the directory, not the file itself.\nThis path is relative to the destination directory", "", 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": "Imports a new XESession XML Template", "Name": "Import-DbaXESessionTemplate", "Links": "https://dbatools.io/Import-DbaXESessionTemplate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eImport-DbaXESessionTemplate -SqlInstance sql2017 -Template db_query_wait_stats\nCreates a new XESession named db_query_wait_stats from the dbatools repository to the SQL Server sql2017.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eImport-DbaXESessionTemplate -SqlInstance sql2017 -Template db_query_wait_stats -Name \"Query Wait Stats\"\nCreates a new XESession named \"Query Wait Stats\" using the db_query_wait_stats template.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 -Session db_ola_health | Remove-DbaXESession\nPS C:\\\u003e Import-DbaXESessionTemplate -SqlInstance sql2017 -Template db_ola_health | Start-DbaXESession\nImports a session if it exists, then recreates it using a template.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaXESessionTemplate | Out-GridView -PassThru | Import-DbaXESessionTemplate -SqlInstance sql2017\nAllows you to select a Session template then import to an instance named sql2017.", "Syntax": "Import-DbaXESessionTemplate [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString\u003e] [[-Path] \u003cString[]\u003e] [[-Template] \u003cString[]\u003e] [[-TargetFilePath] \u003cString\u003e] [[-TargetFileMetadataPath] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Install-DbaFirstResponderKit", "Description": "Downloads, extracts and installs the First Responder Kit stored procedures:\nsp_Blitz, sp_BlitzWho, sp_BlitzFirst, sp_BlitzIndex, sp_BlitzCache and sp_BlitzTrace, etc.\n\nFirst Responder Kit links:\nhttp://FirstResponderKit.org\nhttps://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit", "Tags": [ "BrentOzar", "FRK", "FirstResponderKit" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Branch", "Specifies an alternate branch of the First Responder Kit to install. (master or dev)", "", false, "false", "master" ], [ "Database", "Specifies the database to instal the First Responder Kit stored procedures into", "", false, "false", "master" ], [ "LocalFile", "Specifies the path to a local file to install FRK from. This *should* be the zipfile as distributed by the maintainers.\r\nIf this parameter is not specified, the latest version will be downloaded and installed from https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit", "", false, "false", "" ], [ "Force", "If this switch is enabled, the FRK will be downloaded from the internet even if previously cached.", "", 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 to confirm actions", "cf", false, "false", "" ] ], "Alias": "", "Author": "Tara Kizer, Brent Ozar Unlimited (https://www.brentozar.com/)", "Synopsis": "Installs or updates the First Responder Kit stored procedures.", "Name": "Install-DbaFirstResponderKit", "Links": "https://dbatools.io/Install-DbaFirstResponderKit", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance server1 -Database master\nLogs into server1 with Windows authentication and then installs the FRK in the master database.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance server1\\instance1 -Database DBA\nLogs into server1\\instance1 with Windows authentication and then installs the FRK in the DBA database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance server1\\instance1 -Database master -SqlCredential $cred\nLogs into server1\\instance1 with SQL authentication and then installs the FRK in the master database.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance sql2016\\standardrtm, sql2016\\sqlexpress, sql2014\nLogs into sql2016\\standardrtm, sql2016\\sqlexpress and sql2014 with Windows authentication and then installs the FRK in the master database.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers = \"sql2016\\standardrtm\", \"sql2016\\sqlexpress\", \"sql2014\"\nPS C:\\\u003e $servers | Install-DbaFirstResponderKit\nLogs into sql2016\\standardrtm, sql2016\\sqlexpress and sql2014 with Windows authentication and then installs the FRK in the master database.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance sql2016 -Branch dev\nInstalls the dev branch version of the FRK in the master database on sql2016 instance.", "Syntax": "Install-DbaFirstResponderKit [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Branch] \u003cString\u003e] [[-Database] \u003cObject\u003e] [[-LocalFile] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Install-DbaMaintenanceSolution", "Description": "This script will download and install the latest version of SQL Server Maintenance Solution created by Ola Hallengren", "Tags": [ "Ola", "Maintenance" ], "Params": [ [ "SqlInstance", "The target SQL Server instance onto which the Maintenance Solution will be installed.", "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", "" ], [ "Database", "The database where Ola Hallengren\u0027s solution will be installed. Defaults to master.", "", false, "false", "master" ], [ "BackupLocation", "Location of the backup root directory. If this is not supplied, the default backup directory will be used.", "", false, "false", "" ], [ "CleanupTime", "Time in hours, after which backup files are deleted.", "", false, "false", "0" ], [ "OutputFileDirectory", "Specify the output file directory where the Maintenance Solution will write to.", "", false, "false", "" ], [ "ReplaceExisting", "If this switch is enabled, objects already present in the target database will be dropped and recreated.", "", false, "false", "False" ], [ "LogToTable", "If this switch is enabled, the Maintenance Solution will be configured to log commands to a table.", "", false, "false", "False" ], [ "Solution", "Specifies which portion of the Maintenance solution to install. Valid values are All (full solution), Backup, IntegrityCheck and IndexOptimize.", "", false, "false", "All" ], [ "InstallJobs", "If this switch is enabled, the corresponding SQL Agent Jobs will be created.", "", false, "false", "False" ], [ "LocalFile", "Specifies the path to a local file to install Ola\u0027s solution from. This *should* be the zipfile as distributed by the maintainers.\r\nIf this parameter is not specified, the latest version will be downloaded and installed from https://github.com/olahallengren/sql-server-maintenance-solution", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Ola\u0027s solution will be downloaded from the internet even if previously cached.", "", 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", "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": "", "Author": "Viorel Ciucu, cviorel.com", "Synopsis": "Download and Install SQL Server Maintenance Solution created by Ola Hallengren (https://ola.hallengren.com)", "Name": "Install-DbaMaintenanceSolution", "Links": "http://dbatools.io/Install-DbaMaintenanceSolution", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInstall-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -CleanupTime 72\nInstalls Ola Hallengren\u0027s Solution objects on RES14224 in the DBA database.\r\nBackups will default to the default Backup Directory.\r\nIf the Maintenance Solution already exists, the script will be halted.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInstall-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -BackupLocation \"Z:\\SQLBackup\" -CleanupTime 72\nThis will create the Ola Hallengren\u0027s Solution objects. Existing objects are not affected in any way.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInstall-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -BackupLocation \"Z:\\SQLBackup\" -CleanupTime 72 -ReplaceExisting\nThis will drop and then recreate the Ola Hallengren\u0027s Solution objects\r\nThe cleanup script will drop and recreate:\r\n- TABLE [dbo].[CommandLog]\r\n- STORED PROCEDURE [dbo].[CommandExecute]\r\n- STORED PROCEDURE [dbo].[DatabaseBackup]\r\n- STORED PROCEDURE [dbo].[DatabaseIntegrityCheck]\r\n- STORED PROCEDURE [dbo].[IndexOptimize]\nThe following SQL Agent jobs will be deleted:\r\n- \u0027Output File Cleanup\u0027\r\n- \u0027IndexOptimize - USER_DATABASES\u0027\r\n- \u0027sp_delete_backuphistory\u0027\r\n- \u0027DatabaseBackup - USER_DATABASES - LOG\u0027\r\n- \u0027DatabaseBackup - SYSTEM_DATABASES - FULL\u0027\r\n- \u0027DatabaseBackup - USER_DATABASES - FULL\u0027\r\n- \u0027sp_purge_jobhistory\u0027\r\n- \u0027DatabaseIntegrityCheck - SYSTEM_DATABASES\u0027\r\n- \u0027CommandLog Cleanup\u0027\r\n- \u0027DatabaseIntegrityCheck - USER_DATABASES\u0027\r\n- \u0027DatabaseBackup - USER_DATABASES - DIFF\u0027", "Syntax": "Install-DbaMaintenanceSolution [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject\u003e] [[-BackupLocation] \u003cString\u003e] [[-CleanupTime] \u003cInt32\u003e] [[-OutputFileDirectory] \u003cString\u003e] [-ReplaceExisting] [-LogToTable] [[-Solution] \u003cString\u003e] [-InstallJobs] [[-LocalFile] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Install-DbaSqlWatch", "Description": "Downloads, extracts and installs or updates SqlWatch.\nhttps://sqlwatch.io/", "Tags": "SqlWatch", "Params": [ [ "SqlInstance", "SQL Server name or SMO object representing the SQL Server to connect to.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies the database to install SqlWatch into. Defaults to master.", "", false, "false", "master" ], [ "LocalFile", "Specifies the path to a local file to install SqlWatch from. This *should* be the zipfile as distributed by the maintainers.\r\nIf this parameter is not specified, the latest version will be downloaded and installed from https://github.com/marcingminski/sqlwatch", "", false, "false", "" ], [ "Force", "If this switch is enabled, SqlWatch will be downloaded from the internet even if previously cached.", "", 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" ], [ "WhatIf", "Shows what would happen if the command were to run. No actions are actually performed.", "wi", false, "false", "" ], [ "Confirm", "Prompts to confirm actions", "cf", false, "false", "" ] ], "Alias": "", "Author": "Ken K (github.com/koglerk)", "Synopsis": "Installs or updates SqlWatch.", "Name": "Install-DbaSqlWatch", "Links": "https://dbatools.io/Install-DbaSqlWatch", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInstall-DbaSqlWatch -SqlInstance server1\nLogs into server1 with Windows authentication and then installs SqlWatch in the master database.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInstall-DbaSqlWatch -SqlInstance server1\\instance1 -Database DBA\nLogs into server1\\instance1 with Windows authentication and then installs SqlWatch in the DBA database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInstall-DbaSqlWatch -SqlInstance server1\\instance1 -Database DBA -SqlCredential $cred\nLogs into server1\\instance1 with SQL authentication and then installs SqlWatch in the DBA database.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInstall-DbaSqlWatch -SqlInstance sql2016\\standardrtm, sql2016\\sqlexpress, sql2014\nLogs into sql2016\\standardrtm, sql2016\\sqlexpress and sql2014 with Windows authentication and then installs SqlWatch in the master database.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers = \"sql2016\\standardrtm\", \"sql2016\\sqlexpress\", \"sql2014\"\n$servers | Install-DbaSqlWatch\nLogs into sql2016\\standardrtm, sql2016\\sqlexpress and sql2014 with Windows authentication and then installs SqlWatch in the master database.", "Syntax": "Install-DbaSqlWatch [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [[-LocalFile] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Install-DbaWatchUpdate", "Description": "Adds the scheduled task to support Watch-DbaUpdate.", "Tags": "Module", "Params": [ [ "TaskName", "Provide custom name for the Scheduled Task", "", false, "false", "dbatools version check" ], [ "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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds the scheduled task to support Watch-DbaUpdate.", "Name": "Install-DbaWatchUpdate", "Links": "https://dbatools.io/Install-DbaWatchUpdate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInstall-DbaWatchUpdate\nAdds the scheduled task needed by Watch-DbaUpdate\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInstall-DbaWatchUpdate -TaskName MyScheduledTask\nWill create the scheduled task as the name MyScheduledTask", "Syntax": "Install-DbaWatchUpdate [[-TaskName] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Install-DbaWhoIsActive", "Description": "This command downloads, extracts and installs sp_WhoisActive with Adam\u0027s permission. To read more about sp_WhoisActive, please visit http://whoisactive.com and http://sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx\n\nPlease consider donating to Adam if you find this stored procedure helpful: http://tinyurl.com/WhoIsActiveDonate\n\nNote that you will be prompted a bunch of times to confirm an action.", "Tags": [ "AdamMechanic", "WhoIsActive", "SpWhoIsActive" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. 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", "" ], [ "LocalFile", "Specifies the path to a local file to install sp_WhoisActive from. This can be either the zipfile as distributed by the website or the expanded SQL script. If this parameter is not specified, the \r\nlatest version will be downloaded and installed from https://whoisactive.com/", "", false, "false", "" ], [ "Database", "The database to install sp_WhoisActive into. This parameter is mandatory when executing this command unattended.", "", 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" ], [ "Force", "If this switch is enabled, the sp_WhoisActive will be downloaded from the internet even if previously cached.", "", false, "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": "Install-SqlWhoIsActive", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Automatically installs or updates sp_WhoisActive by Adam Machanic.", "Name": "Install-DbaWhoIsActive", "Links": "https://dbatools.io/Install-DbaWhoIsActive", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInstall-DbaWhoIsActive -SqlInstance sqlserver2014a -Database master\nDownloads sp_WhoisActive from the internet and installs to sqlserver2014a\u0027s master database. Connects to SQL Server using Windows Authentication.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInstall-DbaWhoIsActive -SqlInstance sqlserver2014a -SqlCredential $cred\nPops up a dialog box asking which database on sqlserver2014a you want to install the procedure into. Connects to SQL Server using SQL Authentication.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInstall-DbaWhoIsActive -SqlInstance sqlserver2014a -Database master -LocalFile c:\\SQLAdmin\\whoisactive_install.sql\nInstalls sp_WhoisActive to sqlserver2014a\u0027s master database from the local file whoisactive_install.sql\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$instances = Get-DbaCmsRegServer sqlserver\nPS C:\\\u003e Install-DbaWhoIsActive -SqlInstance $instances -Database master\nInstalls sp_WhoisActive to all servers within CMS", "Syntax": "Install-DbaWhoIsActive [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-LocalFile \u003cString\u003e] [-Database \u003cObject\u003e] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaAdvancedRestore", "Description": "This is the final piece in the Restore-DbaDatabase Stack. Usually a BackupHistory object will arrive here from `Restore-Dbadatabase` via the following pipeline:\n`Get-DbaBackupInformation | Select-DbaBackupInformation | Format-DbaBackupInformation | Test-DbaBackupInformation | Invoke-DbaAdvancedRestore`\n\nWe have exposed these functions publicly to allow advanced users to perform operations that we don\u0027t support, or won\u0027t add as they would make things too complex for the majority of our users\n\nFor example if you wanted to do some very complex redirection during a migration, then doing the rewrite of destinations may be better done with your own custom scripts rather than via `Format-DbaBackupInformation`\n\nWe would recommend ALWAYS pushing your input through `Test-DbaBackupInformation` just to make sure that it makes sense to us.", "Tags": [ "Restore", "Backup" ], "Params": [ [ "BackupHistory", "The BackupHistory object to be restored.\r\nCan be passed in on the pipeline", "", true, "true (ByValue)", "" ], [ "SqlInstance", "The SqlInstance to which the backups should be restored", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "SqlCredential to be used to connect to the target SqlInstance", "", false, "false", "" ], [ "OutputScriptOnly", "If set, the restore will not be performed, but the T-SQL scripts to perform it will be returned", "", false, "false", "False" ], [ "VerifyOnly", "If set, performs a Verify of the backups rather than a full restore", "", false, "false", "False" ], [ "RestoreTime", "Point in Time to which the database should be restored.\nThis should be the same value or earlier, as used in the previous pipeline stages", "", false, "false", "(Get-Date).AddDays(2)" ], [ "StandbyDirectory", "A folder path where a standby file should be created to put the recovered databases in a standby mode", "", false, "false", "" ], [ "NoRecovery", "Leave the database in a restoring state so that further restore may be made", "", false, "false", "False" ], [ "MaxTransferSize", "Parameter to set the unit of transfer. Values must be a multiple by 64kb", "", false, "false", "0" ], [ "BlockSize", "Specifies the block size to use. Must be one of 0.5kb,1kb,2kb,4kb,8kb,16kb,32kb or 64kb\r\nCan be specified in bytes\r\nRefer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail", "", false, "false", "0" ], [ "BufferCount", "Number of I/O buffers to use to perform the operation.\r\nRefer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail", "", false, "false", "0" ], [ "Continue", "Indicates that the restore is continuing a restore, so target database must be in Recovering or Standby states", "", false, "false", "False" ], [ "AzureCredential", "AzureCredential required to connect to blob storage holding the backups", "", false, "false", "" ], [ "WithReplace", "Indicated that if the database already exists it should be replaced", "", false, "false", "False" ], [ "KeepCDC", "Indicates whether CDC information should be restored as part of the database", "", false, "false", "False" ], [ "PageRestore", "The output from Get-DbaSuspect page containing the suspect pages to be restored.", "", false, "false", "" ], [ "EnableException", "Replaces user friendly yellow warnings with bloody red exceptions of doom!\r\nUse this if you want the function to throw terminating errors you want to catch.", "", false, "false", "False" ], [ "WhatIf", "Shows what would happen if the cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Allows the restore of modified BackupHistory Objects\nFor 90% of users Restore-DbaDatabase should be your point of access to this function. The other 10% use it at their own risk", "Name": "Invoke-DbaAdvancedRestore", "Links": "https://dbatools.io/Invoke-DbaAdvancedRestore", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance\nWill restore all the backups in the BackupHistory object according to the transformations it contains\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance -OutputScriptOnly\nPS C:\\\u003e $BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance\nFirst generates just the T-SQL restore scripts so they can be sanity checked, and then if they are good perform the full restore.\r\nBy reusing the BackupHistory object there is no need to rescan all the backup files again", "Syntax": "Invoke-DbaAdvancedRestore [-BackupHistory] \u003cObject[]\u003e [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-OutputScriptOnly] [-VerifyOnly] [[-RestoreTime] \u003cDateTime\u003e] [[-StandbyDirectory] \u003cString\u003e] [-NoRecovery] [[-MaxTransferSize] \u003cInt32\u003e] [[-BlockSize] \u003cInt32\u003e] [[-BufferCount] \u003cInt32\u003e] [-Continue] [[-AzureCredential] \u003cString\u003e] [-WithReplace] [-KeepCDC] [[-PageRestore] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaAgFailover", "Description": "Failover an availability group.", "Tags": [ "AG", "AvailabilityGroup", "HA" ], "Params": [ [ "SqlInstance", "The SQL Server instance. Server version must be SQL Server version 2012 or higher.", "", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential).", "", false, "false", "" ], [ "AvailabilityGroup", "Only failover specific availability groups.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup", "", false, "true (ByValue)", "" ], [ "Force", "Force Failover and allow data loss", "", 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" ], [ "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": "Failover an availability group.", "Name": "Invoke-DbaAgFailover", "Links": "https://dbatools.io/Invoke-DbaAgFailover", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaAgFailover -SqlInstance sql2017 -AvailabilityGroup SharePoint\nSafely (no potential data loss) fails over the SharePoint AG on sql2017. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2017 | Out-GridView -Passthru | Invoke-DbaAgFailover -Confirm:$false\nSafely (no potential data loss) fails over the selected availability groups on sql2017. Does not prompt for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaAgFailover -SqlInstance sql2017 -AvailabilityGroup SharePoint -Force\nForcefully (with potential data loss) fails over the SharePoint AG on sql2017. Prompts for confirmation.", "Syntax": "Invoke-DbaAgFailover [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaBalanceDataFiles", "Description": "When you have a large database with a single data file and add another file, SQL Server will only use the new file until it\u0027s about the same size.\nYou may want to balance the data between all the data files.\n\nThe function will check the server version and edition to see if the it allows for online index rebuilds.\nIf the server does support it, it will try to rebuild the index online.\nIf the server doesn\u0027t support it, it will rebuild the index offline. Be carefull though, this can cause downtime\n\nThe tables must have a clustered index to be able to balance out the data.\nThe function does NOT yet support heaps.\n\nThe function will also check if the file groups are subject to balance out.\nA file group whould have at least have 2 data files and should be writable.\nIf a table is within such a file group it will be subject for processing. If not the table will be skipped.", "Tags": [ "Database", "FileManagement", "File", "Space" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database(s) to process.", "Databases", false, "false", "" ], [ "Table", "The tables(s) of the database to process. If unspecified, all tables will be processed.", "Tables", false, "false", "" ], [ "RebuildOffline", "Will set all the indexes to rebuild offline.\r\nThis option is also needed when the server version is below 2005.", "", 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" ], [ "Force", "This will disable the check for enough disk space for the action to be successful.\r\nUse this with caution!!", "", false, "false", "False" ], [ "WhatIf", "Shows what would happen if the command were to run", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step. For example:\nThe server does not support online rebuilds of indexes.\r\nDo you want to rebuild the indexes offline?\r\n[Y] Yes [N] No [?] Help (default is \"Y\"):", "cf", false, "false", "" ] ], "Alias": "", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Re-balance data between data files", "Name": "Invoke-DbaBalanceDataFiles", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1\nThis command will distribute the data in database db1 on instance sql1\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1 | Select-Object -ExpandProperty DataFilesEnd\nThis command will distribute the data in database db1 on instance sql1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1 -Table table1,table2,table5\nThis command will distribute the data for only the tables table1,table2 and table5\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1 -RebuildOffline\nThis command will consider the fact that there might be a SQL Server edition that does not support online rebuilds of indexes.\r\nBy supplying this parameter you give permission to do the rebuilds offline if the edition does not support it.", "Syntax": "Invoke-DbaBalanceDataFiles [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-Table \u003cObject[]\u003e] [-RebuildOffline] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nInvoke-DbaBalanceDataFiles -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-Table \u003cObject[]\u003e] [-RebuildOffline] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaCycleErrorLog", "Description": "Cycles the current error log for the instance (SQL Server) and/or SQL Server Agent.", "Tags": [ "Log", "Cycle" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.You must have sysadmin access and server version must be SQL Server version 2000 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)", "Credential", false, "false", "" ], [ "Type", "The log to cycle.\r\nAccepts: instance or agent.", "", 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", "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": "", "Author": "Shawn Melton (@wsmelton), https://wsmelton.github.io", "Synopsis": "Cycles the current instance or agent log.", "Name": "Invoke-DbaCycleErrorLog", "Links": "https://dbatools.io/Invoke-DbaCycleLog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaCycleLog -SqlInstance sql2016 -Type agent\nCycles the current error log for the SQL Server Agent on SQL Server instance sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaCycleLog -SqlInstance sql2016 -Type instance\nCycles the current error log for the SQL Server instance on SQL Server instance sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaCycleLog -SqlInstance sql2016\nCycles the current error log for both SQL Server instance and SQL Server Agent on SQL Server instance sql2016", "Syntax": "Invoke-DbaCycleErrorLog [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Type] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbClone", "Description": "Clones a database schema and statistics.\n\nThis can be useful for testing query performance without requiring all the space needed for the data in the database.\n\nRead more:\n - https://sqlperformance.com/2016/08/sql-statistics/expanding-dbcc-clonedatabase\n - https://support.microsoft.com/en-us/help/3177838/how-to-use-dbcc-clonedatabase-to-generate-a-schema-and-statistics-only\n\nThanks to Microsoft Tiger Team for the code and idea https://github.com/Microsoft/tigertoolbox/", "Tags": [ "Statistics", "Performance", "Clone" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database to clone - this list is auto-populated from the server.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", false, "true (ByValue)", "" ], [ "CloneDatabase", "The name(s) to clone to.", "", false, "false", "" ], [ "ExcludeStatistics", "Exclude the statistics in the cloned database", "", false, "false", "False" ], [ "ExcludeQueryStore", "Exclude the QueryStore data in the cloned database", "", false, "false", "False" ], [ "UpdateStatistics", "Update the statistics prior to cloning (per Microsoft Tiger Team formula)", "", 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" ], [ "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": "Invoke-DbaDatabaseClone", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Clones a database schema and statistics", "Name": "Invoke-DbaDbClone", "Links": "https://dbatools.io/Invoke-DbaDbClone", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDbClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone\nClones mydb to myclone on sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 -Database mydb | Invoke-DbaDbClone -CloneDatabase myclone, myclone2 -UpdateStatistics\nUpdates the statistics of mydb then clones to myclone and myclone2", "Syntax": "Invoke-DbaDbClone [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [[-CloneDatabase] \u003cString[]\u003e] [-ExcludeStatistics] [-ExcludeQueryStore] [-UpdateStatistics] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbDecryptObject", "Description": "When a procedure or a function is created with encryption and you lost the code you\u0027re in trouble.\nYou cannot alter the object or view the definition.\nWith this command you can search for the object and decrypt the it.\n\nThe command will output the results to the console.\nThere is an option to export all the results to a folder creating .sql files.\n\nMake sure the instance allowed dedicated administrator connections (DAC).\nThe binary versions of the objects can only be retrieved using a DAC connection.\nYou can check the DAC connection with:\n\u0027Get-DbaSpConfigure -SqlInstance [yourinstance] -ConfigName RemoteDacConnectionsEnabled\u0027\nIt should say 1 in the ConfiguredValue.\n\nTo change the configurations you can use the Set-DbaSpConfigure command:\n\u0027Set-DbaSpConfigure -SqlInstance [yourinstance] -ConfigName RemoteDacConnectionsEnabled -Value 1\u0027\nIn some cases you may need to reboot the instance.", "Tags": [ "Encryption", "Decrypt", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "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", "" ], [ "Database", "Database to look through for the object.", "", true, "false", "" ], [ "ObjectName", "The name of the object to search for in the database.", "", false, "false", "" ], [ "EncodingType", "The encoding that\u0027s used to decrypt and encrypt values.", "", false, "false", "ASCII" ], [ "ExportDestination", "Used for exporting the results to.\r\nThe destiation will use the instance name, database name and object type i.e.: C:\\temp\\decrypt\\SQLDB1\\DB1\\StoredProcedure", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Invoke-DbaDbDecryptObject returns the decrypted version of an object", "Name": "Invoke-DbaDbDecryptObject", "Links": "https://dbatools.io/Invoke-DbaDbDecryptObject", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ObjectName Function1\nDecrypt object \"Function1\" in DB1 of instance SQLDB1 and output the data to the user.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ObjectName Function1 -ExportDestination C:\\temp\\decrypt\nDecrypt object \"Function1\" in DB1 of instance SQLDB1 and output the data to the folder \"C:\\temp\\decrypt\".\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ExportDestination C:\\temp\\decrypt\nDecrypt all objects in DB1 of instance SQLDB1 and output the data to the folder \"C:\\temp\\decrypt\"\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ObjectName Function1, Function2\nDecrypt objects \"Function1\" and \"Function2\" and output the data to the user.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\"SQLDB1\" | Invoke-DbaDbDecryptObject -Database DB1 -ObjectName Function1, Function2\nDecrypt objects \"Function1\" and \"Function2\" and output the data to the user using a pipeline for the instance.", "Syntax": "Invoke-DbaDbDecryptObject [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \u003cObject[]\u003e [[-ObjectName] \u003cString[]\u003e] [[-EncodingType] \u003cString\u003e] [[-ExportDestination] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbLogShipping", "Description": "Invoke-DbaDbLogShipping helps to easily set up log shipping for one or more databases.\n\nThis function will make a lot of decisions for you assuming you want default values like a daily interval for the schedules with a 15 minute interval on the day.\nThere are some settings that cannot be made by the function and they need to be prepared before the function is executed.\n\nThe following settings need to be made before log shipping can be initiated:\n- Backup destination (the folder and the privileges)\n- Copy destination (the folder and the privileges)\n\n* Privileges\nMake sure your agent service on both the primary and the secondary instance is an Active Directory account.\nAlso have the credentials ready to set the folder permissions\n\n** Network share\nThe backup destination needs to be shared and have the share privileges of FULL CONTROL to Everyone.\n\n** NTFS permissions\nThe backup destination must have at least read/write permissions for the primary instance agent account.\nThe backup destination must have at least read permissions for the secondary instance agent account.\nThe copy destination must have at least read/write permission for the secondary instance agent acount.", "Tags": "LogShipping", "Params": [ [ "SourceSqlInstance", "Source SQL Server instance which contains the databases to be log shipped.\r\nYou must have sysadmin access and server version must be SQL Server version 2000 or greater.", "SourceServerInstance,SourceSqlServerSqlServer,Source", true, "false", "" ], [ "DestinationSqlInstance", "Destination SQL Server instance which contains the databases to be log shipped.\r\nYou must have sysadmin access and server version must be SQL Server version 2000 or greater.", "DestinationServerInstance,DestinationSqlServer,Destination", true, "false", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "SourceCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Database to set up log shipping for.", "", true, "true (ByValue)", "" ], [ "BackupNetworkPath", "The backup unc path to place the backup files. This is the root directory.\r\nA directory with the name of the database will be created in this path.", "", true, "false", "" ], [ "BackupLocalPath", "If the backup path is locally for the source server you can also set this value.", "", false, "false", "" ], [ "BackupJob", "Name of the backup that will be created in the SQL Server agent.\r\nThe parameter works as a prefix where the name of the database will be added to the backup job name.\r\nThe default is \"LSBackup_[databasename]\"", "", false, "false", "" ], [ "BackupRetention", "The backup retention period in minutes. Default is 4320 / 72 hours", "", false, "false", "0" ], [ "BackupSchedule", "Name of the backup schedule created for the backup job.\r\nThe parameter works as a prefix where the name of the database will be added to the backup job schedule name.\r\nDefault is \"LSBackupSchedule_[databasename]\"", "", false, "false", "" ], [ "BackupScheduleDisabled", "Parameter to set the backup schedule to disabled upon creation.\r\nBy default the schedule is enabled.", "", false, "false", "False" ], [ "BackupScheduleFrequencyType", "A value indicating when a job is to be executed.\r\nAllowed values are \"Daily\", \"AgentStart\", \"IdleComputer\"", "", false, "false", "" ], [ "BackupScheduleFrequencyInterval", "The number of type periods to occur between each execution of the backup job.", "", false, "false", "" ], [ "BackupScheduleFrequencySubdayType", "Specifies the units for the sub-day FrequencyInterval.\r\nAllowed values are \"Time\", \"Seconds\", \"Minutes\", \"Hours\"", "", false, "false", "" ], [ "BackupScheduleFrequencySubdayInterval", "The number of sub-day type periods to occur between each execution of the backup job.", "", false, "false", "0" ], [ "BackupScheduleFrequencyRelativeInterval", "A job\u0027s occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).", "", false, "false", "" ], [ "BackupScheduleFrequencyRecurrenceFactor", "The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only if FrequencyType is 8, \"Weekly\", 16, \"Monthly\", 32 or \"MonthlyRelative\".", "", false, "false", "0" ], [ "BackupScheduleStartDate", "The date on which execution of a job can begin.", "", false, "false", "" ], [ "BackupScheduleEndDate", "The date on which execution of a job can stop.", "", false, "false", "" ], [ "BackupScheduleStartTime", "The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "BackupScheduleEndTime", "The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "BackupThreshold", "Is the length of time, in minutes, after the last backup before a threshold alert error is raised.\r\nThe default is 60.", "", false, "false", "0" ], [ "CompressBackup", "Do the backups need to be compressed. By default the backups are not compressed.", "", false, "false", "False" ], [ "CopyDestinationFolder", "The path to copy the transaction log backup files to. This is the root directory.\r\nA directory with the name of the database will be created in this path.", "", false, "false", "" ], [ "CopyJob", "Name of the copy job that will be created in the SQL Server agent.\r\nThe parameter works as a prefix where the name of the database will be added to the copy job name.\r\nThe default is \"LSBackup_[databasename]\"", "", false, "false", "" ], [ "CopyRetention", "The copy retention period in minutes. Default is 4320 / 72 hours", "", false, "false", "0" ], [ "CopySchedule", "Name of the backup schedule created for the copy job.\r\nThe parameter works as a prefix where the name of the database will be added to the copy job schedule name.\r\nDefault is \"LSCopy_[DestinationServerName]_[DatabaseName]\"", "", false, "false", "" ], [ "CopyScheduleDisabled", "Parameter to set the copy schedule to disabled upon creation.\r\nBy default the schedule is enabled.", "", false, "false", "False" ], [ "CopyScheduleFrequencyType", "A value indicating when a job is to be executed.\r\nAllowed values are \"Daily\", \"AgentStart\", \"IdleComputer\"", "", false, "false", "" ], [ "CopyScheduleFrequencyInterval", "The number of type periods to occur between each execution of the copy job.", "", false, "false", "" ], [ "CopyScheduleFrequencySubdayType", "Specifies the units for the subday FrequencyInterval.\r\nAllowed values are \"Time\", \"Seconds\", \"Minutes\", \"Hours\"", "", false, "false", "" ], [ "CopyScheduleFrequencySubdayInterval", "The number of subday type periods to occur between each execution of the copy job.", "", false, "false", "0" ], [ "CopyScheduleFrequencyRelativeInterval", "A job\u0027s occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).", "", false, "false", "" ], [ "CopyScheduleFrequencyRecurrenceFactor", "The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only if FrequencyType is 8, \"Weekly\", 16, \"Monthly\", 32 or \"MonthlyRelative\".", "", false, "false", "0" ], [ "CopyScheduleStartDate", "The date on which execution of a job can begin.", "", false, "false", "" ], [ "CopyScheduleEndDate", "The date on which execution of a job can stop.", "", false, "false", "" ], [ "CopyScheduleStartTime", "The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "CopyScheduleEndTime", "The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "DisconnectUsers", "If this parameter is set in combinations of standby the users will be disconnected during restore.", "", false, "false", "False" ], [ "FullBackupPath", "Path to an existing full backup. Use this when an existing backup needs to used to initialize the database on the secondary instance.", "", false, "false", "" ], [ "GenerateFullBackup", "If the database is not initialized on the secondary instance it can be done by creating a new full backup and\r\nrestore it for you.", "", false, "false", "False" ], [ "HistoryRetention", "Is the length of time in minutes in which the history is retained.\r\nThe default value is 14420", "", false, "false", "0" ], [ "NoRecovery", "If this parameter is set the database will be in recovery mode. The database will not be readable.\r\nThis setting is default.", "", false, "false", "False" ], [ "NoInitialization", "If this parameter is set the secondary database will not be initialized.\r\nThe database needs to be on the secondary instance in recovery mode.", "", false, "false", "False" ], [ "PrimaryMonitorServer", "Is the name of the monitor server for the primary server.\r\nThe default is the name of the primary sql server.", "", false, "false", "" ], [ "PrimaryMonitorCredential", "Allows you to login to enter a secure credential. Only needs to be used when the PrimaryMonitorServerSecurityMode is 0 or \"sqlserver\"\r\nTo use: $scred = Get-Credential, then pass $scred object to the -PrimaryMonitorCredential parameter.", "", false, "false", "" ], [ "PrimaryMonitorServerSecurityMode", "The security mode used to connect to the monitor server for the primary server. Allowed values are 0, \"sqlserver\", 1, \"windows\"\r\nThe default is 1 or Windows.", "", false, "false", "" ], [ "PrimaryThresholdAlertEnabled", "Enables the Threshold alert for the primary database", "", false, "false", "False" ], [ "RestoreDataFolder", "Folder to be used to restore the database data files. Only used when parameter GenerateFullBackup or UseExistingFullBackup are set.\r\nIf the parameter is not set the default data folder of the secondary instance will be used including the name of the database.\r\nIf the folder is set but doesn\u0027t exist the default data folder of the secondary instance will be used including the name of the database.", "", false, "false", "" ], [ "RestoreLogFolder", "Folder to be used to restore the database log files. Only used when parameter GenerateFullBackup or UseExistingFullBackup are set.\r\nIf the parameter is not set the default transaction log folder of the secondary instance will be used.\r\nIf the folder is set but doesn\u0027t exist the default transaction log folder of the secondary instance will be used.", "", false, "false", "" ], [ "RestoreDelay", "In case a delay needs to be set for the restore.\r\nThe default is 0.", "", false, "false", "0" ], [ "RestoreAlertThreshold", "The amount of minutes after which an alert will be raised is no restore has taken place.\r\nThe default is 45 minutes.", "", false, "false", "0" ], [ "RestoreJob", "Name of the restore job that will be created in the SQL Server agent.\r\nThe parameter works as a prefix where the name of the database will be added to the restore job name.\r\nThe default is \"LSRestore_[databasename]\"", "", false, "false", "" ], [ "RestoreRetention", "The backup retention period in minutes. Default is 4320 / 72 hours", "", false, "false", "0" ], [ "RestoreSchedule", "Name of the backup schedule created for the restore job.\r\nThe parameter works as a prefix where the name of the database will be added to the restore job schedule name.\r\nDefault is \"LSRestore_[DestinationServerName]_[DatabaseName]\"", "", false, "false", "" ], [ "RestoreScheduleDisabled", "Parameter to set the restore schedule to disabled upon creation.\r\nBy default the schedule is enabled.", "", false, "false", "False" ], [ "RestoreScheduleFrequencyType", "A value indicating when a job is to be executed.\r\nAllowed values are \"Daily\", \"AgentStart\", \"IdleComputer\"", "", false, "false", "" ], [ "RestoreScheduleFrequencyInterval", "The number of type periods to occur between each execution of the restore job.", "", false, "false", "" ], [ "RestoreScheduleFrequencySubdayType", "Specifies the units for the subday FrequencyInterval.\r\nAllowed values are \"Time\", \"Seconds\", \"Minutes\", \"Hours\"", "", false, "false", "" ], [ "RestoreScheduleFrequencySubdayInterval", "The number of subday type periods to occur between each execution of the restore job.", "", false, "false", "0" ], [ "RestoreScheduleFrequencyRelativeInterval", "A job\u0027s occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).", "", false, "false", "" ], [ "RestoreScheduleFrequencyRecurrenceFactor", "The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only if FrequencyType is 8, \"Weekly\", 16, \"Monthly\", 32 or \"MonthlyRelative\".", "", false, "false", "0" ], [ "RestoreScheduleStartDate", "The date on which execution of a job can begin.", "", false, "false", "" ], [ "RestoreScheduleEndDate", "The date on which execution of a job can stop.", "", false, "false", "" ], [ "RestoreScheduleStartTime", "The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "RestoreScheduleEndTime", "The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "RestoreThreshold", "The number of minutes allowed to elapse between restore operations before an alert is generated.\r\nThe default value = 0", "", false, "false", "0" ], [ "SecondaryDatabasePrefix", "The secondary database can be renamed to include a prefix.", "", false, "false", "" ], [ "SecondaryDatabaseSuffix", "The secondary database can be renamed to include a suffix.", "", false, "false", "" ], [ "SecondaryMonitorServer", "Is the name of the monitor server for the secondary server.\r\nThe default is the name of the secondary sql server.", "", false, "false", "" ], [ "SecondaryMonitorCredential", "Allows you to login to enter a secure credential. Only needs to be used when the SecondaryMonitorServerSecurityMode is 0 or \"sqlserver\"\r\nTo use: $scred = Get-Credential, then pass $scred object to the -SecondaryMonitorCredential parameter.", "", false, "false", "" ], [ "SecondaryMonitorServerSecurityMode", "The security mode used to connect to the monitor server for the secondary server. Allowed values are 0, \"sqlserver\", 1, \"windows\"\r\nThe default is 1 or Windows.", "", false, "false", "" ], [ "SecondaryThresholdAlertEnabled", "Enables the Threshold alert for the secondary database", "", false, "false", "False" ], [ "Standby", "If this parameter is set the database will be set to standby mode making the database readable.\r\nIf not set the database will be in recovery mode.", "", false, "false", "False" ], [ "StandbyDirectory", "Directory to place the standby file(s) in", "", false, "false", "" ], [ "UseExistingFullBackup", "If the database is not initialized on the secondary instance it can be done by selecting an existing full backup\r\nand restore it for you.", "", false, "false", "False" ], [ "UseBackupFolder", "This enables the user to specify a specific backup folder containing one or more backup files to initialize the database on the secondary instance.", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.\r\nIt will also remove the any present schedules with the same name for the specific job.", "", false, "false", "False" ], [ "EnableException", "Use this switch to disable any kind of verbose messages", "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": "Invoke-DbaLogShipping", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Invoke-DbaDbLogShipping sets up log shipping for one or more databases", "Name": "Invoke-DbaDbLogShipping", "Links": "https://dbatools.io/Invoke-DbaDbLogShipping", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e SourceSqlInstance = \u0027sql1\u0027\r\n\u003e\u003e DestinationSqlInstance = \u0027sql2\u0027\r\n\u003e\u003e Database = \u0027db1\u0027\r\n\u003e\u003e BackupNetworkPath= \u0027\\\\sql1\\logshipping\u0027\r\n\u003e\u003e BackupLocalPath= \u0027D:\\Data\\logshipping\u0027\r\n\u003e\u003e BackupScheduleFrequencyType = \u0027daily\u0027\r\n\u003e\u003e BackupScheduleFrequencyInterval = 1\r\n\u003e\u003e CompressBackup = $true\r\n\u003e\u003e CopyScheduleFrequencyType = \u0027daily\u0027\r\n\u003e\u003e CopyScheduleFrequencyInterval = 1\r\n\u003e\u003e GenerateFullBackup = $true\r\n\u003e\u003e RestoreScheduleFrequencyType = \u0027daily\u0027\r\n\u003e\u003e RestoreScheduleFrequencyInterval = 1\r\n\u003e\u003e SecondaryDatabaseSuffix = \u0027DR\u0027\r\n\u003e\u003e CopyDestinationFolder = \u0027\\\\sql2\\logshippingdest\u0027\r\n\u003e\u003e Force = $true\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Invoke-DbaDbLogShipping @params\nSets up log shipping for database \"db1\" with the backup path to a network share allowing local backups.\r\nIt creates daily schedules for the backup, copy and restore job with all the defaults to be executed every 15 minutes daily.\r\nThe secondary database will be called \"db1_LS\".\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e SourceSqlInstance = \u0027sql1\u0027\r\n\u003e\u003e DestinationSqlInstance = \u0027sql2\u0027\r\n\u003e\u003e Database = \u0027db1\u0027\r\n\u003e\u003e BackupNetworkPath= \u0027\\\\sql1\\logshipping\u0027\r\n\u003e\u003e GenerateFullBackup = $true\r\n\u003e\u003e Force = $true\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Invoke-DbaDbLogShipping @params\nSets up log shipping with all defaults except that a backup file is generated.\r\nThe script will show a message that the copy destination has not been supplied and asks if you want to use the default which would be the backup directory of the secondary server with the folder \r\n\"logshipping\" i.e. \"D:\\SQLBackup\\Logshiping\".", "Syntax": "Invoke-DbaDbLogShipping [-SourceSqlInstance] \u003cObject\u003e [-DestinationSqlInstance] \u003cObject[]\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-SourceCredential] \u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-DestinationCredential] \u003cPSCredential\u003e] [-Database] \u003cObject[]\u003e [-BackupNetworkPath] \u003cString\u003e [[-BackupLocalPath] \u003cString\u003e] [[-BackupJob] \u003cString\u003e] [[-BackupRetention] \u003cInt32\u003e] [[-BackupSchedule] \u003cString\u003e] [-BackupScheduleDisabled] [[-BackupScheduleFrequencyType] \u003cObject\u003e] [[-BackupScheduleFrequencyInterval] \u003cObject[]\u003e] [[-BackupScheduleFrequencySubdayType] \u003cObject\u003e] \r\n[[-BackupScheduleFrequencySubdayInterval] \u003cInt32\u003e] [[-BackupScheduleFrequencyRelativeInterval] \u003cObject\u003e] [[-BackupScheduleFrequencyRecurrenceFactor] \u003cInt32\u003e] [[-BackupScheduleStartDate] \u003cString\u003e] [[-BackupScheduleEndDate] \u003cString\u003e] [[-BackupScheduleStartTime] \u003cString\u003e] [[-BackupScheduleEndTime] \u003cString\u003e] [[-BackupThreshold] \u003cInt32\u003e] [-CompressBackup] [[-CopyDestinationFolder] \u003cString\u003e] [[-CopyJob] \u003cString\u003e] [[-CopyRetention] \u003cInt32\u003e] [[-CopySchedule] \u003cString\u003e] [-CopyScheduleDisabled] [[-CopyScheduleFrequencyType] \u003cObject\u003e] [[-CopyScheduleFrequencyInterval] \u003cObject[]\u003e] \r\n[[-CopyScheduleFrequencySubdayType] \u003cObject\u003e] [[-CopyScheduleFrequencySubdayInterval] \u003cInt32\u003e] [[-CopyScheduleFrequencyRelativeInterval] \u003cObject\u003e] [[-CopyScheduleFrequencyRecurrenceFactor] \u003cInt32\u003e] [[-CopyScheduleStartDate] \u003cString\u003e] [[-CopyScheduleEndDate] \u003cString\u003e] [[-CopyScheduleStartTime] \u003cString\u003e] [[-CopyScheduleEndTime] \u003cString\u003e] [-DisconnectUsers] [[-FullBackupPath] \u003cString\u003e] [-GenerateFullBackup] [[-HistoryRetention] \u003cInt32\u003e] [-NoRecovery] [-NoInitialization] [[-PrimaryMonitorServer] \u003cString\u003e] [[-PrimaryMonitorCredential] \u003cPSCredential\u003e] [[-PrimaryMonitorServerSecurityMode] \u003cObject\u003e] \r\n[-PrimaryThresholdAlertEnabled] [[-RestoreDataFolder] \u003cString\u003e] [[-RestoreLogFolder] \u003cString\u003e] [[-RestoreDelay] \u003cInt32\u003e] [[-RestoreAlertThreshold] \u003cInt32\u003e] [[-RestoreJob] \u003cString\u003e] [[-RestoreRetention] \u003cInt32\u003e] [[-RestoreSchedule] \u003cString\u003e] [-RestoreScheduleDisabled] [[-RestoreScheduleFrequencyType] \u003cObject\u003e] [[-RestoreScheduleFrequencyInterval] \u003cObject[]\u003e] [[-RestoreScheduleFrequencySubdayType] \u003cObject\u003e] [[-RestoreScheduleFrequencySubdayInterval] \u003cInt32\u003e] [[-RestoreScheduleFrequencyRelativeInterval] \u003cObject\u003e] [[-RestoreScheduleFrequencyRecurrenceFactor] \u003cInt32\u003e] [[-RestoreScheduleStartDate] \r\n\u003cString\u003e] [[-RestoreScheduleEndDate] \u003cString\u003e] [[-RestoreScheduleStartTime] \u003cString\u003e] [[-RestoreScheduleEndTime] \u003cString\u003e] [[-RestoreThreshold] \u003cInt32\u003e] [[-SecondaryDatabasePrefix] \u003cString\u003e] [[-SecondaryDatabaseSuffix] \u003cString\u003e] [[-SecondaryMonitorServer] \u003cString\u003e] [[-SecondaryMonitorCredential] \u003cPSCredential\u003e] [[-SecondaryMonitorServerSecurityMode] \u003cObject\u003e] [-SecondaryThresholdAlertEnabled] [-Standby] [[-StandbyDirectory] \u003cString\u003e] [-UseExistingFullBackup] [[-UseBackupFolder] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbLogShipRecovery", "Description": "By default all the databases for a particular instance are recovered.\nIf the database is in the right state, either standby or recovering, the process will try to recover the database.\n\nAt first the function will check if the backup source directory can still be reached.\nIf so it will look up the last transaction log backup for the database. If that backup file is not the last copied file the log shipping copy job will be started.\nIf the directory cannot be reached for the function will continue to the restoring process.\nAfter the copy job check is performed the job is disabled to prevent the job to run.\n\nFor the restore the log shipping status is checked in the msdb database.\nIf the last restored file is not the same as the last file name found, the log shipping restore job will be executed.\nAfter the restore job check is performed the job is disabled to prevent the job to run\n\nThe last part is to set the database online by restoring the databases with recovery", "Tags": "LogShipping", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "Database", "Database to perform the restore for. This value can also be piped enabling multiple databases to be recovered.\r\nIf this value is not supplied all databases will be recovered.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "NoRecovery", "Allows you to choose to not restore the database to a functional state (Normal) in the final steps of the process.\r\nBy default the database is restored to a functional state (Normal).", "", 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" ], [ "Force", "Use this parameter to force the function to continue and perform any adjusting actions to successfully execute", "", false, "false", "False" ], [ "InputObject", "Allows piped input from Get-DbaDatabase", "", false, "true (ByValue)", "" ], [ "Delay", "Set the delay in seconds to wait for the copy and/or restore jobs.\r\nBy default the delay is 5 seconds", "", false, "false", "5" ], [ "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": "Invoke-DbaLogShippingRecovery", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Invoke-DbaDbLogShipRecovery recovers log shipped databases to a normal state to act upon a migration or disaster.", "Name": "Invoke-DbaDbLogShipRecovery", "Links": "https://dbatools.io/Invoke-DbaDbLogShipRecovery", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDbLogShipRecovery -SqlInstance server1\nRecovers all the databases on the instance that are enabled for log shipping\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaDbLogShipRecovery -SqlInstance server1 -SqlCredential $cred -Verbose\nRecovers all the databases on the instance that are enabled for log shipping using a credential\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaDbLogShipRecovery -SqlInstance server1 -database db_logship -Verbose\nRecovers the database \"db_logship\" to a normal status\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003edb1, db2, db3, db4 | Invoke-DbaDbLogShipRecovery -SqlInstance server1 -Verbose\nRecovers the database db1, db2, db3, db4 to a normal status\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eInvoke-DbaDbLogShipRecovery -SqlInstance server1 -WhatIf\nShows what would happen if the command were executed.", "Syntax": "Invoke-DbaDbLogShipRecovery [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Database] \u003cString[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-NoRecovery] [-EnableException] [-Force] [[-InputObject] \u003cDatabase[]\u003e] [[-Delay] \u003cInt32\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbMirrorFailover", "Description": "Failover a mirrored database", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "SQL Server name or SMO object representing the primary SQL Server.", "", false, "false", "" ], [ "SqlCredential", "Login to the primary instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database or databases to mirror", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaDatabase", "", false, "true (ByValue)", "" ], [ "Force", "Force Failover and allow data loss", "", 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" ], [ "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": "Failover a mirrored database", "Name": "Invoke-DbaDbMirrorFailover", "Links": "https://dbatools.io/Invoke-DbaDbMirrorFailover", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDbMirrorFailover -SqlInstance sql2016 -Database pubs\nFails over the pubs database on sql2016. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 -Database pubs | Invoke-DbaDbMirrorFailover -Force -Confirm:$false\nForces the failover of the pubs database on sql2016 and allows data loss.\r\nDoes not prompt for confirmation.", "Syntax": "Invoke-DbaDbMirrorFailover [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbMirroring", "Description": "Automates the creation of database mirrors.\n\n* Verifies that a mirror is possible\n* Sets the recovery model to Full if needed\n* If the database does not exist on mirror or witness, a backup/restore is performed\n* Sets up endpoints if necessary\n* Creates a login and grants permissions to service accounts if needed\n* Starts endpoints if needed\n* Sets up partner for mirror\n* Sets up partner for primary\n* Sets up witness if one is specified\n\nNOTE: If a backup / restore is performed, the backups will be left in tact on the network share.", "Tags": [ "Mirror", "HA" ], "Params": [ [ "Primary", "SQL Server name or SMO object representing the primary SQL Server.", "", false, "false", "" ], [ "PrimarySqlCredential", "Login to the primary instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Mirror", "SQL Server name or SMO object representing the mirror SQL Server.", "", true, "false", "" ], [ "MirrorSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Witness", "SQL Server name or SMO object representing the witness SQL Server.", "", false, "false", "" ], [ "WitnessSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database or databases to mirror.", "", false, "false", "" ], [ "SharedPath", "The network share where the backups will be backed up and restored from.\nEach SQL Server service account must have access to this share.\nNOTE: If a backup / restore is performed, the backups will be left in tact on the network share.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase.", "", false, "true (ByValue)", "" ], [ "UseLastBackup", "Use the last full backup of database.", "", false, "false", "False" ], [ "Force", "Drop and recreate the database on remote servers using fresh backup.", "", 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" ], [ "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": "Automates the creation of database mirrors.", "Name": "Invoke-DbaDbMirroring", "Links": "https://dbatools.io/Invoke-DbaDbMirroring", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e Primary = \u0027sql2017a\u0027\r\n\u003e\u003e Mirror = \u0027sql2017b\u0027\r\n\u003e\u003e MirrorSqlCredential = \u0027sqladmin\u0027\r\n\u003e\u003e Witness = \u0027sql2019\u0027\r\n\u003e\u003e Database = \u0027pubs\u0027\r\n\u003e\u003e SharedPath = \u0027\\\\nas\\sql\\share\u0027\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Invoke-DbaDbMirror @params\nPerforms a bunch of checks to ensure the pubs database on sql2017a\r\ncan be mirrored from sql2017a to sql2017b. Logs in to sql2019 and sql2017a\r\nusing Windows credentials and sql2017b using a SQL credential.\nPrompts for confirmation for most changes. To avoid confirmation, use -Confirm:$false or\r\nuse the syntax in the second example.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e Primary = \u0027sql2017a\u0027\r\n\u003e\u003e Mirror = \u0027sql2017b\u0027\r\n\u003e\u003e MirrorSqlCredential = \u0027sqladmin\u0027\r\n\u003e\u003e Witness = \u0027sql2019\u0027\r\n\u003e\u003e Database = \u0027pubs\u0027\r\n\u003e\u003e SharedPath = \u0027\\\\nas\\sql\\share\u0027\r\n\u003e\u003e Force = $true\r\n\u003e\u003e Confirm = $false\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Invoke-DbaDbMirror @params\nPerforms a bunch of checks to ensure the pubs database on sql2017a\r\ncan be mirrored from sql2017a to sql2017b. Logs in to sql2019 and sql2017a\r\nusing Windows credentials and sql2017b using a SQL credential.\nDrops existing pubs database on Mirror and Witness and restores them with\r\na fresh backup.\nDoes all the things in the decription, does not prompt for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$map = @{ \u0027database_data\u0027 = \u0027M:\\Data\\database_data.mdf\u0027 \u0027database_log\u0027 = \u0027L:\\Log\\database_log.ldf\u0027 }\nPS C:\\\u003e Get-ChildItem \\\\nas\\seed | Restore-DbaDatabase -SqlInstance sql2017b -FileMapping $map -NoRecovery\r\nPS C:\\\u003e Get-DbaDatabase -SqlInstance sql2017a -Database pubs | Invoke-DbaDbMirroring -Mirror sql2017b -Confirm:$false\nRestores backups from sql2017a to a specific file struture on sql2017b then creates mirror with no prompts for confirmation.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017a -Database pubs |\n\u003e\u003e Invoke-DbaDbMirroring -Mirror sql2017b -UseLastBackup -Confirm:$false\nMirrors pubs on sql2017a to sql2017b and uses the last full and logs from sql2017a to seed. Doesn\u0027t prompt for confirmation.", "Syntax": "Invoke-DbaDbMirroring [[-Primary] \u003cDbaInstanceParameter\u003e] [[-PrimarySqlCredential] \u003cPSCredential\u003e] [-Mirror] \u003cDbaInstanceParameter[]\u003e [[-MirrorSqlCredential] \u003cPSCredential\u003e] [[-Witness] \u003cDbaInstanceParameter\u003e] [[-WitnessSqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-SharedPath] \u003cString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-UseLastBackup] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbShrink", "Description": "Shrinks all files in a database. Databases should be shrunk only when completely necessary.\n\nMany awesome SQL people have written about why you should not shrink your data files. Paul Randal and Kalen Delaney wrote great posts about this topic:\n\nhttp://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-files\nhttp://sqlmag.com/sql-server/shrinking-data-files\n\nHowever, there are some cases where a database will need to be shrunk. In the event that you must shrink your database:\n\n1. Ensure you have plenty of space for your T-Log to grow\n2. Understand that shrinks require a lot of CPU and disk resources\n3. Consider running DBCC INDEXDEFRAG or ALTER INDEX ... REORGANIZE after the shrink is complete.", "Tags": [ "Shrink", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to the default instance on localhost.", "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", "" ], [ "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", "" ], [ "AllUserDatabases", "Run command against all user databases.", "", false, "false", "False" ], [ "PercentFreeSpace", "Specifies how much free space to leave, defaults to 0.", "", false, "false", "0" ], [ "ShrinkMethod", "Specifies the method that is used to shrink the database\r\nDefault\r\nData in pages located at the end of a file is moved to pages earlier in the file. Files are truncated to reflect allocated space.\r\nEmptyFile\r\nMigrates all of the data from the referenced file to other files in the same filegroup. (DataFile and LogFile objects only).\r\nNoTruncate\r\nData in pages located at the end of a file is moved to pages earlier in the file.\r\nTruncateOnly\r\nData distribution is not affected. Files are truncated to reflect allocated space, recovering free space at the end of any file.", "", false, "false", "Default" ], [ "FileType", "Specifies the files types that will be shrunk\r\nAll - All Data and Log files are shrunk, using database shrink (Default)\r\nData - Just the Data files are shrunk using file shrink\r\nLog - Just the Log files are shrunk using file shrink", "", false, "false", "All" ], [ "StepSizeMB", "If specified, this will chunk a larger shrink operation into multiple smaller shrinks.\r\nIf shrinking a file by a large amount there are benefits of doing multiple smaller chunks.", "", false, "false", "0" ], [ "StatementTimeout", "Timeout in minutes. Defaults to infinity (shrinks can take a while).", "", false, "false", "0" ], [ "LogsOnly", "Deprecated. Use FileType instead.", "", false, "false", "False" ], [ "ExcludeIndexStats", "Exclude statistics about fragmentation.", "", false, "false", "False" ], [ "ExcludeUpdateUsage", "Exclude DBCC UPDATE USAGE for database.", "", 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.", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step. For example:\nAre you sure you want to perform this action?\r\nPerforming the operation \"Shrink database\" on target \"pubs on SQL2016\\VNEXT\".\r\n[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is \"Y\"):", "cf", false, "false", "" ] ], "Alias": "Invoke-DbaDatabaseShrink", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Shrinks all files in a database. This is a command that should rarely be used.\n\n- Shrinks can cause severe index fragmentation (to the tune of 99%)\n- Shrinks can cause massive growth in the database\u0027s transaction log\n- Shrinks can require a lot of time and system resources to perform data movement", "Name": "Invoke-DbaDbShrink", "Links": "https://dbatools.io/Invoke-DbaDbShrink", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2016 -Database Northwind,pubs,Adventureworks2014\nShrinks Northwind, pubs and Adventureworks2014 to have as little free space as possible.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2014 -Database AdventureWorks2014 -PercentFreeSpace 50\nShrinks AdventureWorks2014 to have 50% free space. So let\u0027s say AdventureWorks2014 was 1GB and it\u0027s using 100MB space. The database free space would be reduced to 50MB.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2014 -Database AdventureWorks2014 -PercentFreeSpace 50 -FileType Data -StepSizeMB 25\nShrinks AdventureWorks2014 to have 50% free space, runs shrinks in 25MB chunks for improved performance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2012 -AllUserDatabases\nShrinks all databases on SQL2012 (not ideal for production)", "Syntax": "Invoke-DbaDbShrink [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-AllUserDatabases] [[-PercentFreeSpace] \u003cInt32\u003e] [[-ShrinkMethod] \u003cString\u003e] [[-FileType] \u003cString\u003e] [[-StepSizeMB] \u003cInt32\u003e] [[-StatementTimeout] \u003cInt32\u003e] [-LogsOnly] [-ExcludeIndexStats] [-ExcludeUpdateUsage] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDbUpgrade", "Description": "Updates compatibility level, then runs CHECKDB with data_purity, DBCC updateusage, sp_updatestats and finally sp_refreshview against all user views.", "Tags": [ "Shrink", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "", false, "false", "" ], [ "Database", "The database(s) to process - this list is autopopulated from the server. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is autopopulated from the server", "", false, "false", "" ], [ "NoCheckDb", "Skip checkdb", "", false, "false", "False" ], [ "NoUpdateUsage", "Skip usage update", "", false, "false", "False" ], [ "NoUpdateStats", "Skip stats update", "", false, "false", "False" ], [ "NoRefreshView", "Skip view update", "", false, "false", "False" ], [ "AllUserDatabases", "Run command against all user databases", "", false, "false", "False" ], [ "Force", "Don\u0027t skip over databases that are already at the same level the instance is", "", false, "false", "False" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase)", "", 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.", "Silent", false, "false", "False" ], [ "WhatIf", "Shows what would happen if the command were to run", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step. For example:\nAre you sure you want to perform this action?\r\nPerforming the operation \"Update database\" on target \"pubs on SQL2016\\VNEXT\".\r\n[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is \"Y\"):", "cf", false, "false", "" ] ], "Alias": "Invoke-DbaDatabaseUpgrade", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Take a database and upgrades it to compatibility of the SQL Instance its hosted on. Based on https://thomaslarock.com/2014/06/upgrading-to-sql-server-2014-a-dozen-things-to-check/", "Name": "Invoke-DbaDbUpgrade", "Links": "https://dbatools.io/Invoke-DbaDbUpgrade", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDbUpgrade -SqlInstance PRD-SQL-MSD01 -Database Test\nRuns the below processes against the databases\r\n-- Puts compatibility of database to level of SQL Instance\r\n-- Runs CHECKDB DATA_PURITY\r\n-- Runs DBCC UPDATESUSAGE\r\n-- Updates all users statistics\r\n-- Runs sp_refreshview against every view in the database\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaDbUpgrade -SqlInstance PRD-SQL-INT01 -Database Test -NoRefreshView\nRuns the upgrade command skipping the sp_refreshview update on all views\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaDbUpgrade -SqlInstance PRD-SQL-INT01 -Database Test -Force\nIf database Test is already at the correct compatibility, runs every necessary step\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 | Out-GridView -Passthru | Invoke-DbaDbUpgrade\nGet only specific databases using GridView and pass those to Invoke-DbaDbUpgrade", "Syntax": "Invoke-DbaDbUpgrade [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-NoCheckDb] [-NoUpdateUsage] [-NoUpdateStats] [-NoRefreshView] [-AllUserDatabases] [-Force] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaDiagnosticQuery", "Description": "This is the main function of the Sql Server Diagnostic Queries related functions in dbatools.\nThe diagnostic queries are developed and maintained by Glenn Berry and they can be found here along with a lot of documentation:\nhttp://www.sqlskills.com/blogs/glenn/category/dmv-queries/\n\nThe most recent version of the diagnostic queries are included in the dbatools module.\nBut it is possible to download a newer set or a specific version to an alternative location and parse and run those scripts.\nIt will run all or a selection of those scripts on one or multiple servers and return the result as a PowerShell Object", "Tags": [ "Database", "DMV" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Can be either a string or SMO server", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Database", "The database(s) to process. If unspecified, all databases will be processed", "DatabaseName", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude", "", false, "false", "" ], [ "ExcludeQuery", "The Queries to exclude", "", false, "false", "" ], [ "SqlCredential", "Allows alternative Windows or SQL login credentials to be used", "Credential", false, "false", "" ], [ "Path", "Alternate path for the diagnostic scripts", "", false, "false", "" ], [ "QueryName", "Only run specific query", "", false, "false", "" ], [ "UseSelectionHelper", "Provides a gridview with all the queries to choose from and will run the selection made by the user on the Sql Server instance specified.", "", false, "false", "False" ], [ "InstanceOnly", "Run only instance level queries", "", false, "false", "False" ], [ "DatabaseSpecific", "Run only database level queries", "", false, "false", "False" ], [ "NoQueryTextColumn", "Use this switch to exclude the [Complete Query Text] column from relevant queries", "", false, "false", "False" ], [ "NoPlanColumn", "Use this switch to exclude the [Query Plan] column from relevant queries", "", false, "false", "False" ], [ "NoColumnParsing", "Does not parse the [Complete Query Text] and [Query Plan] columns and disregards the NoQueryTextColumn and NoColumnParsing switches", "", false, "false", "False" ], [ "OutputPath", "Directory to parsed diagnostict queries to. This will split them based on server, databasename, and query.", "", false, "false", "" ], [ "ExportQueries", "Use this switch to export the diagnostic queries to sql files. I\r\nnstead of running the queries, the server will be evaluated to find the appropriate queries to run based on SQL Version.\r\nThese sql files will then be created in the OutputDirectory", "", 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 would execute, but does not actually perform the command", "wi", false, "false", "" ], [ "Confirm", "Prompts to confirm certain actions", "cf", false, "false", "" ] ], "Alias": "", "Author": "Andre Kamman (@AndreKamman), http://clouddba.io", "Synopsis": "Invoke-DbaDiagnosticQuery runs the scripts provided by Glenn Berry\u0027s DMV scripts on specified servers", "Name": "Invoke-DbaDiagnosticQuery", "Links": "https://dbatools.io/Invoke-DbaDiagnosticQuery", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -SqlInstance sql2016\nRun the selection made by the user on the Sql Server instance specified.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -SqlInstance sql2016 -UseSelectionHelper | Export-DbaDiagnosticQuery -Path C:\\temp\\gboutput\nProvides a gridview with all the queries to choose from and will run the selection made by the user on the SQL Server instance specified.\r\nThen it will export the results to Export-DbaDiagnosticQuery.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -sqlinstance localhost -ExportQueries -outputpath \"C:\\temp\\DiagnosticQueries\"\nExport All Queries to Disk\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -sqlinstance localhost -DatabaseSpecific -DatabaseName \u0027tempdb\u0027 -ExportQueries -outputpath \"C:\\temp\\DiagnosticQueries\"\nExport Database Specific Queries for all User Dbs\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -sqlinstance localhost -DatabaseSpecific -DatabaseName \u0027tempdb\u0027 -ExportQueries -outputpath \"C:\\temp\\DiagnosticQueries\"\nExport Database Specific Queries For One Target Database\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -sqlinstance localhost -DatabaseSpecific -DatabaseName \u0027tempdb\u0027 -ExportQueries -outputpath \"C:\\temp\\DiagnosticQueries\" -queryname \u0027Database-scoped Configurations\u0027\nExport Database Specific Queries For One Target Database and One Specific Query\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -sqlinstance localhost -UseSelectionHelper\nChoose Queries To Export\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003e[PSObject[]]$results = Invoke-DbaDiagnosticQuery -SqlInstance localhost -whatif\nParse the appropriate diagnostic queries by connecting to server, and instead of running them, return as [PSCustomObject[]] to work with further\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003e$results = Invoke-DbaDiagnosticQuery -SqlInstance Sql2017 -DatabaseSpecific -queryname \u0027Database-scoped Configurations\u0027 -databasename TestStuff\nRun diagnostic queries targeted at specific database, and only run database level queries against this database.", "Syntax": "Invoke-DbaDiagnosticQuery [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-ExcludeQuery \u003cObject[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Path \u003cFileInfo\u003e] [-QueryName \u003cString[]\u003e] [-UseSelectionHelper] [-InstanceOnly] [-DatabaseSpecific] [-NoQueryTextColumn] [-NoPlanColumn] [-NoColumnParsing] [-OutputPath \u003cString\u003e] [-ExportQueries] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaPfRelog", "Description": "Pipeline-compatible wrapper for the relog command. Relog is useful for converting Windows Perfmon.\n\nExtracts performance counters from performance counter logs into other formats,\nsuch as text-TSV (for tab-delimited text), text-CSV (for comma-delimited text), binary-BIN, or SQL.\n\n`relog \"C:\\PerfLogs\\Admin\\System Correlation\\WORKSTATIONX_20180112-000001\\DataCollector01.blg\" -o C:\\temp\\foo.csv -f tsv`\n\nIf you find any input hangs, please send us the output so we can accommodate for it then use -Raw for an immediate solution.", "Tags": [ "Performance", "DataCollector", "PerfCounter", "Relog" ], "Params": [ [ "Path", "Specifies the pathname of an existing performance counter log or performance counter path. You can specify multiple input files.", "FullName", false, "true (ByPropertyName)", "" ], [ "Destination", "Specifies the pathname of the output file or SQL database where the counters will be written. Defaults to the same directory as the source.", "", false, "false", "" ], [ "Type", "The output format. Defaults to tsv. Options include tsv, csv, bin, and sql.\nFor a SQL database, the output file specifies the DSN!counter_log. You can specify the database location by using the ODBC manager to configure the DSN (Database System Name).\nFor more information, read here: https://technet.microsoft.com/en-us/library/bb490958.aspx", "", false, "false", "tsv" ], [ "Append", "If this switch is enabled, output will be appended to the specified file instead of overwriting. This option does not apply to SQL format where the default is always to append.", "", false, "false", "False" ], [ "AllowClobber", "If this switch is enabled, the destination file will be overwritten if it exists.", "", false, "false", "False" ], [ "PerformanceCounter", "Specifies the performance counter path to log.", "", false, "false", "" ], [ "PerformanceCounterPath", "Specifies the pathname of the text file that lists the performance counters to be included in a relog file. Use this option to list counter paths in an input file, one per line. Default setting is \r\nall counters in the original log file are relogged.", "", false, "false", "" ], [ "Interval", "Specifies sample intervals in \"n\" records. Includes every nth data point in the relog file. Default is every data point.", "", false, "false", "0" ], [ "BeginTime", "This is is Get-Date object and we format it for you.", "", false, "false", "" ], [ "EndTime", "Specifies end time for copying last record from the input file. This is is Get-Date object and we format it for you.", "", false, "false", "" ], [ "ConfigPath", "Specifies the pathname of the settings file that contains command-line parameters.", "", false, "false", "" ], [ "Summary", "If this switch is enabled, the performance counters and time ranges of log files specified in the input file will be displayed.", "", false, "false", "False" ], [ "InputObject", "Accepts the output of Get-DbaPfDataCollector and Get-DbaPfDataCollectorSet as input via the pipeline.", "", false, "true (ByValue)", "" ], [ "Multithread", "If this switch is enabled, processing will be done in parallel. This may speed up large batches or large files.", "", false, "false", "False" ], [ "AllTime", "If this switch is enabled and a datacollector or datacollectorset is passed in via the pipeline, collects all logs, not just the latest.", "", false, "false", "False" ], [ "Raw", "If this switch is enabled, the results of the DOS command instead of Get-ChildItem will be displayed. This does not run in parallel.", "", 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": "Pipeline-compatible wrapper for the relog command which is available on modern Windows platforms.", "Name": "Invoke-DbaPfRelog", "Links": "https://dbatools.io/Invoke-DbaPfRelog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaPfRelog -Path C:\\temp\\perfmon.blg\nCreates C:\\temp\\perfmon.tsv from C:\\temp\\perfmon.blg.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaPfRelog -Path C:\\temp\\perfmon.blg -Destination C:\\temp\\a\\b\\c\nCreates the temp, a, and b directories if needed, then generates c.tsv (tab separated) from C:\\temp\\perfmon.blg.\nReturns the newly created file as a file object.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2016 | Get-DbaPfDataCollector | Invoke-DbaPfRelog -Destination C:\\temp\\perf\nCreates C:\\temp\\perf if needed, then generates computername-datacollectorname.tsv (tab separated) from the latest logs of all data collector sets on sql2016. This destination format was chosen to \r\navoid naming conflicts with piped input.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-DbaPfRelog -Path C:\\temp\\perfmon.blg -Destination C:\\temp\\a\\b\\c -Raw\n```\r\n[Invoke-DbaPfRelog][21:21:35] relog \"C:\\temp\\perfmon.blg\" -f csv -o C:\\temp\\a\\b\\c\nInput\r\n----------------\r\nFile(s):\r\nC:\\temp\\perfmon.blg (Binary)\nBegin: 1/13/2018 5:13:23\r\nEnd: 1/13/2018 14:29:55\r\nSamples: 2227\n100.00%\nOutput\r\n----------------\r\nFile: C:\\temp\\a\\b\\c.csv\nBegin: 1/13/2018 5:13:23\r\nEnd: 1/13/2018 14:29:55\r\nSamples: 2227\nThe command completed successfully.\r\n```\nCreates the temp, a, and b directories if needed, then generates c.tsv (tab separated) from C:\\temp\\perfmon.blg then outputs the raw results of the relog command.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eInvoke-DbaPfRelog -Path \u0027C:\\temp\\perflog with spaces.blg\u0027 -Destination C:\\temp\\a\\b\\c -Type csv -BeginTime ((Get-Date).AddDays(-30)) -EndTime ((Get-Date).AddDays(-1))\nCreates the temp, a, and b directories if needed, then generates c.csv (comma separated) from C:\\temp\\perflog with spaces.blg\u0027, starts 30 days ago and ends one day ago.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$servers | Get-DbaPfDataCollectorSet | Get-DbaPfDataCollector | Invoke-DbaPfRelog -Multithread -AllowClobber\nRelogs latest data files from all collectors within the servers listed in $servers.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollector -Collector DataCollector01 | Invoke-DbaPfRelog -AllowClobber -AllTime\nRelogs all the log files from the DataCollector01 on the local computer and allows overwrite.", "Syntax": "Invoke-DbaPfRelog [[-Path] \u003cString[]\u003e] [[-Destination] \u003cString\u003e] [[-Type] \u003cString\u003e] [-Append] [-AllowClobber] [[-PerformanceCounter] \u003cString[]\u003e] [[-PerformanceCounterPath] \u003cString\u003e] [[-Interval] \u003cInt32\u003e] [[-BeginTime] \u003cDateTime\u003e] [[-EndTime] \u003cDateTime\u003e] [[-ConfigPath] \u003cString\u003e] [-Summary] [[-InputObject] \u003cObject[]\u003e] [-Multithread] [-AllTime] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaQuery", "Description": "This function is a wrapper command around Invoke-DbaAsync, which in turn is based on Invoke-SqlCmd2.\nIt was designed to be more convenient to use in a pipeline and to behave in a way consistent with the rest of our functions.", "Tags": [ "Database", "Query" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server Instance as a different user. This can be a Windows or SQL Server account. Windows users are determined by the existence of a backslash, so if you \r\nare intending to use an alternative Windows connection instead of a SQL login, ensure it contains a backslash.", "Credential", false, "false", "" ], [ "Database", "The database to select before running the query. This list is auto-populated from the server.", "", false, "false", "" ], [ "Query", "Specifies one or more queries to be run. The queries can be Transact-SQL, XQuery statements, or sqlcmd commands. Multiple queries in a single batch may be separated by a semicolon or a GO\nEscape any double quotation marks included in the string.\nConsider using bracketed identifiers such as [MyTable] instead of quoted identifiers such as \"MyTable\".", "", true, "false", "" ], [ "QueryTimeout", "Specifies the number of seconds before the queries time out.", "", false, "false", "600" ], [ "File", "Specifies the path to one or several files to be used as the query input.", "InputFile", true, "false", "" ], [ "SqlObject", "Specify on or multiple SQL objects. Those will be converted to script and their scripts run on the target system(s).", "", true, "false", "" ], [ "As", "Specifies output type. Valid options for this parameter are \u0027DataSet\u0027, \u0027DataTable\u0027, \u0027DataRow\u0027, \u0027PSObject\u0027, and \u0027SingleValue\u0027\nPSObject output introduces overhead but adds flexibility for working with results: http://powershell.org/wp/forums/topic/dealing-with-dbnull/", "", false, "false", "DataRow" ], [ "SqlParameters", "Specifies a hashtable of parameters for parameterized SQL queries. http://blog.codinghorror.com/give-me-parameterized-sql-or-give-me-death/", "", false, "false", "" ], [ "AppendServerInstance", "If this switch is enabled, the SQL Server instance will be appended to PSObject and DataRow output.", "", false, "false", "False" ], [ "MessagesToOutput", "Use this switch to have on the output stream messages too (e.g. PRINT statements). Output will hold the resultset too. See examples for detail", "", false, "false", "False" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase)", "", 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": "Invoke-DbaCmd,Invoke-DbaSqlQuery", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "A command to run explicit T-SQL commands or files.", "Name": "Invoke-DbaQuery", "Links": "https://dbatools.io/Invoke-DbaQuery", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaQuery -SqlInstance server\\instance -Query \u0027SELECT foo FROM bar\u0027\nRuns the sql query \u0027SELECT foo FROM bar\u0027 against the instance \u0027server\\instance\u0027\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance [SERVERNAME] -Group [GROUPNAME] | Invoke-DbaQuery -Query \u0027SELECT foo FROM bar\u0027\nRuns the sql query \u0027SELECT foo FROM bar\u0027 against all instances in the group [GROUPNAME] on the CMS [SERVERNAME]\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e\"server1\", \"server1\\nordwind\", \"server2\" | Invoke-DbaQuery -File \"C:\\scripts\\sql\\rebuild.sql\"\nRuns the sql commands stored in rebuild.sql against the instances \"server1\", \"server1\\nordwind\" and \"server2\"\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance \"server1\", \"server1\\nordwind\", \"server2\" | Invoke-DbaQuery -File \"C:\\scripts\\sql\\rebuild.sql\"\nRuns the sql commands stored in rebuild.sql against all accessible databases of the instances \"server1\", \"server1\\nordwind\" and \"server2\"", "Syntax": "Invoke-DbaQuery [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cString\u003e] [-Query] \u003cString\u003e [-QueryTimeout \u003cInt32\u003e] [-As \u003cString\u003e] [-SqlParameters \u003cIDictionary\u003e] [-AppendServerInstance] [-MessagesToOutput] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nInvoke-DbaQuery [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cString\u003e] [-QueryTimeout \u003cInt32\u003e] -File \u003cObject[]\u003e [-As \u003cString\u003e] [-SqlParameters \u003cIDictionary\u003e] [-AppendServerInstance] [-MessagesToOutput] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\nInvoke-DbaQuery [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cString\u003e] [-QueryTimeout \u003cInt32\u003e] -SqlObject \u003cSqlSmoObject[]\u003e [-As \u003cString\u003e] [-SqlParameters \u003cIDictionary\u003e] [-AppendServerInstance] [-MessagesToOutput] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbatoolsFormatter", "Description": "Uses PSSA\u0027s Invoke-Formatter to format the target files and saves it without the BOM.", "Tags": "Formatting", "Params": [ [ "Path", "The path to the ps1 file that needs to be formatted", "", 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.", "", false, "false", "False" ] ], "Alias": "", "Author": "Simone Bizzotto", "Synopsis": "Helps formatting function files to dbatools\u0027 standards", "Name": "Invoke-DbatoolsFormatter", "Links": "https://dbatools.io/Invoke-DbatoolsFormatter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbatoolsFormatter -Path C:\\dbatools\\functions\\Get-DbaDatabase.ps1\nReformats C:\\dbatools\\functions\\Get-DbaDatabase.ps1 to dbatools\u0027 standards", "Syntax": "Invoke-DbatoolsFormatter [-Path] \u003cObject[]\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbatoolsRenameHelper", "Description": "Older dbatools command names have been changed. This script helps keep up.", "Tags": "Module", "Params": [ [ "InputObject", "A piped in object from Get-ChildItem", "", true, "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" ], [ "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" ], [ "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": "Older dbatools command names have been changed. This script helps keep up.", "Name": "Invoke-DbatoolsRenameHelper", "Links": "https://dbatools.io/Invoke-DbatoolsRenameHelper", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-ChildItem C:\\temp\\ps\\*.ps1 -Recurse | Invoke-DbatoolsRenameHelper\nChecks to see if any ps1 file in C:\\temp\\ps matches an old command name.\r\nIf so, then the command name within the text is updated and the resulting changes are written to disk in UTF-8.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-ChildItem C:\\temp\\ps\\*.ps1 -Recurse | Invoke-DbatoolsRenameHelper -Encoding Ascii -WhatIf\nShows what would happen if the command would run. If the command would run and there were matches,\r\nthe resulting changes would be written to disk as Ascii encoded.", "Syntax": "Invoke-DbatoolsRenameHelper [-InputObject] \u003cFileInfo[]\u003e [[-Encoding] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaWhoIsActive", "Description": "Output results of Adam Machanic\u0027s sp_WhoIsActive\n\nThis command was built with Adam\u0027s permission. To read more about sp_WhoIsActive, please visit:\n\nUpdates: http://sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx\n\nAlso, consider donating to Adam if you find this stored procedure helpful: http://tinyurl.com/WhoIsActiveDonate", "Tags": [ "AdamMechanic", "WhoIsActive", "SpWhoIsActive" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 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", "" ], [ "Database", "The database where sp_WhoIsActive is installed. Defaults to master. If the sp_WhoIsActive is not installed, the command will warn and exit.", "", false, "false", "" ], [ "Filter", "FiltersBoth inclusive and exclusive\r\nSet either filter to \u0027\u0027 to disable\r\nSession is a session ID, and either 0 or \u0027\u0027 can be used to indicate \"all\" sessions\r\nAll other filter types support % or _ as wildcards", "As", false, "false", "" ], [ "FilterType", "Valid filter types are: session, program, database, login, and host", "", false, "false", "Session" ], [ "NotFilter", "FiltersBoth inclusive and exclusive\r\nSet either filter to \u0027\u0027 to disable\r\nSession is a session ID, and either 0 or \u0027\u0027 can be used to indicate \"all\" sessions\r\nAll other filter types support % or _ as wildcards", "", false, "false", "" ], [ "NotFilterType", "Valid filter types are: session, program, database, login, and host", "", false, "false", "Session" ], [ "ShowOwnSpid", "Retrieve data about the calling session?", "", false, "false", "False" ], [ "ShowSystemSpids", "Retrieve data about system sessions?", "", false, "false", "False" ], [ "ShowSleepingSpids", "Controls how sleeping SPIDs are handled, based on the idea of levels of interest\r\n0 does not pull any sleeping SPIDs\r\n1 pulls only those sleeping SPIDs that also have an open transaction\r\n2 pulls all sleeping SPIDs", "", false, "false", "0" ], [ "GetFullInnerText", "If 1, gets the full stored procedure or running batch, when available\r\nIf 0, gets only the actual statement that is currently running in the batch or procedure", "", false, "false", "False" ], [ "GetPlans", "Get associated query plans for running tasks, if available\r\nIf 1, gets the plan based on the request\u0027s statement offset\r\nIf 2, gets the entire plan based on the request\u0027s plan_handle", "", false, "false", "0" ], [ "GetOuterCommand", "Get the associated outer ad hoc query or stored procedure call, if available", "", false, "false", "False" ], [ "GetTransactionInfo", "Enables pulling transaction log write info and transaction duration", "", false, "false", "False" ], [ "GetTaskInfo", "Get information on active tasks, based on three interest levels\r\nLevel 0 does not pull any task-related information\r\nLevel 1 is a lightweight mode that pulls the top non-CXPACKET wait, giving preference to blockers\r\nLevel 2 pulls all available task-based metrics, including:\r\nnumber of active tasks, current wait stats, physical I/O, context switches, and blocker information", "", false, "false", "0" ], [ "GetLocks", "Gets associated locks for each request, aggregated in an XML format", "", false, "false", "False" ], [ "GetAverageTime", "Get average time for past runs of an active query\r\n(based on the combination of plan handle, sql handle, and offset)", "", false, "false", "False" ], [ "GetAdditonalInfo", "Get additional non-performance-related information about the session or request\r\ntext_size, language, date_format, date_first, quoted_identifier, arithabort, ansi_null_dflt_on,\r\nansi_defaults, ansi_warnings, ansi_padding, ansi_nulls, concat_null_yields_null,\r\ntransaction_isolation_level, lock_timeout, deadlock_priority, row_count, command_type\nIf a SQL Agent job is running, an subnode called agent_info will be populated with some or all of\r\nthe following: job_id, job_name, step_id, step_name, msdb_query_error (in the event of an error)\nIf @get_task_info is set to 2 and a lock wait is detected, a subnode called block_info will be\r\npopulated with some or all of the following: lock_type, database_name, object_id, file_id, hobt_id,\r\napplock_hash, metadata_resource, metadata_class_id, object_name, schema_name", "", false, "false", "False" ], [ "FindBlockLeaders", "Walk the blocking chain and count the number of\r\ntotal SPIDs blocked all the way down by a given session\r\nAlso enables task_info Level 1, if @get_task_info is set to 0", "", false, "false", "False" ], [ "DeltaInterval", "Pull deltas on various metrics\r\nInterval in seconds to wait before doing the second data pull", "", false, "false", "0" ], [ "OutputColumnList", "List of desired output columns, in desired order\r\nNote that the final output will be the intersection of all enabled features and all\r\ncolumns in the list. Therefore, only columns associated with enabled features will\r\nactually appear in the output. Likewise, removing columns from this list may effectively\r\ndisable features, even if they are turned on\nEach element in this list must be one of the valid output column names. Names must be\r\ndelimited by square brackets. White space, formatting, and additional characters are\r\nallowed, as long as the list contains exact matches of delimited valid column names.", "", false, "false", "[dd%][session_id][sql_text][sql_command][login_name][wait_info][tasks][tran_log%][cpu%][temp%][block%][reads%][writes%][context%][physical%][query_plan][locks][%]" ], [ "SortOrder", "Column(s) by which to sort output, optionally with sort directions.\r\nValid column choices:\r\nsession_id, physical_io, reads, physical_reads, writes, tempdb_allocations,\r\ntempdb_current, CPU, context_switches, used_memory, physical_io_delta,\r\nreads_delta, physical_reads_delta, writes_delta, tempdb_allocations_delta,\r\ntempdb_current_delta, CPU_delta, context_switches_delta, used_memory_delta,\r\ntasks, tran_start_time, open_tran_count, blocking_session_id, blocked_session_count,\r\npercent_complete, host_name, login_name, database_name, start_time, login_time\nNote that column names in the list must be bracket-delimited. Commas and/or white\r\nspace are not required.", "", false, "false", "[start_time] ASC" ], [ "FormatOutput", "Formats some of the output columns in a more \"human readable\" form\r\n0 disables output format\r\n1 formats the output for variable-width fonts\r\n2 formats the output for fixed-width fonts", "", false, "false", "1" ], [ "DestinationTable", "If set to a non-blank value, the script will attempt to insert into the specified destination table. Please note that the script will not verify that the table exists, or that it has the correct \r\nschema, before doing the insert. Table can be specified in one, two, or three-part format", "", false, "false", "" ], [ "ReturnSchema", "If set to 1, no data collection will happen and no result set will be returned; instead,\r\na CREATE TABLE statement will be returned via the @schema parameter, which will match\r\nthe schema of the result set that would be returned by using the same collection of the\r\nrest of the parameters. The CREATE TABLE statement will have a placeholder token of\r\n\u003ctable_name\u003e in place of an actual table name.", "", false, "false", "False" ], [ "Schema", "If set to 1, no data collection will happen and no result set will be returned; instead,\r\na CREATE TABLE statement will be returned via the @schema parameter, which will match\r\nthe schema of the result set that would be returned by using the same collection of the\r\nrest of the parameters. The CREATE TABLE statement will have a placeholder token of\r\n\u003ctable_name\u003e in place of an actual table name.", "", false, "false", "" ], [ "Help", "Help! What do I do?", "", 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": "Show-SqlWhoIsActive", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Outputs results of Adam Machanic\u0027s sp_WhoIsActive DataTable", "Name": "Invoke-DbaWhoIsActive", "Links": "https://dbatools.io/Invoke-DbaWhoIsActive", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a\nExecute sp_whoisactive on sqlserver2014a. This command expects sp_WhoIsActive to be in the master database. Logs into the SQL Server with Windows credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a -SqlCredential $credential -Database dbatools\nExecute sp_whoisactive on sqlserver2014a. This command expects sp_WhoIsActive to be in the dbatools database. Logs into the SQL Server with SQL Authentication.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a -GetAverageTime\nSimilar to running sp_WhoIsActive @get_avg_time\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a -GetOuterCommand -FindBlockLeaders\nSimilar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders = 1", "Syntax": "Invoke-DbaWhoIsActive [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject\u003e] [[-Filter] \u003cString\u003e] [[-FilterType] \u003cString\u003e] [[-NotFilter] \u003cString\u003e] [[-NotFilterType] \u003cString\u003e] [-ShowOwnSpid] [-ShowSystemSpids] [[-ShowSleepingSpids] \u003cInt32\u003e] [-GetFullInnerText] [[-GetPlans] \u003cInt32\u003e] [-GetOuterCommand] [-GetTransactionInfo] [[-GetTaskInfo] \u003cInt32\u003e] [-GetLocks] [-GetAverageTime] [-GetAdditonalInfo] [-FindBlockLeaders] [[-DeltaInterval] \u003cInt32\u003e] [[-OutputColumnList] \u003cString\u003e] [[-SortOrder] \u003cString\u003e] [[-FormatOutput] \u003cInt32\u003e] [[-DestinationTable] \u003cString\u003e] \r\n[-ReturnSchema] [[-Schema] \u003cString\u003e] [-Help] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-DbaXeReplay", "Description": "This command replays events from Read-DbaXEFile. It is simplistic in its approach.\n\n- Writes all queries to a temp sql file\n- Executes temp file using . $sqlcmd so that batches are executed properly\n- Deletes temp file", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "SqlInstance", "Target SQL Server(s)", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Used to provide alternative credentials.", "Credential", false, "false", "" ], [ "Database", "The initial starting database.", "", false, "false", "" ], [ "Event", "Each Response can be limited to processing specific events, while ignoring all the other ones. When this attribute is omitted, all events are processed.", "", false, "false", "@(\u0027sql_batch_completed\u0027, \u0027rcp_completed\u0027)" ], [ "InputObject", "Accepts the object output of Read-DbaXESession.", "", true, "true (ByValue)", "" ], [ "Raw", "By dafault, the results of . $sqlcmd are collected, cleaned up and displayed. If you\u0027d like to see all results immeidately, use Raw.", "", 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": "This command replays events from Read-DbaXEFile on one or more target servers", "Name": "Invoke-DbaXeReplay", "Links": "https://dbatools.io/Invoke-DbaXEReplay", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\sample.xel | Invoke-DbaXeReplay -SqlInstance sql2017\nRuns all batch_text for sql_batch_completed against tempdb on sql2017.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\sample.xel | Invoke-DbaXeReplay -SqlInstance sql2017 -Database planning -Event sql_batch_completed\nSets the *initial* database to planning then runs only sql_batch_completed against sql2017.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\sample.xel | Invoke-DbaXeReplay -SqlInstance sql2017, sql2016\nRuns all batch_text for sql_batch_completed against tempdb on sql2017 and sql2016.", "Syntax": "Invoke-DbaXeReplay [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-Event] \u003cString[]\u003e] [-InputObject] \u003cObject\u003e [-Raw] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Invoke-Sqlcmd2", "Description": "Runs a T-SQL script. Invoke-Sqlcmd2 runs the whole script and only captures the first selected result set, such as the output of PRINT statements when -verbose parameter is specified.\nParameterized queries are supported.\n\nHelp details below borrowed from Invoke-Sqlcmd", "Params": [ [ "ServerInstance", "Specifies the SQL Server instance(s) to execute the query against.", "Instance,Instances,ComputerName,Server,Servers,SqlInstance", true, "true (ByValue, ByPropertyName)", "" ], [ "Database", "Specifies the name of the database to execute the query against. If specified, this database will be used in the ConnectionString when establishing the connection to SQL Server.\nIf a SQLConnection is provided, the default database for that connection is overridden with this database.", "", false, "true (ByPropertyName)", "" ], [ "Query", "Specifies one or more queries to be run. The queries can be Transact-SQL, XQuery statements, or sqlcmd commands. Multiple queries in a single batch may be separated by a semicolon.\nDo not specify the sqlcmd GO separator (or, use the ParseGo parameter). Escape any double quotation marks included in the string.\nConsider using bracketed identifiers such as [MyTable] instead of quoted identifiers such as \"MyTable\".", "", true, "true (ByPropertyName)", "" ], [ "InputFile", "Specifies the full path to a file to be used as the query input to Invoke-Sqlcmd2. The file can contain Transact-SQL statements, XQuery statements, sqlcmd commands and scripting variables.", "", true, "true (ByPropertyName)", "" ], [ "Credential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)\nSECURITY NOTE: If you use the -Debug switch, the connectionstring including plain text password will be sent to the debug stream.", "SqlCredential", false, "true (ByPropertyName)", "" ], [ "Encrypt", "If this switch is enabled, the connection to SQL Server will be made using SSL.\nThis requires that the SQL Server has been set up to accept SSL requests. For information regarding setting up SSL on SQL Server, see \r\nhttps://technet.microsoft.com/en-us/library/ms189067(v=sql.105).aspx", "", false, "false", "False" ], [ "QueryTimeout", "Specifies the number of seconds before the queries time out.", "", false, "true (ByPropertyName)", "600" ], [ "ConnectionTimeout", "Specifies the number of seconds before Invoke-Sqlcmd2 times out if it cannot successfully connect to an instance of the Database Engine. The timeout value must be an integer between 0 and 65534. If 0 \r\nis specified, connection attempts do not time out.", "", false, "true (ByPropertyName)", "15" ], [ "As", "Specifies output type. Valid options for this parameter are \u0027DataSet\u0027, \u0027DataTable\u0027, \u0027DataRow\u0027, \u0027PSObject\u0027, and \u0027SingleValue\u0027\nPSObject output introduces overhead but adds flexibility for working with results: http://powershell.org/wp/forums/topic/dealing-with-dbnull/", "", false, "true (ByPropertyName)", "DataRow" ], [ "SqlParameters", "Specifies a hashtable of parameters for parameterized SQL queries. http://blog.codinghorror.com/give-me-parameterized-sql-or-give-me-death/\nExample:", "", false, "true (ByPropertyName)", "" ], [ "AppendServerInstance", "If this switch is enabled, the SQL Server instance will be appended to PSObject and DataRow output.", "", false, "false", "False" ], [ "ParseGO", "If this switch is enabled, \"GO\" statements will be handled automatically.\r\nEvery \"GO\" will effectively run in a separate query, like if you issued multiple Invoke-SqlCmd2 commands.\r\n\"GO\"s will be recognized if they are on a single line, as this covers\r\nthe 95% of the cases \"GO\" parsing is needed\r\nNote:\r\nQueries will always target that database, e.g. if you have this Query:\r\nUSE DATABASE [dbname]\r\nGO\r\nSELECT * from sys.tables\r\nand you call it via\r\nInvoke-SqlCmd2 -ServerInstance instance -Database msdb -Query ...\r\nyou\u0027ll get back tables from msdb, not dbname.", "", false, "false", "False" ], [ "SQLConnection", "Specifies an existing SQLConnection object to use in connecting to SQL Server. If the connection is closed, an attempt will be made to open it.", "Connection,Conn", false, "false", "" ] ], "Alias": "", "Synopsis": "Runs a T-SQL script.", "Name": "Invoke-Sqlcmd2", "Links": [ "https://github.com/sqlcollaborative/Invoke-SqlCmd2", "https://github.com/RamblingCookieMonster/PowerShell" ], "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance \"MyComputer\\MyInstance\" -Query \"SELECT login_time AS \u0027StartTime\u0027 FROM sysprocesses WHERE spid = 1\"\nConnects to a named instance of the Database Engine on a computer and runs a basic T-SQL query.\nStartTime\r\n-----------\r\n2010-08-12 21:21:03.593\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance \"MyComputer\\MyInstance\" -InputFile \"C:\\MyFolder\\tsqlscript.sql\" | Out-File -filePath \"C:\\MyFolder\\tsqlscript.rpt\"\nReads a file containing T-SQL statements, runs the file, and writes the output to another file.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance \"MyComputer\\MyInstance\" -Query \"PRINT \u0027hello world\u0027\" -Verbose\nUses the PowerShell -Verbose parameter to return the message output of the PRINT command.\r\nVERBOSE: hello world\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance MyServer\\MyInstance -Query \"SELECT ServerName, VCNumCPU FROM tblServerInfo\" -as PSObject | ?{$_.VCNumCPU -gt 8}\nInvoke-Sqlcmd2 -ServerInstance MyServer\\MyInstance -Query \"SELECT ServerName, VCNumCPU FROM tblServerInfo\" -as PSObject | ?{$_.VCNumCPU}\nThis example uses the PSObject output type to allow more flexibility when working with results.\nIf we used DataRow rather than PSObject, we would see the following behavior:\r\nEach row where VCNumCPU does not exist would produce an error in the first example\r\nResults would include rows where VCNumCPU has DBNull value in the second example\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e\u0027Instance1\u0027, \u0027Server1/Instance1\u0027, \u0027Server2\u0027 | Invoke-Sqlcmd2 -query \"Sp_databases\" -as psobject -AppendServerInstance\nThis example lists databases for each instance. It includes a column for the ServerInstance in question.\r\nDATABASE_NAME DATABASE_SIZE REMARKS ServerInstance\r\n------------- ------------- ------- --------------\r\nREDACTED 88320 Instance1\r\nmaster 17920 Instance1\r\n...\r\nmsdb 618112 Server1/Instance1\r\ntempdb 563200 Server1/Instance1\r\n...\r\nOperationsManager 20480000 Server2\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e#Construct a query using SQL parameters\n$Query = \"SELECT ServerName, VCServerClass, VCServerContact FROM tblServerInfo WHERE VCServerContact LIKE @VCServerContact AND VCServerClass LIKE @VCServerClass\"\n#Run the query, specifying values for SQL parameters\r\nInvoke-Sqlcmd2 -ServerInstance SomeServer\\NamedInstance -Database ServerDB -query $query -SqlParameters @{ VCServerContact=\"%cookiemonster%\"; VCServerClass=\"Prod\" }\nServerName VCServerClass VCServerContact\r\n---------- ------------- ---------------\r\nSomeServer1 Prod cookiemonster, blah\r\nSomeServer2 Prod cookiemonster\r\nSomeServer3 Prod blah, cookiemonster\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eInvoke-Sqlcmd2 -SQLConnection $Conn -Query \"SELECT login_time AS \u0027StartTime\u0027 FROM sysprocesses WHERE spid = 1\"\nUses an existing SQLConnection and runs a basic T-SQL query against it\nStartTime\r\n-----------\r\n2010-08-12 21:21:03.593\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eInvoke-SqlCmd -SQLConnection $Conn -Query \"SELECT ServerName FROM tblServerInfo WHERE ServerName LIKE @ServerName\" -SqlParameters @{\"ServerName = \"c-is-hyperv-1\"}\nExecutes a parameterized query against the existing SQLConnection, with a collection of one parameter to be passed to the query when executed.", "Syntax": "Invoke-Sqlcmd2 [-ServerInstance] \u003cString[]\u003e [[-Database] \u003cString\u003e] [-Query] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] [[-Encrypt]] [[-QueryTimeout] \u003cInt32\u003e] [[-ConnectionTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \u003cIDictionary\u003e] [[-AppendServerInstance]] [[-ParseGO]] [\u003cCommonParameters\u003e]\nInvoke-Sqlcmd2 [-ServerInstance] \u003cString[]\u003e [[-Database] \u003cString\u003e] [-InputFile] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] [[-Encrypt]] [[-QueryTimeout] \u003cInt32\u003e] [[-ConnectionTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \u003cIDictionary\u003e] [[-AppendServerInstance]] [[-ParseGO]] [\u003cCommonParameters\u003e]\nInvoke-Sqlcmd2 [[-Database] \u003cString\u003e] [-Query] \u003cString\u003e [[-QueryTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \u003cIDictionary\u003e] [[-AppendServerInstance]] [[-ParseGO]] [[-SQLConnection] \u003cSqlConnection\u003e] [\u003cCommonParameters\u003e]\nInvoke-Sqlcmd2 [[-Database] \u003cString\u003e] [-InputFile] \u003cString\u003e [[-QueryTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \u003cIDictionary\u003e] [[-AppendServerInstance]] [[-ParseGO]] [[-SQLConnection] \u003cSqlConnection\u003e] [\u003cCommonParameters\u003e]" }, { "CommandName": "Join-DbaAvailabilityGroup", "Description": "Joins a secondary replica to an availability group on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The availability group to join.", "", false, "false", "" ], [ "ClusterType", "Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.\r\nOptions include: External, Wsfc or None.", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaAvailabilityGroup.", "", 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" ], [ "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": "Joins a secondary replica to an availability group on a SQL Server instance.", "Name": "Join-DbaAvailabilityGroup", "Links": "https://dbatools.io/Join-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql01 -AvailabilityGroup SharePoint | Join-DbaAvailabilityGroup -SqlInstance sql02\nJoins sql02 to the SharePoint availability group on sql01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$ag = Get-DbaAvailabilityGroup -SqlInstance sql01 -AvailabilityGroup SharePoint\nPS C:\\\u003e Join-DbaAvailabilityGroup -SqlInstance sql02 -InputObject $ag\nJoins sql02 to the SharePoint availability group on sql01\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql01 -AvailabilityGroup SharePoint | Join-DbaAvailabilityGroup -SqlInstance sql02 -WhatIf\nShows what would happen if the command were to run. No actions are actually performed.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql01 -AvailabilityGroup SharePoint | Join-DbaAvailabilityGroup -SqlInstance sql02 -Confirm\nPrompts for confirmation then joins sql02 to the SharePoint availability group on sql01.", "Syntax": "Join-DbaAvailabilityGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-ClusterType] \u003cString\u003e] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Measure-DbaBackupThroughput", "Description": "Returns backup history details for one or more databases on a SQL Server.\n\nOutput looks like this:\nSqlInstance : sql2016\nDatabase : SharePoint_Config\nAvgThroughputMB : 1.07\nAvgSizeMB : 24.17\nAvgDuration : 00:00:01.1000000\nMinThroughputMB : 0.02\nMaxThroughputMB : 2.26\nMinBackupDate : 8/6/2015 10:22:01 PM\nMaxBackupDate : 6/19/2016 12:57:45 PM\nBackupCount : 10", "Tags": [ "Backup", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,Instance,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", "" ], [ "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", "" ], [ "ExcludeDatabase", "The database(s) to exclude. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Since", "All backups taken on or after the point in time represented by this datetime object will be processed.", "", false, "false", "" ], [ "Last", "If this switch is enabled, only the last backup will be measured.", "", false, "false", "False" ], [ "Type", "By default, this command measures the speed of Full backups. Valid options are \"Full\", \"Log\" and \"Differential\".", "", false, "false", "Full" ], [ "DeviceType", "Specifies one or more DeviceTypes to use in filtering backup sets. Valid values are \"Disk\", \"Permanent Disk Device\", \"Tape\", \"Permanent Tape Device\", \"Pipe\", \"Permanent Pipe Device\" and \"Virtual \r\nDevice\", as well as custom integers for your own DeviceTypes.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Determines how quickly SQL Server is backing up databases to media.", "Name": "Measure-DbaBackupThroughput", "Links": "https://dbatools.io/Measure-DbaBackupThroughput", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016\nParses every backup in msdb\u0027s backuphistory for stats on all databases.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016 -Database AdventureWorks2014\nParses every backup in msdb\u0027s backuphistory for stats on AdventureWorks2014.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2005 -Last\nProcesses the last full, diff and log backups every backup for all databases on sql2005.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2005 -Last -Type Log\nProcesses the last log backups every backup for all databases on sql2005.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016 -Since (Get-Date).AddDays(-7)\nGets backup calculations for the last week.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016 -Since (Get-Date).AddDays(-365) -Database bigoldb\nGets backup calculations, limited to the last year and only the bigoldb database", "Syntax": "Measure-DbaBackupThroughput [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-Since \u003cDateTime\u003e] [-Last] [-Type \u003cString\u003e] [-DeviceType \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Measure-DbaDiskSpaceRequirement", "Description": "Returns a file list from source and destination where source file may overwrite destination. Complex scenarios where a new file may exist is taken into account.\nThis command will accept a hash object in pipeline with the following keys: Source, SourceDatabase, Destination. Using this command will provide a way to prepare before a complex migration with multiple databases from different sources and destinations.", "Tags": [ "Database", "DiskSpace", "Migration" ], "Params": [ [ "Source", "Source SQL Server.", "", true, "true (ByPropertyName)", "" ], [ "Database", "The database to copy. It MUST exist.", "", true, "true (ByPropertyName)", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "true (ByPropertyName)", "" ], [ "Destination", "Destination SQL Server instance.", "", true, "true (ByPropertyName)", "" ], [ "DestinationDatabase", "The database name at destination.\r\nMay or may not be present, if unspecified it will default to the database name provided in SourceDatabase.", "", false, "true (ByPropertyName)", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "true (ByPropertyName)", "" ], [ "Credential", "The credentials to use to connect via CIM/WMI/PowerShell remoting.", "", false, "true (ByPropertyName)", "" ], [ "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": "Pollus Brodeur (@pollusb)", "Synopsis": "Calculate the space needed to copy and possibly replace a database from one SQL server to another.", "Name": "Measure-DbaDiskSpaceRequirement", "Links": "https://dbatools.io/Measure-DbaDiskSpaceRequirement", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eMeasure-DbaDiskSpaceRequirement -Source INSTANCE1 -Database DB1 -Destination INSTANCE2\nCalculate space needed for a simple migration with one database with the same name at destination.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e@(\n\u003e\u003e [PSCustomObject]@{Source=\u0027SQL1\u0027;Destination=\u0027SQL2\u0027;Database=\u0027DB1\u0027},\r\n\u003e\u003e [PSCustomObject]@{Source=\u0027SQL1\u0027;Destination=\u0027SQL2\u0027;Database=\u0027DB2\u0027}\r\n\u003e\u003e ) | Measure-DbaDiskSpaceRequirement\nUsing a PSCustomObject with 2 databases to migrate on SQL2.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eImport-Csv -Path .\\migration.csv -Delimiter \"`t\" | Measure-DbaDiskSpaceRequirement | Format-Table -AutoSize\nUsing a CSV file. You will need to use this header line \"Source\u003ctab\u003eDestination\u003ctab\u003eDatabase\u003ctab\u003eDestinationDatabase\".\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$qry = \"SELECT Source, Destination, Database FROM dbo.Migrations\"\nPS C:\\\u003e Invoke-DbaCmd -SqlInstance DBA -Database Migrations -Query $qry | Measure-DbaDiskSpaceRequirement\nUsing a SQL table. We are DBA after all!", "Syntax": "Measure-DbaDiskSpaceRequirement [-Source] \u003cDbaInstanceParameter\u003e [-Database] \u003cString\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter\u003e [[-DestinationDatabase] \u003cString\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Measure-DbatoolsImport", "Description": "Displays the import load times of the dbatools PowerShell module", "Tags": "Debug", "Params": [ ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Displays the import load times of the dbatools PowerShell module", "Name": "Measure-DbatoolsImport", "Links": "https://dbatools.io/Measure-DbatoolsImport", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eMeasure-DbatoolsImport\nDisplays the import load times of the dbatools PowerShell module\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eImport-Module dbatools\nPS C:\\\u003e Measure-DbatoolsImport\nDisplays the import load times of the dbatools PowerShell module", "Syntax": "Measure-DbatoolsImport [\u003cCommonParameters\u003e]" }, { "CommandName": "Mount-DbaDatabase", "Description": "This command will attach a SQL Server database.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Database", "The database(s) to attach.", "", true, "false", "" ], [ "FileStructure", "A StringCollection object value that contains a list database files. If FileStructure is not specified, BackupHistory will be used to guess the structure.", "", false, "false", "" ], [ "DatabaseOwner", "Sets the database owner for the database. The sa account (or equivalent) will be used if DatabaseOwner is not specified.", "", false, "false", "" ], [ "AttachOption", "An AttachOptions object value that contains the attachment options. Valid options are \"None\", \"RebuildLog\", \"EnableBroker\", \"NewBroker\" and \"ErrorBrokerConversations\".", "", false, "false", "None" ], [ "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", "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": "Attach-DbaDatabase", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Attach a SQL Server Database - aliased to Attach-DbaDatabase", "Name": "Mount-DbaDatabase", "Links": "https://dbatools.io/Mount-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$fileStructure = New-Object System.Collections.Specialized.StringCollection\nPS C:\\\u003e $fileStructure.Add(\"E:\\archive\\example.mdf\")\r\nPS C:\\\u003e $filestructure.Add(\"E:\\archive\\example.ldf\")\r\nPS C:\\\u003e $filestructure.Add(\"E:\\archive\\example.ndf\")\r\nPS C:\\\u003e Mount-DbaDatabase -SqlInstance sql2016 -Database example -FileStructure $fileStructure\nAttaches a database named \"example\" to sql2016 with the files \"E:\\archive\\example.mdf\", \"E:\\archive\\example.ldf\" and \"E:\\archive\\example.ndf\". The database owner will be set to sa and the attach \r\noption is None.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eMount-DbaDatabase -SqlInstance sql2016 -Database example\nSince the FileStructure was not provided, this command will attempt to determine it based on backup history. If found, a database named example will be attached to sql2016.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eMount-DbaDatabase -SqlInstance sql2016 -Database example -WhatIf\nShows what would happen if the command were executed (without actually performing the command)", "Syntax": "Mount-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \u003cString[]\u003e [[-FileStructure] \u003cStringCollection\u003e] [[-DatabaseOwner] \u003cString\u003e] [[-AttachOption] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Move-DbaCmsRegServer", "Description": "Moves registered servers around SQL Server Central Management Server (CMS)", "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", "" ], [ "Name", "Specifies one or more reg servers to move. Name is the visible name in SSMS CMS interface (labeled Registered Server Name)", "", false, "false", "" ], [ "ServerName", "Specifies one or more reg servers to move. Server Name is the actual instance name (labeled Server Name)", "", false, "false", "" ], [ "NewGroup", "The new group. If no new group is specified, the default root will used", "", false, "false", "" ], [ "InputObject", "Allows results from Get-DbaCmsRegServer to be piped in", "", false, "true (ByValue)", "" ], [ "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" ], [ "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": "Move-DbaRegisteredServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Moves registered servers around SQL Server Central Management Server (CMS)", "Name": "Move-DbaCmsRegServer", "Links": "https://dbatools.io/Move-DbaCmsRegServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eMove-DbaCmsRegServer -SqlInstance sql2012 -Name \u0027Web SQL Cluster\u0027 -NewGroup HR\\Prod\nMoves the registered server on sql2012 titled \u0027Web SQL Cluster\u0027 to the Prod group within the HR group\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2017 -Name \u0027Web SQL Cluster\u0027 | Move-DbaCmsRegServer -NewGroup Web\nMoves the registered server \u0027Web SQL Cluster\u0027 on sql2017 to the Web group, also on sql2017", "Syntax": "Move-DbaCmsRegServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-NewGroup] \u003cString\u003e] [[-InputObject] \u003cRegisteredServer[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Move-DbaCmsRegServerGroup", "Description": "Moves registered server groups around SQL Server Central Management Server (CMS).", "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", "" ], [ "Group", "Specifies one or more groups to include from SQL Server Central Management Server.", "", false, "false", "" ], [ "NewGroup", "The new location.", "", true, "false", "" ], [ "InputObject", "Allows results from Get-DbaCmsRegServerGroup to be piped in", "", false, "true (ByValue)", "" ], [ "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" ], [ "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": "Move-DbaRegisteredServerGroup", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Moves registered server groups around SQL Server Central Management Server (CMS).", "Name": "Move-DbaCmsRegServerGroup", "Links": "https://dbatools.io/Move-DbaCmsRegServerGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eMove-DbaCmsRegServerGroup -SqlInstance sql2012 -Group HR\\Development -NewGroup AD\\Prod\nMoves the Development group within HR to the Prod group within AD\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServerGroup -SqlInstance sql2017 -Group HR\\Development| Move-DbaCmsRegServer -NewGroup Web\nMoves the Development group within HR to the Web group", "Syntax": "Move-DbaCmsRegServerGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Group] \u003cString[]\u003e] [-NewGroup] \u003cString\u003e [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaAgentJob", "Description": "New-DbaAgentJob makes is possible to create a job in the SQL Server Agent.\nIt returns an array of the job(s) created", "Tags": [ "Agent", "Job", "JobStep" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Job", "The name of the job. The name must be unique and cannot contain the percent (%) character.", "", true, "false", "" ], [ "Schedule", "Schedule to attach to job. This can be more than one schedule.", "", false, "false", "" ], [ "ScheduleId", "Schedule ID to attach to job. This can be more than one schedule ID.", "", false, "false", "" ], [ "Disabled", "Sets the status of the job to disabled. By default a job is enabled.", "", false, "false", "False" ], [ "Description", "The description of the job.", "", false, "false", "" ], [ "StartStepId", "The identification number of the first step to execute for the job.", "", false, "false", "0" ], [ "Category", "The category of the job.", "", false, "false", "" ], [ "OwnerLogin", "The name of the login that owns the job.", "", false, "false", "" ], [ "EventLogLevel", "Specifies when to place an entry in the Microsoft Windows application log for this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value can either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "EmailLevel", "Specifies when to send an e-mail upon the completion of this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value can either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "PageLevel", "Specifies when to send a page upon the completion of this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value can either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "EmailOperator", "The e-mail name of the operator to whom the e-mail is sent when EmailLevel is reached.", "", false, "false", "" ], [ "NetsendOperator", "The name of the operator to whom the network message is sent.", "", false, "false", "" ], [ "PageOperator", "The name of the operator to whom a page is sent.", "", false, "false", "" ], [ "DeleteLevel", "Specifies when to delete the job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value can either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "New-DbaAgentJob creates a new job", "Name": "New-DbaAgentJob", "Links": "https://dbatools.io/New-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -Description \u0027Just another job\u0027\nCreates a job with the name \"Job1\" and a small description\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -Disabled\nCreates the job but sets it to disabled\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -EventLogLevel OnSuccess\nCreates the job and sets the notification to write to the Windows Application event log on success\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance SSTAD-PC -Job \u0027Job One\u0027 -EmailLevel OnFailure -EmailOperator dba\nCreates the job and sets the notification to send an e-mail to the e-mail operator\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -Description \u0027Just another job\u0027 -Whatif\nDoesn\u0027t create the job but shows what would happen.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job \u0027Job One\u0027\nCreates a job with the name \"Job One\" on multiple servers\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e\"sql1\", \"sql2\", \"sql3\" | New-DbaAgentJob -Job \u0027Job One\u0027\nCreates a job with the name \"Job One\" on multiple servers using the pipe line", "Syntax": "New-DbaAgentJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cString\u003e [[-Schedule] \u003cObject[]\u003e] [[-ScheduleId] \u003cInt32[]\u003e] [-Disabled] [[-Description] \u003cString\u003e] [[-StartStepId] \u003cInt32\u003e] [[-Category] \u003cString\u003e] [[-OwnerLogin] \u003cString\u003e] [[-EventLogLevel] \u003cObject\u003e] [[-EmailLevel] \u003cObject\u003e] [[-PageLevel] \u003cObject\u003e] [[-EmailOperator] \u003cString\u003e] [[-NetsendOperator] \u003cString\u003e] [[-PageOperator] \u003cString\u003e] [[-DeleteLevel] \u003cObject\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaAgentJobCategory", "Description": "New-DbaAgentJobCategory makes it possible to create a job category that can be used with jobs.\nIt returns an array of the job(s) created .", "Tags": [ "Agent", "Job", "JobCategory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Category", "The name of the category", "", true, "false", "" ], [ "CategoryType", "The type of category. This can be \"LocalJob\", \"MultiServerJob\" or \"None\".\r\nThe default is \"LocalJob\" and will automatically be set when no option is chosen.", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "New-DbaAgentJobCategory creates a new job category.", "Name": "New-DbaAgentJobCategory", "Links": "https://dbatools.io/New-DbaAgentJobCategory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 1\u0027\nCreates a new job category with the name \u0027Category 1\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 2\u0027 -CategoryType MultiServerJob\nCreates a new job category with the name \u0027Category 2\u0027 and assign the category type for a multi server job.", "Syntax": "New-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Category] \u003cString[]\u003e [[-CategoryType] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaAgentJobStep", "Description": "New-DbaAgentJobStep creates a new job in the SQL Server Agent for a specific job", "Tags": [ "Agent", "Job", "JobStep" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Job", "The name of the job to which to add the step.", "", true, "false", "" ], [ "StepId", "The sequence identification number for the job step. Step identification numbers start at 1 and increment without gaps.", "", false, "false", "0" ], [ "StepName", "The name of the step.", "", true, "false", "" ], [ "Subsystem", "The subsystem used by the SQL Server Agent service to execute command.\r\nAllowed values \u0027ActiveScripting\u0027,\u0027AnalysisCommand\u0027,\u0027AnalysisQuery\u0027,\u0027CmdExec\u0027,\u0027Distribution\u0027,\u0027LogReader\u0027,\u0027Merge\u0027,\u0027PowerShell\u0027,\u0027QueueReader\u0027,\u0027Snapshot\u0027,\u0027Ssis\u0027,\u0027TransactSql\u0027\r\nThe default is \u0027TransactSql\u0027", "", false, "false", "TransactSql" ], [ "Command", "The commands to be executed by SQLServerAgent service through subsystem.", "", false, "false", "" ], [ "CmdExecSuccessCode", "The value returned by a CmdExec subsystem command to indicate that command executed successfully.", "", false, "false", "0" ], [ "OnSuccessAction", "The action to perform if the step succeeds.\r\nAllowed values \"QuitWithSuccess\" (default), \"QuitWithFailure\", \"GoToNextStep\", \"GoToStep\".\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "QuitWithSuccess" ], [ "OnSuccessStepId", "The ID of the step in this job to execute if the step succeeds and OnSuccessAction is \"GoToStep\".", "", false, "false", "0" ], [ "OnFailAction", "The action to perform if the step fails.\r\nAllowed values \"QuitWithSuccess\" (default), \"QuitWithFailure\", \"GoToNextStep\", \"GoToStep\".\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "QuitWithFailure" ], [ "OnFailStepId", "The ID of the step in this job to execute if the step fails and OnFailAction is \"GoToStep\".", "", false, "false", "0" ], [ "Database", "The name of the database in which to execute a Transact-SQL step. The default is \u0027master\u0027.", "", false, "false", "" ], [ "DatabaseUser", "The name of the user account to use when executing a Transact-SQL step.", "", false, "false", "" ], [ "RetryAttempts", "The number of retry attempts to use if this step fails. The default is 0.", "", false, "false", "0" ], [ "RetryInterval", "The amount of time in minutes between retry attempts. The default is 0.", "", false, "false", "0" ], [ "OutputFileName", "The name of the file in which the output of this step is saved.", "", false, "false", "" ], [ "Flag", "Sets the flag(s) for the job step.\nFlag Description\r\n----------------------------------------------------------------------------\r\nAppendAllCmdExecOutputToJobHistory Job history, including command output, is appended to the job history file.\r\nAppendToJobHistory Job history is appended to the job history file.\r\nAppendToLogFile Job history is appended to the SQL Server log file.\r\nAppendToTableLog Job history is appended to a log table.\r\nLogToTableWithOverwrite Job history is written to a log table, overwriting previous contents.\r\nNone Job history is not appended to a file.\r\nProvideStopProcessEvent Job processing is stopped.", "", false, "false", "" ], [ "ProxyName", "The name of the proxy that the job step runs as.", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "New-DbaAgentJobStep creates a new job step for a job", "Name": "New-DbaAgentJobStep", "Links": "https://dbatools.io/New-DbaAgentJobStep", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1\nCreate a step in \"Job1\" with the name Step1 with the default subsystem TransactSql.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1 -Database msdb\nCreate a step in \"Job1\" with the name Step1 where the database will the msdb\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1 -StepName Step1 -Database msdb\nCreate a step in \"Job1\" with the name Step1 where the database will the \"msdb\" for multiple servers\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1, Job2, \u0027Job Three\u0027 -StepName Step1 -Database msdb\nCreate a step in \"Job1\" with the name Step1 where the database will the \"msdb\" for multiple servers for multiple jobs\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003esql1, sql2, sql3 | New-DbaAgentJobStep -Job Job1 -StepName Step1 -Database msdb\nCreate a step in \"Job1\" with the name Step1 where the database will the \"msdb\" for multiple servers using pipeline", "Syntax": "New-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e [[-StepId] \u003cInt32\u003e] [-StepName] \u003cString\u003e [[-Subsystem] \u003cString\u003e] [[-Command] \u003cString\u003e] [[-CmdExecSuccessCode] \u003cInt32\u003e] [[-OnSuccessAction] \u003cString\u003e] [[-OnSuccessStepId] \u003cInt32\u003e] [[-OnFailAction] \u003cString\u003e] [[-OnFailStepId] \u003cInt32\u003e] [[-Database] \u003cObject\u003e] [[-DatabaseUser] \u003cString\u003e] [[-RetryAttempts] \u003cInt32\u003e] [[-RetryInterval] \u003cInt32\u003e] [[-OutputFileName] \u003cString\u003e] [[-Flag] \u003cString[]\u003e] [[-ProxyName] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaAgentProxy", "Description": "Adds one or more proxies to SQL Server Agent", "Tags": [ "Agent", "Proxy" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.You must have sysadmin access and server version must be SQL Server version 2000 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", "" ], [ "Name", "The name of the proxy or proxies you want to create", "", true, "false", "" ], [ "ProxyCredential", "The associated SQL Server Credential. The credential must be created prior to creating the Proxy.", "", true, "false", "" ], [ "SubSystem", "The associated subsystem or subsystems. Defaults to CmdExec.\nValid options include:\r\nActiveScripting\r\nAnalysisCommand\r\nAnalysisQuery\r\nCmdExec\r\nDistribution\r\nLogReader\r\nMerge\r\nPowerShell\r\nQueueReader\r\nSnapshot\r\nSsis\r\nTransactSql", "", false, "false", "CmdExec" ], [ "Description", "A description of the proxy", "", false, "false", "" ], [ "Login", "The SQL Server login or logins (known as proxy principals) to assign to the proxy", "", false, "false", "" ], [ "ServerRole", "The SQL Server role or roles (known as proxy principals) to assign to the proxy", "", false, "false", "" ], [ "MsdbRole", "The msdb role or roles (known as proxy principals) to assign to the proxy", "", false, "false", "" ], [ "Disabled", "Create the proxy as disabled", "", false, "false", "False" ], [ "Force", "Drop and recreate the proxy if it already exists", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds one or more proxies to SQL Server Agent", "Name": "New-DbaAgentProxy", "Links": "https://dbatools.io/New-DbaAgentProxy", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAgentProxy -SqlInstance sql2016 -Name STIG -ProxyCredential \u0027PowerShell Proxy\u0027\nCreates an Agent Proxy on sql2016 with the name STIG with the \u0027PowerShell Proxy\u0027 credential.\r\nThe proxy is automatically added to the CmdExec subsystem.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaAgentProxy -SqlInstance localhost\\sql2016 -Name STIG -ProxyCredential \u0027PowerShell Proxy\u0027 -Description \"Used for auditing purposes\" -Login ad\\sqlstig -SubSystem CmdExec, PowerShell \r\n-ServerRole securtyadmin -MsdbRole ServerGroupAdministratorRole\nCreates an Agent Proxy on sql2016 with the name STIG with the \u0027PowerShell Proxy\u0027 credential and the following principals:\nLogin: ad\\sqlstig\r\nServerRole: securtyadmin\r\nMsdbRole: ServerGroupAdministratorRole\nBy default, only sysadmins have access to create job steps with proxies. This will allow 3 additional principals access:\r\nThe proxy is then added to the CmdExec and PowerShell subsystems", "Syntax": "New-DbaAgentProxy [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString[]\u003e [-ProxyCredential] \u003cString[]\u003e [[-SubSystem] \u003cString[]\u003e] [[-Description] \u003cString\u003e] [[-Login] \u003cString[]\u003e] [[-ServerRole] \u003cString[]\u003e] [[-MsdbRole] \u003cString[]\u003e] [-Disabled] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaAgentSchedule", "Description": "New-DbaAgentSchedule will help create a new schedule for a job.\nIf the job parameter is not supplied the schedule will not be attached to a job.", "Tags": [ "Agent", "Job", "JobStep" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Job", "The name of the job that has the schedule.", "", false, "false", "" ], [ "Schedule", "The name of the schedule.", "", false, "false", "" ], [ "Disabled", "Set the schedule to disabled. Default is enabled", "", false, "false", "False" ], [ "FrequencyType", "A value indicating when a job is to be executed.\nAllowed values: Once, Daily, Weekly, Monthly, MonthlyRelative, AgentStart or IdleComputer\nIf force is used the default will be \"Once\".", "", false, "false", "" ], [ "FrequencyInterval", "The days that a job is executed\nAllowed values: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Weekdays, Weekend or EveryDay.\r\nThe other allowed values are the numbers 1 to 31 for each day of the month.\nIf \"Weekdays\", \"Weekend\" or \"EveryDay\" is used it over writes any other value that has been passed before.\nIf force is used the default will be 1.", "", false, "false", "" ], [ "FrequencySubdayType", "Specifies the units for the subday FrequencyInterval.\nAllowed values: Time, Seconds, Minutes, or Hours", "", false, "false", "" ], [ "FrequencySubdayInterval", "The number of subday type periods to occur between each execution of a job.", "", false, "false", "0" ], [ "FrequencyRelativeInterval", "A job\u0027s occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).\nAllowed values: First, Second, Third, Fourth or Last", "", false, "false", "" ], [ "FrequencyRecurrenceFactor", "The number of weeks or months between the scheduled execution of a job.\nFrequencyRecurrenceFactor is used only if FrequencyType is \"Weekly\", \"Monthly\" or \"MonthlyRelative\".", "", false, "false", "0" ], [ "StartDate", "The date on which execution of a job can begin.\nIf force is used the start date will be the current day", "", false, "false", "" ], [ "EndDate", "The date on which execution of a job can stop.\nIf force is used the end date will be \u00279999-12-31\u0027", "", false, "false", "" ], [ "StartTime", "The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.\nIf force is used the start time will be \u002700:00:00\u0027", "", false, "false", "" ], [ "EndTime", "The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.\nIf force is used the start time will be \u002723:59:59\u0027", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.\r\nIt will also remove the any present schedules with the same name for the specific job.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "New-DbaAgentSchedule creates a new schedule in the msdb database.", "Name": "New-DbaAgentSchedule", "Links": "https://dbatools.io/New-DbaAgentSchedule", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAgentSchedule -SqlInstance localhost\\SQL2016 -Schedule daily -FrequencyType Daily -FrequencyInterval Everyday -Force\nCreates a schedule with a daily frequency every day. It assumes default values for the start date, start time, end date and end time due to -Force.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaAgentSchedule -SqlInstance sstad-pc -Schedule MonthlyTest -FrequencyType Monthly -FrequencyInterval 10 -FrequencyRecurrenceFactor 1 -Force\nCreate a schedule with a monhtly frequency occuring every 10th of the month. It assumes default values for the start date, start time, end date and end time due to -Force.", "Syntax": "New-DbaAgentSchedule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [[-Schedule] \u003cObject\u003e] [-Disabled] [[-FrequencyType] \u003cObject\u003e] [[-FrequencyInterval] \u003cObject[]\u003e] [[-FrequencySubdayType] \u003cObject\u003e] [[-FrequencySubdayInterval] \u003cInt32\u003e] [[-FrequencyRelativeInterval] \u003cObject\u003e] [[-FrequencyRecurrenceFactor] \u003cInt32\u003e] [[-StartDate] \u003cString\u003e] [[-EndDate] \u003cString\u003e] [[-StartTime] \u003cString\u003e] [[-EndTime] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaAvailabilityGroup", "Description": "Automates the creation of availability groups.\n\n* Checks prerequisites\n* Creates Availability Group and adds primary replica\n* Grants cluster permissions if necessary\n* Adds secondary replica if supplied\n* Adds databases if supplied\n* Performs backup/restore if seeding mode is manual\n* Performs backup to NUL if seeding mode is automatic\n* Adds listener to primary if supplied\n* Joins secondaries to availability group\n* Grants endpoint connect permissions to service accounts\n* Grants CreateAnyDatabase permissions if seeding mode is automatic\n* Returns Availability Group object from primary\n\nNOTE: If a backup / restore is performed, the backups will be left intact on the network share.\n\nThanks for this, Thomas Stringer! https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/29/set-up-an-alwayson-availability-group-with-powershell/", "Tags": "HA", "Params": [ [ "Primary", "The primary SQL Server instance. Server version must be SQL Server version 2012 or higher.", "", false, "true (ByValue)", "" ], [ "PrimarySqlCredential", "Login to the primary instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Secondary", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SecondarySqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "The name of the Availability Group.", "", true, "false", "" ], [ "DtcSupport", "Indicates whether the DtcSupport is enabled", "", false, "false", "False" ], [ "ClusterType", "Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.\r\nOptions include: External, Wsfc or None. None by default.", "", false, "false", "External" ], [ "AutomatedBackupPreference", "Specifies how replicas in the primary role are treated in the evaluation to pick the desired replica to perform a backup.", "", false, "false", "Secondary" ], [ "FailureConditionLevel", "Specifies the different conditions that can trigger an automatic failover in Availability Group.", "", false, "false", "OnServerDown" ], [ "HealthCheckTimeout", "This setting used to specify the length of time, in milliseconds, that the SQL Server resource DLL should wait for information returned by the sp_server_diagnostics stored procedure before reporting \r\nthe Always On Failover Cluster Instance (FCI) as unresponsive.\nChanges that are made to the timeout settings are effective immediately and do not require a restart of the SQL Server resource.\nDefaults to 30000 (30 seconds).", "", false, "false", "30000" ], [ "Basic", "Indicates whether the availability group is basic. Basic availability groups like pumpkin spice and uggs.\nhttps://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/basic-availability-groups-always-on-availability-groups", "", false, "false", "False" ], [ "DatabaseHealthTrigger", "Indicates whether the availability group triggers the database health.", "", false, "false", "False" ], [ "Passthru", "Don\u0027t create the availability group, just pass thru an object that can be further customized before creation.", "", false, "false", "False" ], [ "Database", "The database or databases to add.", "", false, "false", "" ], [ "SharedPath", "The network share where the backups will be backed up and restored from.\nEach SQL Server service account must have access to this share.\nNOTE: If a backup / restore is performed, the backups will be left in tact on the network share.", "", false, "false", "" ], [ "UseLastBackup", "Use the last full backup of database.", "", false, "false", "False" ], [ "Force", "Drop and recreate the database on remote servers using fresh backup.", "", false, "false", "False" ], [ "AvailabilityMode", "Sets the availability mode of the availability group replica. Options are: AsynchronousCommit and SynchronousCommit. SynchronousCommit is default.", "", false, "false", "SynchronousCommit" ], [ "FailoverMode", "Sets the failover mode of the availability group replica. Options are Automatic, Manual and External. Automatic is default.", "", false, "false", "Automatic" ], [ "BackupPriority", "Sets the backup priority availability group replica. Default is 50.", "", false, "false", "50" ], [ "ConnectionModeInPrimaryRole", "Specifies the connection intent modes of an Availability Replica in primary role. AllowAllConnections by default.", "", false, "false", "AllowAllConnections" ], [ "ConnectionModeInSecondaryRole", "Specifies the connection modes of an Availability Replica in secondary role. AllowAllConnections by default.", "", false, "false", "AllowAllConnections" ], [ "SeedingMode", "Specifies how the secondary replica will be initially seeded.\nAutomatic enables direct seeding. This method will seed the secondary replica over the network. This method does not require you to backup and restore a copy of the primary database on the replica.\nManual requires you to create a backup of the database on the primary replica and manually restore that backup on the secondary replica.", "", false, "false", "Manual" ], [ "Endpoint", "By default, this command will attempt to find a DatabaseMirror endpoint. If one does not exist, it will create it.\nIf an endpoint must be created, the name \"hadr_endpoint\" will be used. If an alternative is preferred, use Endpoint.", "", false, "false", "" ], [ "ReadonlyRoutingConnectionUrl", "Sets the read only routing connection url for the availability replica.", "", false, "false", "" ], [ "Certificate", "Specifies that the endpoint is to authenticate the connection using the certificate specified by certificate_name to establish identity for authorization.\nThe far endpoint must have a certificate with the public key matching the private key of the specified certificate.", "", false, "false", "" ], [ "IPAddress", "Sets the IP address of the availability group listener.", "", false, "false", "" ], [ "SubnetMask", "Sets the subnet IP mask of the availability group listener.", "", false, "false", "255.255.255.0" ], [ "Port", "Sets the number of the port used to communicate with the availability group.", "", false, "false", "1433" ], [ "Dhcp", "Indicates whether the object is DHCP.", "", 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" ], [ "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": "Automates the creation of availability groups.", "Name": "New-DbaAvailabilityGroup", "Links": "https://dbatools.io/New-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAvailabilityGroup -Primary sql2016a -Name SharePoint\nCreates a new availability group on sql2016a named SharePoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaAvailabilityGroup -Primary sql2016a -Name SharePoint -Secondary sql2016b\nCreates a new availability group on sql2016b named SharePoint with a secondary replica, sql2016b\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaAvailabilityGroup -Primary sql2016std -Name BAG1 -Basic -Confirm:$false\nCreates a basic availability group named BAG1 on sql2016std and does not confirm when setting up\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaAvailabilityGroup -Primary sql2016b -Name AG1 -ClusterType Wsfc -Dhcp -Database db1 -UseLastBackup\nCreates an availability group on sql2016b with the name ag1. Uses the last backups available to add the database db1 to the AG.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eNew-DbaAvailabilityGroup -Primary sql2017 -Name SharePoint -ClusterType None -FailoverMode Manual\nCreates a new availability group on sql2017 named SharePoint with a cluster type of none and a failover mode of manual\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eNew-DbaAvailabilityGroup -Primary sql1 -Secondary sql2 -Name ag1 -Database pubs -ClusterType None -SeedingMode Automatic -FailoverMode Manual\nCreates a new availability group with a primary replica on sql1 and a secondary on sql2. Automatically adds the database pubs.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e $params = @{\r\n \u003e\u003e Primary = \"sql1\"\r\n \u003e\u003e PrimarySqlCredential = $cred\r\n \u003e\u003e Secondary = \"sql2\"\r\n \u003e\u003e SecondarySqlCredential = $cred\r\n \u003e\u003e Name = \"test-ag\"\r\n \u003e\u003e Database = \"pubs\"\r\n \u003e\u003e ClusterType = \"None\"\r\n \u003e\u003e SeedingMode = \"Automatic\"\r\n \u003e\u003e FailoverMode = \"Manual\"\r\n \u003e\u003e Confirm = $false\r\n \u003e\u003e }\r\nPS C:\\\u003e New-DbaAvailabilityGroup @params\nThis exact command was used to create an availability group on docker!", "Syntax": "New-DbaAvailabilityGroup [[-Primary] \u003cDbaInstanceParameter\u003e] [[-PrimarySqlCredential] \u003cPSCredential\u003e] [[-Secondary] \u003cDbaInstanceParameter[]\u003e] [[-SecondarySqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString\u003e [-DtcSupport] [[-ClusterType] \u003cString\u003e] [[-AutomatedBackupPreference] \u003cString\u003e] [[-FailureConditionLevel] \u003cString\u003e] [[-HealthCheckTimeout] \u003cInt32\u003e] [-Basic] [-DatabaseHealthTrigger] [-Passthru] [[-Database] \u003cString[]\u003e] [[-SharedPath] \u003cString\u003e] [-UseLastBackup] [-Force] [[-AvailabilityMode] \u003cString\u003e] [[-FailoverMode] \u003cString\u003e] [[-BackupPriority] \u003cInt32\u003e] [[-ConnectionModeInPrimaryRole] \u003cString\u003e] \r\n[[-ConnectionModeInSecondaryRole] \u003cString\u003e] [[-SeedingMode] \u003cString\u003e] [[-Endpoint] \u003cString\u003e] [[-ReadonlyRoutingConnectionUrl] \u003cString\u003e] [[-Certificate] \u003cString\u003e] [[-IPAddress] \u003cIPAddress[]\u003e] [[-SubnetMask] \u003cIPAddress\u003e] [[-Port] \u003cInt32\u003e] [-Dhcp] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaClientAlias", "Description": "Creates/updates a SQL Server alias by altering HKLM:\\SOFTWARE\\Microsoft\\MSSQLServer\\Client", "Tags": "Alias", "Params": [ [ "ComputerName", "The target computer where the alias will be created", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to remote computers using alternative credentials", "", false, "false", "" ], [ "ServerName", "The target SQL Server", "", true, "true (ByValue)", "" ], [ "Alias", "The alias to be created", "", true, "false", "" ], [ "Protocol", "The protocol for the connection, either TCPIP or NetBIOS. Defaults to TCPIP.", "", false, "false", "TCPIP" ], [ "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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates/updates a sql alias for the specified server - mimics cliconfg.exe", "Name": "New-DbaClientAlias", "Links": "https://dbatools.io/New-DbaClientAlias", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaClientAlias -ServerName sqlcluster\\sharepoint -Alias sp\nCreates a new TCP alias on the local workstation called sp, which points sqlcluster\\sharepoint\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaClientAlias -ServerName \u0027sqlcluster,14443\u0027 -Alias spinstance\nCreates a new TCP alias on the local workstation called spinstance, which points to sqlcluster, port 14443.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaClientAlias -ServerName sqlcluster\\sharepoint -Alias sp -Protocol NamedPipes\nCreates a new NamedPipes alias on the local workstation called sp, which points sqlcluster\\sharepoint", "Syntax": "New-DbaClientAlias [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-ServerName] \u003cDbaInstanceParameter[]\u003e [-Alias] \u003cString\u003e [[-Protocol] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaCmConnection", "Description": "Generates a connection object for use in remote computer management.\nThose objects are used for the purpose of cim/wmi queries, caching which protocol worked, optimizing performance and minimizing authentication errors.\n\nNew-DbaCmConnection will create a NEW object and overwrite any existing ones for the specified computer.\nFurthermore, information stored in the input beyond the computername will be discarded in favor of the new settings.\n\nUnless the connection cache has been disabled, all connections will automatically be registered in the cache, so no further action is necessary.\nThe output is primarily for information purposes, however it may be used to pass objects and circumvent the cache with those.\n\nNOTE: Generally, this function need not be used, as a first connection to a computer using any connecting function such as \"Get-DbaCmObject\" will automatically register a new default connection for it.\n\nThis function exists to be able to preconfigure connections.", "Tags": [ "ComputerManagement", "CIM" ], "Params": [ [ "ComputerName", "The computer to build the connection object for.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "The credential to register.", "", false, "false", "" ], [ "UseWindowsCredentials", "Whether using the default windows credentials is legit.\r\nNot setting this will not exclude using windows credentials, but only not pre-confirm them as working.", "", false, "false", "False" ], [ "OverrideExplicitCredential", "Setting this will enable the credential override.\r\nThe override will cause the system to ignore explicitly specified credentials, so long as known, good credentials are available.", "", false, "false", "False" ], [ "DisabledConnectionTypes", "Exlicitly disable connection types.\r\nThese types will then not be used for connecting to the computer.", "", false, "false", "None" ], [ "DisableBadCredentialCache", "Will prevent the caching of credentials if set to true.", "", false, "false", "False" ], [ "DisableCimPersistence", "Will prevent Cim-Sessions to be reused.", "", false, "false", "False" ], [ "DisableCredentialAutoRegister", "Will prevent working credentials from being automatically cached", "", false, "false", "False" ], [ "EnableCredentialFailover", "Will enable automatic failing over to known to work credentials, when using bad credentials.\r\nBy default, passing bad credentials will cause the Computer Management functions to interrupt with a warning (Or exception if in silent mode).", "", false, "false", "False" ], [ "WindowsCredentialsAreBad", "Will prevent the windows credentials of the currently logged on user from being used for the remote connection.", "", false, "false", "False" ], [ "CimWinRMOptions", "Specify a set of options to use when connecting to the target computer using CIM over WinRM.\r\nUse \u0027New-CimSessionOption\u0027 to create such an object.", "", false, "false", "" ], [ "CimDCOMOptions", "Specify a set of options to use when connecting to the target computer using CIM over DCOM.\r\nUse \u0027New-CimSessionOption\u0027 to create such an object.", "", 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", "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": "", "Synopsis": "Generates a connection object for use in remote computer management.", "Name": "New-DbaCmConnection", "Links": "https://dbatools.io/New-DbaCmConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaCmConnection -ComputerName sql2014 -UseWindowsCredentials -OverrideExplicitCredential -DisabledConnectionTypes CimRM\nReturns a new configuration object for connecting to the computer sql2014.\r\n- The current user credentials are set as valid\r\n- The connection is configured to ignore explicit credentials (so all connections use the windows credentials)\r\n- The connections will not try using CIM over WinRM\nUnless caching is globally disabled, this is automatically stored in the connection cache and will be applied automatically.\r\nIn that (the default) case, the output is for information purposes only and need not be used.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-Content computers.txt | New-DbaCmConnection -Credential $cred -CimWinRMOptions $options -DisableBadCredentialCache -OverrideExplicitCredential\nGathers a list of computers from a text file, then creates and registers connections for each of them, setting them to ...\r\n- use the credentials stored in $cred\r\n- use the options stored in $options when connecting using CIM over WinRM\r\n- not store credentials that are known to not work\r\n- to ignore explicitly specified credentials\nEssentially, this configures all connections to those computers to prefer failure with the specified credentials over using alternative credentials.", "Syntax": "New-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-OverrideExplicitCredential] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] [-WindowsCredentialsAreBad] [-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nNew-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-UseWindowsCredentials] [-OverrideExplicitCredential] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] [-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaComputerCertificate", "Description": "Creates a new computer certificate - self-signed or signed by an Active Directory CA, using the Web Server certificate.\n\nBy default, a key with a length of 1024 and a friendly name of the machines FQDN is generated.\n\nThis command was originally intended to help automate the process so that SSL certificates can be available for enforcing encryption on connections.\n\nIt makes a lot of assumptions - namely, that your account is allowed to auto-enroll and that you have permission to do everything it needs to do ;)\n\nReferences:\nhttp://sqlmag.com/sql-server/7-steps-ssl-encryption\nhttps://azurebi.jppp.org/2016/01/23/using-lets-encrypt-certificates-for-secure-sql-server-connections/\nhttps://blogs.msdn.microsoft.com/sqlserverfaq/2016/09/26/creating-and-registering-ssl-certificates/\n\nThe certificate is generated using AD\u0027s webserver SSL template on the client machine and pushed to the remote machine.", "Tags": "Certificate", "Params": [ [ "ComputerName", "The target SQL Server instance or instances. Defaults to localhost. If target is a cluster, you must also specify ClusterInstanceName (see below)", "ServerInstance,SqlServer,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative credentials.", "", false, "false", "" ], [ "CaServer", "Optional - the CA Server where the request will be sent to", "", false, "false", "" ], [ "CaName", "The properly formatted CA name of the corresponding CaServer", "", false, "false", "" ], [ "ClusterInstanceName", "When creating certs for a cluster, use this parameter to create the certificate for the cluster node name. Use ComputerName for each of the nodes.", "", false, "false", "" ], [ "Password", "Password to encrypt/decrypt private key for export to remote machine", "", false, "false", "" ], [ "FriendlyName", "The FriendlyName listed in the certificate. This defaults to the FQDN of the $ComputerName", "", false, "false", "SQL Server" ], [ "CertificateTemplate", "The domain\u0027s Certificate Template - WebServer by default.", "", false, "false", "WebServer" ], [ "KeyLength", "The length of the key - defaults to 1024", "", false, "false", "1024" ], [ "Store", "Certificate store - defaults to LocalMachine", "", false, "false", "LocalMachine" ], [ "Folder", "Certificate folder - defaults to My (Personal)", "", false, "false", "My" ], [ "Dns", "Specify the Dns entries listed in SAN. By default, it will be ComputerName + FQDN, or in the case of clusters, clustername + cluster FQDN.", "", false, "false", "" ], [ "SelfSigned", "Creates a self-signed certificate. All other parameters can still apply except CaServer and CaName because the command does not go and get the certificate signed.", "", 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": "Creates a new computer certificate useful for Forcing Encryption", "Name": "New-DbaComputerCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaComputerCertificate\nCreates a computer certificate signed by the local domain CA for the local machine with the keylength of 1024.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaComputerCertificate -ComputerName Server1\nCreates a computer certificate signed by the local domain CA _on the local machine_ for server1 with the keylength of 1024.\nThe certificate is then copied to the new machine over WinRM and imported.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaComputerCertificate -ComputerName sqla, sqlb -ClusterInstanceName sqlcluster -KeyLength 4096\nCreates a computer certificate for sqlcluster, signed by the local domain CA, with the keylength of 4096.\nThe certificate is then copied to sqla _and_ sqlb over WinRM and imported.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaComputerCertificate -ComputerName Server1 -WhatIf\nShows what would happen if the command were run\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eNew-DbaComputerCertificate -SelfSigned\nCreates a self-signed certificate", "Syntax": "New-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CaServer] \u003cString\u003e] [[-CaName] \u003cString\u003e] [[-ClusterInstanceName] \u003cString\u003e] [[-Password] \u003cSecureString\u003e] [[-FriendlyName] \u003cString\u003e] [[-CertificateTemplate] \u003cString\u003e] [[-KeyLength] \u003cInt32\u003e] [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] [[-Dns] \u003cString[]\u003e] [-SelfSigned] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaConnectionString", "Description": "Builds or extracts a SQL Server Connection String\n\nSee https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx\nand https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnectionstringbuilder.aspx\nand https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx", "Tags": [ "Connection", "Connect", "ConnectionString" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Credential", "Credential object used to connect to the SQL Server as a different user be it Windows or SQL Server. Windows users are determined by the existence of a backslash, so if you are intending to use an \r\nalternative Windows connection instead of a SQL login, ensure it contains a backslash.", "SqlCredential", false, "false", "" ], [ "AccessToken", "Gets or sets the access token for the connection.", "", false, "false", "" ], [ "ApplicationIntent", "Declares the application workload type when connecting to a server. Possible values are ReadOnly and ReadWrite.", "", false, "false", "" ], [ "BatchSeparator", "By default, this is \"GO\"", "", false, "false", "" ], [ "ClientName", "By default, this command sets the client to \"dbatools PowerShell module - dbatools.io - custom connection\" if you\u0027re doing anything that requires profiling, you can look for this client name. Using \r\n-ClientName allows you to set your own custom client.", "", false, "false", "custom connection" ], [ "ConnectTimeout", "The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.\nValid values are greater than or equal to 0 and less than or equal to 2147483647.\nWhen opening a connection to a Azure SQL Database, set the connection timeout to 30 seconds.", "", false, "false", "0" ], [ "EncryptConnection", "When true, SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed. Recognized values are true, false, yes, and no. For more \r\ninformation, see Connection String Syntax.\nBeginning in .NET Framework 4.5, when TrustServerCertificate is false and Encrypt is true, the server name (or IP address) in a SQL Server SSL certificate must exactly match the server name (or IP \r\naddress) specified in the connection string. Otherwise, the connection attempt will fail. For information about support for certificates whose subject starts with a wildcard character (*), see \r\nAccepted wildcards used by server certificates for server authentication.", "", false, "false", "False" ], [ "FailoverPartner", "The name of the failover partner server where database mirroring is configured.\nIf the value of this key is \"\", then Initial Catalog must be present, and its value must not be \"\".\nThe server name can be 128 characters or less.\nIf you specify a failover partner but the failover partner server is not configured for database mirroring and the primary server (specified with the Server keyword) is not available, then the \r\nconnection will fail.\nIf you specify a failover partner and the primary server is not configured for database mirroring, the connection to the primary server (specified with the Server keyword) will succeed if the primary \r\nserver is available.", "", false, "false", "" ], [ "IsActiveDirectoryUniversalAuth", "Azure related", "", false, "false", "False" ], [ "LockTimeout", "Sets the time in seconds required for the connection to time out when the current transaction is locked.", "", false, "false", "0" ], [ "MaxPoolSize", "Sets the maximum number of connections allowed in the connection pool for this specific connection string.", "", false, "false", "0" ], [ "MinPoolSize", "Sets the minimum number of connections allowed in the connection pool for this specific connection string.", "", false, "false", "0" ], [ "MultipleActiveResultSets", "When used, an application can maintain multiple active result sets (MARS). When false, an application must process or cancel all result sets from one batch before it can execute any other batch on \r\nthat connection.", "", false, "false", "False" ], [ "MultiSubnetFailover", "If your application is connecting to an AlwaysOn availability group (AG) on different subnets, setting MultiSubnetFailover provides faster detection of and connection to the (currently) active \r\nserver. For more information about SqlClient support for Always On Availability Groups", "", false, "false", "False" ], [ "NetworkProtocol", "Connect explicitly using \u0027TcpIp\u0027,\u0027NamedPipes\u0027,\u0027Multiprotocol\u0027,\u0027AppleTalk\u0027,\u0027BanyanVines\u0027,\u0027Via\u0027,\u0027SharedMemory\u0027 and \u0027NWLinkIpxSpx\u0027", "", false, "false", "" ], [ "NonPooledConnection", "Request a non-pooled connection", "", false, "false", "False" ], [ "PacketSize", "Sets the size in bytes of the network packets used to communicate with an instance of SQL Server. Must match at server.", "", false, "false", "0" ], [ "PooledConnectionLifetime", "When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by \r\nConnection Lifetime. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.\nA value of zero (0) causes pooled connections to have the maximum connection timeout.", "", false, "false", "0" ], [ "SqlExecutionModes", "The SqlExecutionModes enumeration contains values that are used to specify whether the commands sent to the referenced connection to the server are executed immediately or saved in a buffer.\nValid values include CaptureSql, ExecuteAndCaptureSql and ExecuteSql.", "", false, "false", "" ], [ "StatementTimeout", "Sets the number of seconds a statement is given to run before failing with a time-out error.", "", false, "false", "0" ], [ "TrustServerCertificate", "Sets a value that indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust.", "", false, "false", "False" ], [ "WorkstationId", "Sets the name of the workstation connecting to SQL Server.", "", false, "false", "" ], [ "AppendConnectionString", "Appends to the current connection string. Note that you cannot pass authentication information using this method. Use -SqlInstance and, optionally, -SqlCredential to set authentication information.", "", 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": "New-DbaSqlConnectionString", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Builds or extracts a SQL Server Connection String", "Name": "New-DbaConnectionString", "Links": "https://dbatools.io/New-DbaConnectionString", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaConnectionString -SqlInstance sql2014\nCreates a connection string that connects using Windows Authentication\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eConnect-DbaInstance -SqlInstance sql2016 | New-DbaConnectionString\nBuilds a connected SMO object using Connect-DbaInstance then extracts and displays the connection string\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\nPS C:\\\u003e New-DbaConnectionString -SqlInstance sql2014 -Credential $wincred\nCreates a connection string that connects using alternative Windows credentials\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$sqlcred = Get-Credential sqladmin\nPS C:\\\u003e $server = New-DbaConnectionString -SqlInstance sql2014 -Credential $sqlcred\nLogin to sql2014 as SQL login sqladmin.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$server = New-DbaConnectionString -SqlInstance sql2014 -ClientName \"mah connection\"\nCreates a connection string that connects using Windows Authentication and uses the client name \"mah connection\". So when you open up profiler or use extended events, you can search for \"mah \r\nconnection\".\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$server = New-DbaConnectionString -SqlInstance sql2014 -AppendConnectionString \"Packet Size=4096;AttachDbFilename=C:\\MyFolder\\MyDataFile.mdf;User Instance=true;\"\nCreates a connection string that connects to sql2014 using Windows Authentication, then it sets the packet size (this can also be done via -PacketSize) and other connection attributes.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$server = New-DbaConnectionString -SqlInstance sql2014 -NetworkProtocol TcpIp -MultiSubnetFailover\nCreates a connection string with Windows Authentication that uses TCPIP and has MultiSubnetFailover enabled.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003e$connstring = New-DbaConnectionString sql2016 -ApplicationIntent ReadOnly\nCreates a connection string with ReadOnly ApplicationIntent.", "Syntax": "New-DbaConnectionString [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [[-AccessToken] \u003cString\u003e] [[-ApplicationIntent] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [[-ClientName] \u003cString\u003e] [[-ConnectTimeout] \u003cInt32\u003e] [-EncryptConnection] [[-FailoverPartner] \u003cString\u003e] [-IsActiveDirectoryUniversalAuth] [[-LockTimeout] \u003cInt32\u003e] [[-MaxPoolSize] \u003cInt32\u003e] [[-MinPoolSize] \u003cInt32\u003e] [-MultipleActiveResultSets] [-MultiSubnetFailover] [[-NetworkProtocol] \u003cString\u003e] [-NonPooledConnection] [[-PacketSize] \u003cInt32\u003e] [[-PooledConnectionLifetime] \u003cInt32\u003e] [[-SqlExecutionModes] \u003cString\u003e] \r\n[[-StatementTimeout] \u003cInt32\u003e] [-TrustServerCertificate] [[-WorkstationId] \u003cString\u003e] [[-AppendConnectionString] \u003cString\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaConnectionStringBuilder", "Description": "Creates a System.Data.SqlClient.SqlConnectionStringBuilder from a connection string.", "Tags": [ "SqlBuild", "ConnectionString", "Connection" ], "Params": [ [ "ConnectionString", "A Connection String", "", false, "true (ByValue)", "" ], [ "ApplicationName", "The application name to tell SQL Server the connection is associated with.", "", false, "false", "dbatools Powershell Module" ], [ "DataSource", "The Sql Server to connect to.", "", false, "false", "" ], [ "InitialCatalog", "The initial database on the server to connect to.", "", false, "false", "" ], [ "IntegratedSecurity", "Set to true to use windows authentication.", "", false, "false", "" ], [ "UserName", "Sql User Name to connect with.", "", false, "false", "" ], [ "Password", "Password to use to connect with.", "", false, "false", "" ], [ "MultipleActiveResultSets", "Enable Multiple Active Result Sets.", "MARS", false, "false", "False" ], [ "ColumnEncryptionSetting", "Enable Always Encrypted.", "AlwaysEncrypted", false, "false", "Enabled" ], [ "WorkstationId", "Set the Workstation Id that is associated with the connection.", "", false, "false", "$env:COMPUTERNAME" ], [ "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": "New-DbaSqlConnectionStringBuilder", "Author": "zippy1981 | Chrissy LeMaire (@cl)", "Synopsis": "Returns a System.Data.SqlClient.SqlConnectionStringBuilder with the string specified", "Name": "New-DbaConnectionStringBuilder", "Links": "https://dbatools.io/New-DbaConnectionStringBuilder", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaConnectionStringBuilder\nReturns an empty ConnectionStringBuilder\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\"Data Source=localhost,1433;Initial Catalog=AlwaysEncryptedSample;UID=sa;PWD=alwaysB3Encrypt1ng;Application Name=Always Encrypted Sample MVC App;Column Encryption Setting=enabled\" | \r\nNew-DbaConnectionStringBuilder\nReturns a connection string builder that can be used to connect to the local sql server instance on the default port.", "Syntax": "New-DbaConnectionStringBuilder [[-ConnectionString] \u003cString[]\u003e] [[-ApplicationName] \u003cString\u003e] [[-DataSource] \u003cString\u003e] [[-InitialCatalog] \u003cString\u003e] [[-IntegratedSecurity] \u003cNullable`1\u003e] [[-UserName] \u003cString\u003e] [[-Password] \u003cString\u003e] [-MultipleActiveResultSets] [[-ColumnEncryptionSetting] {Disabled | Enabled}] [[-WorkstationId] \u003cString\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaCredential", "Description": "Creates a new credential", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server(s)", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Name", "The Credential name", "", false, "false", "$Identity" ], [ "Identity", "The Credential Identity", "CredentialIdentity", true, "false", "" ], [ "Password", "Secure string used to authenticate the Credential Identity", "", false, "false", "" ], [ "MappedClassType", "Sets the class associated with the credential.", "", false, "false", "None" ], [ "ProviderName", "Sets the name of the provider", "", false, "false", "" ], [ "Force", "If credential exists, drop and recreate", "", 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": "Creates a new SQL Server credential", "Name": "New-DbaCredential", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaCredential -SqlInstance Server1\nYou will be prompted to securely enter your password, then a credential will be created in the master database on server1 if it does not exist.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaCredential -SqlInstance Server1 -Confirm:$false\nSuppresses all prompts to install but prompts to securely enter your password and creates a credential on Server1.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaCredential -SqlInstance Server1 -Name AzureBackupBlobStore -Identity \u0027\u003cAzure Storage Account Name\u003e\u0027 -Password (ConvertTo-SecureString \u0027\u003cAzure Storage Account Access Key\u003e\u0027 -AsPlainText \r\n-Force)\nCreate credential on SQL Server 2012 CU2, SQL Server 2014 for use with BACKUP TO URL.\r\nCredentialIdentity needs to be supplied with the Azure Storage Account Name.\r\nPassword needs to be one of the Access Keys for the account.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaCredential -SqlInstance Server1 -Name \u0027https://\u003cAzure Storage Account Name\u003e.blob.core.windows.net/\u003cBlob Store Container Name\u003e\u0027 -Identity \u0027SHARED ACCESS SIGNATURE\u0027 -Password \r\n(ConvertTo-SecureString \u0027\u003cShared Access Token\u003e\u0027 -AsPlainText -Force)\nCreate Credential on SQL Server 2016 or higher for use with BACKUP TO URL.\r\nName has to be the full URL for the blob store container that will be the backup target.\r\nPassword needs to be passed the Shared Access Token (SAS Key).", "Syntax": "New-DbaCredential [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cObject[]\u003e] [-Identity] \u003cString[]\u003e [[-Password] \u003cSecureString\u003e] [[-MappedClassType] \u003cString\u003e] [[-ProviderName] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDacOption", "Description": "Creates a new Microsoft.SqlServer.Dac.DacExtractOptions/DacExportOptions object that can be used during DacPackage extract. Basically saves you the time from remembering the SMO assembly name ;)\n\nSee:\nhttps://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dac.dacexportoptions.aspx\nhttps://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dac.dacextractoptions.aspx\nfor more information", "Tags": [ "Migration", "Database", "Dacpac" ], "Params": [ [ "Type", "Selecting the type of the export: Dacpac (default) or Bacpac.", "", false, "false", "Dacpac" ], [ "Action", "Choosing an intended action: Publish or Export.", "", true, "false", "" ], [ "PublishXml", "Specifies the publish profile which will include options and sqlCmdVariables.", "", 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" ], [ "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": "", "Author": "Kirill Kravtsov (@nvarscar), nvarscar.wordpress.com", "Synopsis": "Creates a new Microsoft.SqlServer.Dac.DacExtractOptions/DacExportOptions object depending on the chosen Type", "Name": "New-DbaDacOption", "Links": "https://dbatools.io/New-DbaDacOption", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$options = New-DbaDacOption -Type Dacpac -Action Export\nPS C:\\\u003e $options.ExtractAllTableData = $true\r\nPS C:\\\u003e $options.CommandTimeout = 0\r\nPS C:\\\u003e Export-DbaDacPackage -SqlInstance sql2016 -Database DB1 -Options $options\nUses DacOption object to set the CommandTimeout to 0 then extracts the dacpac for SharePoint_Config on sql2016 to C:\\temp\\SharePoint_Config.dacpac including all table data.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$options = New-DbaDacOption -Type Dacpac -Action Publish\nPS C:\\\u003e $options.DeployOptions.DropObjectsNotInSource = $true\r\nPS C:\\\u003e Publish-DbaDacPackage -SqlInstance sql2016 -Database DB1 -Options $options -Path c:\\temp\\db.dacpac\nUses DacOption object to set Deployment Options and publish the db.dacpac dacpac file as DB1 on sql2016", "Syntax": "New-DbaDacOption [[-Type] \u003cString\u003e] [-Action] \u003cString\u003e [[-PublishXml] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDacProfile", "Description": "The New-DbaDacProfile command generates a standard publish profile xml file that can be used by the DacFx (this and everything else) to control the deployment of your dacpac\nThis generates a standard template XML which is enough to dpeloy a dacpac but it is highly recommended that you add additional options to the publish profile.\nIf you use Visual Studio you can open a publish.xml file and use the ui to edit the file -\nTo create a new file, right click on an SSDT project, choose \"Publish\" then \"Load Profile\" and load your profile or create a new one.\nOnce you have loaded it in Visual Studio, clicking advanced shows you the list of options available to you.\nFor a full list of options that you can add to the profile, google \"sqlpackage.exe command line switches\" or (https://msdn.microsoft.com/en-us/library/hh550080(v=vs.103).aspx)", "Tags": "Dacpac", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Alternatively, you can provide a ConnectionString.", "ServerInstance,SqlServer", false, "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 name you are targeting", "", true, "false", "" ], [ "Path", "The directory where you would like to save the profile xml file(s).", "", false, "false", "\"$home\\Documents\"" ], [ "ConnectionString", "The connection string to the database you are upgrading.\nAlternatively, you can provide a SqlInstance (and optionally SqlCredential) and the script will connect and generate the connectionstring.", "", false, "false", "" ], [ "PublishOptions", "Optional hashtable to set publish options. Key/value pairs in the hashtable get converted to strings of \"\u003ckey\u003evalue\u003c/key\u003e\".", "", 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" ], [ "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": "New-DbaPublishProfile", "Author": "Richie lee (@richiebzzzt)", "Synopsis": "Creates a new Publish Profile.", "Name": "New-DbaDacProfile", "Links": "https://dbatools.io/New-DbaDacProfile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDacProfile -SqlInstance sql2017 -SqlCredential ad\\sqldba -Database WorldWideImporters -Path C:\\temp\nIn this example, a prompt will appear for alternative credentials, then a connection will be made to sql2017. Using that connection,\r\nthe ConnectionString will be extracted and used within the Publish Profile XML file which will be created at C:\\temp\\sql2017-WorldWideImporters-publish.xml\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaDacProfile -Database WorldWideImporters -Path C:\\temp -ConnectionString \"SERVER=(localdb)\\MSSQLLocalDB;Integrated Security=True;Database=master\"\nIn this example, no connections are made, and a Publish Profile XML would be created at C:\\temp\\localdb-MSSQLLocalDB-WorldWideImporters-publish.xml", "Syntax": "New-DbaDacProfile [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \u003cString[]\u003e [[-Path] \u003cString\u003e] [[-ConnectionString] \u003cString[]\u003e] [[-PublishOptions] \u003cHashtable\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDatabase", "Description": "This command creates a new database.\n\nIt allows creation with multiple files, and sets all growth settings to be fixed size rather than percentage growth.", "Tags": "Database", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "The name of the new database or databases to be created.", "", false, "false", "" ], [ "Collation", "The database collation, if not supplied the default server collation will be used.", "", false, "false", "" ], [ "Recoverymodel", "The recovery model for the database, if not supplied the recovery model from the model database will be used.", "", false, "false", "" ], [ "Owner", "The login that will be used as the database owner.", "", false, "false", "" ], [ "DataFilePath", "The location that data files will be placed, otherwise the default SQL Server data path will be used.", "", false, "false", "" ], [ "LogFilePath", "The location the log file will be placed, otherwise the default SQL Server log path will be used.", "", false, "false", "" ], [ "PrimaryFilesize", "The size in MB for the Primary file. If this is less than the primary file size for the model database, then the model size will be used instead.", "", false, "false", "0" ], [ "PrimaryFileGrowth", "The size in MB that the Primary file will autogrow by.", "", false, "false", "0" ], [ "PrimaryFileMaxSize", "The maximum permitted size in MB for the Primary File. If this is less the primary file size for the model database, then the model size will be used instead.", "", false, "false", "0" ], [ "LogSize", "The size in MB that the Transaction log will be created.", "", false, "false", "0" ], [ "LogGrowth", "The amount in MB that the log file will be set to autogrow by.", "", false, "false", "0" ], [ "SecondaryFilesize", "The size in MB of the files to be added to the Secondary filegroup. Each file added will be created with this size setting.", "", false, "false", "0" ], [ "SecondaryFileGrowth", "The amount in MB that the Secondary files will be set to autogrow by. Use 0 for no growth allowed. Each file added will be created with this growth setting.", "", false, "false", "0" ], [ "SecondaryFileMaxSize", "The maximum permitted size in MB for the Secondary data files to grow to. Each file added will be created with this max size setting.", "", false, "false", "0" ], [ "SecondaryFileCount", "The number of files to create in the Secondary filegroup for the database.", "", false, "false", "0" ], [ "DefaultFileGroup", "Sets the default file group. Either primary or secondary.", "", 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" ], [ "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": "", "Author": "Matthew Darwin (@evoDBA, naturalselectiondba.wordpress.com) | Chrissy LeMaire (@cl)", "Synopsis": "Creates a new database", "Name": "New-DbaDatabase", "Links": "https://dbatools.io/New-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDatabase -SqlInstance sql1\nCreates a randomly named database (random-N) on instance sql1\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaDatabase -SqlInstance sql1 -Name dbatools, dbachecks\nCreates a database named dbatools and a database named dbachecks on sql1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaDatabase -SqlInstance sql1, sql2, sql3 -Name multidb, multidb2 -SecondaryFilesize 20 -SecondaryFileGrowth 20 -LogSize 20 -LogGrowth 20\nCreates two databases, multidb and multidb2, on 3 instances (sql1, sql2 and sql3) and sets the secondary data file size to 20MB, the file growth to 20MB and the log growth to 20MB for each\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaDatabase -SqlInstance sql1 -Name nondefault -DataFilePath M:\\Data -LogFilePath \u0027L:\\Logs with spaces\u0027 -SecondaryFileCount 2\nCreates a database named nondefault and places data files in in the M:\\data directory and log files in \"L:\\Logs with spaces\".\nCreates a secondary group with 2 files in the Secondary filegroup.", "Syntax": "New-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-Collation] \u003cString\u003e] [[-Recoverymodel] \u003cString\u003e] [[-Owner] \u003cString\u003e] [[-DataFilePath] \u003cString\u003e] [[-LogFilePath] \u003cString\u003e] [[-PrimaryFilesize] \u003cInt32\u003e] [[-PrimaryFileGrowth] \u003cInt32\u003e] [[-PrimaryFileMaxSize] \u003cInt32\u003e] [[-LogSize] \u003cInt32\u003e] [[-LogGrowth] \u003cInt32\u003e] [[-SecondaryFilesize] \u003cInt32\u003e] [[-SecondaryFileGrowth] \u003cInt32\u003e] [[-SecondaryFileMaxSize] \u003cInt32\u003e] [[-SecondaryFileCount] \u003cInt32\u003e] [[-DefaultFileGroup] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDbCertificate", "Description": "Creates a new database certificate. If no database is specified, the certificate will be created in master.", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials.", "", false, "false", "" ], [ "Name", "Optional name to create the certificate. Defaults to database name.", "", false, "false", "" ], [ "Database", "The database where the certificate will be created. Defaults to master.", "", false, "false", "master" ], [ "Subject", "Optional subject to create the certificate.", "", false, "false", "" ], [ "StartDate", "Optional secure string used to create the certificate.", "", false, "false", "(Get-Date)" ], [ "ExpirationDate", "Optional secure string used to create the certificate.", "", false, "false", "$StartDate.AddYears(5)" ], [ "ActiveForServiceBrokerDialog", "Optional secure string used to create the certificate.", "", false, "false", "False" ], [ "Password", "Optional password - if no password is supplied, the password will be protected by the master key", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", 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" ], [ "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": "New-DbaDatabaseCertificate", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new database certificate", "Name": "New-DbaDbCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDbCertificate -SqlInstance Server1\nYou will be prompted to securely enter your password, then a certificate will be created in the master database on server1 if it does not exist.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaDbCertificate -SqlInstance Server1 -Database db1 -Confirm:$false\nSuppresses all prompts to install but prompts to securely enter your password and creates a certificate in the \u0027db1\u0027 database", "Syntax": "New-DbaDbCertificate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-Database] \u003cString[]\u003e] [[-Subject] \u003cString[]\u003e] [[-StartDate] \u003cDateTime\u003e] [[-ExpirationDate] \u003cDateTime\u003e] [-ActiveForServiceBrokerDialog] [[-Password] \u003cSecureString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDbMasterKey", "Description": "Creates a new database master key. If no database is specified, the master key will be created in master.", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials.", "", false, "false", "" ], [ "Credential", "Enables easy creation of a secure password.", "", false, "false", "" ], [ "Database", "The database where the master key will be created. Defaults to master.", "", false, "false", "master" ], [ "Password", "Secure string used to create the key.", "", false, "false", "" ], [ "InputObject", "Database object piped in from Get-DbaDatabase.", "", 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" ], [ "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": "New-DbaDatabaseMasterKey", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new database master key", "Name": "New-DbaDbMasterKey", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDbMasterKey -SqlInstance Server1\nYou will be prompted to securely enter your password, then a master key will be created in the master database on server1 if it does not exist.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaDbMasterKey -SqlInstance Server1 -Credential usernamedoesntmatter\nYou will be prompted by a credential interface to securely enter your password, then a master key will be created in the master database on server1 if it does not exist.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaDbMasterKey -SqlInstance Server1 -Database db1 -Confirm:$false\nSuppresses all prompts to install but prompts in th console to securely enter your password and creates a master key in the \u0027db1\u0027 database", "Syntax": "New-DbaDbMasterKey [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-Password] \u003cSecureString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDbSnapshot", "Description": "Creates database snapshots without hassles", "Tags": [ "Snapshot", "Restore", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "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", "" ], [ "AllDatabases", "Creates snapshot for all eligible databases", "", false, "false", "False" ], [ "Name", "The specific snapshot name you want to create. Works only if you target a single database. If you need to create multiple snapshot,\r\nyou must use the NameSuffix parameter", "", false, "false", "" ], [ "NameSuffix", "When you pass a simple string, it\u0027ll be appended to use it to build the name of the snapshot. By default snapshots are created with yyyyMMdd_HHmmss suffix\r\nYou can also pass a standard placeholder, in which case it\u0027ll be interpolated (e.g. \u0027{0}\u0027 gets replaced with the database name)", "", false, "false", "" ], [ "Path", "Snapshot files will be created here (by default the filestructure will be created in the same folder as the base db)", "", false, "false", "" ], [ "Force", "Databases with Filestream FG can be snapshotted, but the Filestream FG is marked offline\r\nin the snapshot. To create a \"partial\" snapshot, you need to pass -Force explicitely\nNB: You can\u0027t then restore the Database from the newly-created snapshot.\r\nFor details, check https://msdn.microsoft.com/en-us/library/bb895334.aspx", "", false, "false", "False" ], [ "InputObject", "Allows Piping from Get-DbaDatabase", "", 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.", "Silent", false, "false", "False" ], [ "WhatIf", "Shows what would happen if the command were to run", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step.", "cf", false, "false", "" ] ], "Alias": "New-DbaDatabaseSnapshot", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Creates database snapshots", "Name": "New-DbaDbSnapshot", "Links": "https://dbatools.io/New-DbaDbSnapshot", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting\nCreates snapshot for HR and Accounting, returning a custom object displaying Server, Database, DatabaseCreated, SnapshotOf, SizeMB, DatabaseCreated, PrimaryFilePath, Status, Notes\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR -Name HR_snap\nCreates snapshot named \"HR_snap\" for HR\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR -NameSuffix \u0027fool_{0}_snap\u0027\nCreates snapshot named \"fool_HR_snap\" for HR\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting -Path F:\\snapshotpath\nCreates snapshots for HR and Accounting databases, storing files under the F:\\snapshotpath\\ dir\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 -Database df | New-DbaDbSnapshot\nCreates a snapshot for the database df on sql2016", "Syntax": "New-DbaDbSnapshot [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-AllDatabases] [[-Name] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-Path] \u003cString\u003e] [-Force] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDbUser", "Description": "Creates a new user for a specified database with provided specifications.", "Tags": [ "Database", "User" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to the default instance on localhost.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins instead of Windows Authentication (AKA Integrated or Trusted). To use:\n$scred = Get-Credential, then pass $scred object to the -SqlCredential parameter.\nWindows Authentication will be used if SqlCredential is not specified. SQL Server does not accept Windows credentials being passed as credentials.\nTo connect to SQL Server as a different Windows user, run PowerShell as that user.", "", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server. By default, system databases are excluded.", "", false, "false", "" ], [ "IncludeSystem", "If this switch is enabled, the user will be added to system databases.", "", false, "false", "False" ], [ "Login", "When specified, the user will be associated to this SQL login and have the same name as the Login.", "", false, "false", "" ], [ "Username", "When specified, the user will have this name.", "", false, "false", "" ], [ "Force", "If user exists, drop and recreate.", "", 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", "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": "", "Author": "Frank Henninger (@osiris687)", "Synopsis": "Creates a new user for the specified database.", "Name": "New-DbaDbUser", "Links": "https://dbatools.io/New-DbaDbUser", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDbUser -SqlInstance sqlserver2014 -Database DB1 -Login user1\nCreates a new sql user with login named user1 in the specified database.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaDbUser -SqlInstance sqlserver2014 -Database DB1 -Username user1\nCreates a new sql user without login named user1 in the specified database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaDbUser -SqlInstance sqlserver2014 -Database DB1 -Login Login1 -Username user1\nCreates a new sql user named user1 mapped to Login1 in the specified database.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbUser -SqlInstance sqlserver1 -Database DB1 | New-DbaDbUser -SqlInstance sqlserver2 -Database DB1\nCopies users from sqlserver1.DB1 to sqlserver2.DB1. Does not copy permissions!", "Syntax": "New-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeSystem] [-Username \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nNew-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-IncludeSystem] [-Login \u003cString[]\u003e] [-Username \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaDirectory", "Description": "Uses master.dbo.xp_create_subdir to create the path\nReturns $true if the path can be created, $false otherwise", "Tags": [ "Path", "Directory", "Folder" ], "Params": [ [ "SqlInstance", "The SQL Server you want to run the test on.", "ServerInstance,SqlServer", true, "false", "" ], [ "Path", "The Path to tests. Can be a file or directory.", "", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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" ], [ "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": "New-DbaSqlDirectory", "Author": "Stuart Moore", "Synopsis": "Creates new path as specified by the path variable", "Name": "New-DbaDirectory", "Links": "https://dbatools.io/New-DbaDirectory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaDirectory -SqlInstance sqlcluster -Path L:\\MSAS12.MSSQLSERVER\\OLAP\nIf the SQL Server instance sqlcluster can create the path L:\\MSAS12.MSSQLSERVER\\OLAP it will do and return $true, if not it will return $false.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$credential = Get-Credential\nPS C:\\\u003e New-DbaDirectory -SqlInstance sqlcluster -SqlCredential $credential -Path L:\\MSAS12.MSSQLSERVER\\OLAP\nIf the SQL Server instance sqlcluster can create the path L:\\MSAS12.MSSQLSERVER\\OLAP it will do and return $true, if not it will return $false. Uses a SqlCredential to connect", "Syntax": "New-DbaDirectory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Path] \u003cString\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaEndpoint", "Description": "Creates endpoints on a SQL Server instance.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "The name of the endpoint. If a name is not specified, one will be auto-generated.", "", false, "false", "" ], [ "Type", "The type of endpoint. Defaults to DatabaseMirroring. Options: DatabaseMirroring, ServiceBroker, Soap, TSql", "", false, "false", "DatabaseMirroring" ], [ "Protocol", "The type of protocol. Defaults to tcp. Options: Tcp, NamedPipes, Http, Via, SharedMemory", "", false, "false", "Tcp" ], [ "Role", "The type of role. Defaults to All. Options: All, None, Partner, Witness", "", false, "false", "All" ], [ "EndpointEncryption", "Used to specify the state of encryption on the endpoint. Defaults to required.\r\nDisabled\r\nRequired\r\nSupported", "", false, "false", "Required" ], [ "EncryptionAlgorithm", "Specifies an encryption algorithm used on an endpoint. Defaults to Aes.\nOptions are:\r\nAesRC4\r\nAes\r\nNone\r\nRC4\r\nRC4Aes", "", false, "false", "Aes" ], [ "Certificate", "Database certificate used for authentication.", "", false, "false", "" ], [ "Port", "Port for TCP. If one is not provided, it will be autogenerated.", "", false, "false", "0" ], [ "SslPort", "Port for SSL", "", false, "false", "0" ], [ "Owner", "Owner of the endpoint. Defaults to sa.", "", 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" ], [ "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": "Creates endpoints on a SQL Server instance.", "Name": "New-DbaEndpoint", "Links": "https://dbatools.io/New-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaEndpoint -SqlInstance localhost\nCreates all Endpoint(s) on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eNew-DbaEndpoint -SqlInstance localhost, sql2016\nReturns all Endpoint(s) for the local and sql2016 SQL Server instances", "Syntax": "New-DbaEndpoint [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Name \u003cString\u003e] [-Type \u003cString\u003e] [-Protocol \u003cString\u003e] [-Role \u003cString\u003e] [-EndpointEncryption \u003cString\u003e] [-EncryptionAlgorithm \u003cString\u003e] [-Certificate \u003cString\u003e] [-Port \u003cInt32\u003e] [-SslPort \u003cInt32\u003e] [-Owner \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaLogin", "Description": "Creates a new SQL Server login with provided specifications", "Tags": [ "Login", "Security" ], "Params": [ [ "SqlInstance", "The target SQL Server(s)", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Login", "The Login name(s)", "Name,LoginName", false, "false", "" ], [ "InputObject", "Takes the parameters required from a Login object that has been piped into the command", "", false, "true (ByValue)", "" ], [ "LoginRenameHashtable", "Pass a hash table into this parameter to change login names when piping objects into the procedure", "Rename", false, "false", "" ], [ "Password", "Secure string used to authenticate the Login", "", false, "false", "" ], [ "HashedPassword", "Hashed password string used to authenticate the Login", "Hash,PasswordHash", false, "false", "" ], [ "MapToCertificate", "Map the login to a certificate", "", false, "false", "" ], [ "MapToAsymmetricKey", "Map the login to an asymmetric key", "", false, "false", "" ], [ "MapToCredential", "Map the login to a credential", "", false, "false", "" ], [ "Sid", "Provide an explicit Sid that should be used when creating the account. Can be [byte[]] or hex [string] (\u00270xFFFF...\u0027)", "", false, "false", "" ], [ "DefaultDatabase", "Default database for the login", "DefaulDB", false, "false", "" ], [ "Language", "Login\u0027s default language", "", false, "false", "" ], [ "PasswordExpiration", "Enforces password expiration policy. Requires PasswordPolicy to be enabled. Can be $true or $false(default)", "Expiration,CheckExpiration", false, "false", "False" ], [ "PasswordPolicy", "Enforces password complexity policy. Can be $true or $false(default)", "Policy,CheckPolicy", false, "false", "False" ], [ "Disabled", "Create the login in a disabled state", "Disable", false, "false", "False" ], [ "NewSid", "Ignore sids from the piped login object to generate new sids on the server. Useful when copying login onto the same server", "", false, "false", "False" ], [ "Force", "If login exists, drop and recreate", "", 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": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Creates a new SQL Server login", "Name": "New-DbaLogin", "Links": "https://dbatools.io/New-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaLogin -SqlInstance Server1,Server2 -Login Newlogin\nYou will be prompted to securely enter the password for a login [Newlogin]. The login would be created on servers Server1 and Server2 with default parameters.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$securePassword = Read-Host \"Input password\" -AsSecureString\nPS C:\\\u003e New-DbaLogin -SqlInstance Server1\\sql1 -Login Newlogin -Password $securePassword -PasswordPolicy -PasswordExpiration\nCreates a login on Server1\\sql1 with a predefined password. The login will have password and expiration policies enforced onto it.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql1 -Login Oldlogin | New-DbaLogin -SqlInstance sql1 -LoginRenameHashtable @{Oldlogin = \u0027Newlogin\u0027} -Force -NewSid -Disabled:$false\nCopies a login [Oldlogin] to the same instance sql1 with the same parameters (including password). New login will have a new sid, a new name [Newlogin] and will not be disabled. Existing login \r\n[Newlogin] will be removed prior to creation.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql1 -Login Login1,Login2 | New-DbaLogin -SqlInstance sql2 -PasswordPolicy -PasswordExpiration -DefaultDatabase tempdb -Disabled\nCopies logins [Login1] and [Login2] from instance sql1 to instance sql2, but enforces password and expiration policies for the new logins. New logins will also have a default database set to [tempdb] \r\nand will be created in a disabled state.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eNew-DbaLogin -SqlInstance sql1 -Login domain\\user\nCreates a new Windows Authentication backed login on sql1. The login will be part of the public server role.", "Syntax": "New-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [-InputObject \u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [[-Password] \u003cSecureString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \u003cObject\u003e] [-DefaultDatabase \u003cString\u003e] [-Language \u003cString\u003e] [-PasswordExpiration] [-PasswordPolicy] [-Disabled] [-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cString[]\u003e] [-InputObject \u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-MapToAsymmetricKey \u003cString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \u003cObject\u003e] [-Disabled] [-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cString[]\u003e] [-InputObject \u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-MapToCertificate \u003cString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \u003cObject\u003e] [-Disabled] [-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cString[]\u003e] [-InputObject \u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-HashedPassword \u003cString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \u003cObject\u003e] [-DefaultDatabase \u003cString\u003e] [-Language \u003cString\u003e] [-PasswordExpiration] [-PasswordPolicy] [-Disabled] [-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaScriptingOption", "Description": "Creates a new Microsoft.SqlServer.Management.Smo.ScriptingOptions object. Basically saves you the time from remembering the SMO assembly name ;)\n\nSee https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.scriptingoptions.aspx for more information", "Tags": [ "Migration", "Backup", "DR" ], "Params": [ ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new Microsoft.SqlServer.Management.Smo.ScriptingOptions object", "Name": "New-DbaScriptingOption", "Links": "https://dbatools.io/New-DbaScriptingOption", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$options = New-DbaScriptingOption\nPS C:\\\u003e $options.ScriptDrops = $false\r\nPS C:\\\u003e $options.WithDependencies = $true\r\nPS C:\\\u003e Get-DbaAgentJob -SqlInstance sql2016 | Export-DbaScript -ScriptingOptionObject $options\nExports Agent Jobs with the Scripting Options ScriptDrops set to $false and WithDependencies set to true", "Syntax": "New-DbaScriptingOption [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaServiceMasterKey", "Description": "Creates a new service master key in the master database.", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials.", "", false, "false", "" ], [ "Credential", "Enables easy creation of a secure password.", "", false, "false", "" ], [ "Password", "Secure string used to create the key.", "", 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" ], [ "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": "Creates a new service master key.", "Name": "New-DbaServiceMasterKey", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaServiceMasterKey -SqlInstance Server1\nYou will be prompted to securely enter your Service Key password, then a master key will be created in the master database on server1 if it does not exist.", "Syntax": "New-DbaServiceMasterKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Password] \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaSsisCatalog", "Description": "After installing the SQL Server Engine and SSIS you still have to enable the SSIS Catalog. This function will enable the catalog and gives the option of supplying the password.", "Tags": [ "SSIS", "SSISDB", "Catalog" ], "Params": [ [ "SqlInstance", "SQL Server you wish to run the function on.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credentials used to connect to the SQL Server", "", false, "false", "" ], [ "Password", "Required password that will be used for the security key in SSISDB.", "", true, "false", "" ], [ "SsisCatalog", "SSIS catalog name. By default, this is SSISDB.", "", false, "false", "SSISDB" ], [ "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": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Enables the SSIS Catalog on a SQL Server 2012+", "Name": "New-DbaSsisCatalog", "Links": "https://dbatools.io/New-DbaSsisCatalog", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$password = ConvertTo-SecureString MyVisiblePassWord -AsPlainText -Force\nPS C:\\\u003e New-DbaSsisCatalog -SqlInstance sql2016 -Password $password\nCreates the SSIS Catalog on server DEV01 with the specified password.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$password = Read-Host -AsSecureString -Prompt \"Enter password\"\nPS C:\\\u003e New-DbaSsisCatalog -SqlInstance DEV01 -Password $password\nCreates the SSIS Catalog on server DEV01 with the specified password.", "Syntax": "New-DbaSsisCatalog [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Password] \u003cSecureString\u003e [[-SsisCatalog] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbatoolsSupportPackage", "Description": "This function creates an extensive debugging package that can help with reproducing and fixing issues.\n\nThe file will be created on the desktop by default and will contain quite a bit of information:\n- OS Information\n- Hardware Information (CPU, Ram, things like that)\n- .NET Information\n- PowerShell Information\n- Your input history\n- The In-Memory message log\n- The In-Memory error log\n- Screenshot of the console buffer (Basically, everything written in your current console, even if you have to scroll upwards to see it.", "Tags": "Debug", "Params": [ [ "Path", "The folder where to place the output xml in.", "", false, "false", "\"$($env:USERPROFILE)\\Desktop\"" ], [ "Variables", "Name of additional variables to attach.\r\nThis allows you to add the content of variables to the support package, if you believe them to be relevant to the case.", "", 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", "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": "", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Creates a package of troubleshooting information that can be used by dbatools to help debug issues.", "Name": "New-DbatoolsSupportPackage", "Links": "https://dbatools.io/New-DbatoolsSupportPackage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbatoolsSupportPackage\nCreates a large support pack in order to help us troubleshoot stuff.", "Syntax": "New-DbatoolsSupportPackage [[-Path] \u003cString\u003e] [[-Variables] \u003cString[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaXESession", "Description": "Creates a new XESession object - for the dogged (very manual, Import-DbaXESession is recommended). See the following for more info:\n\nhttps://docs.microsoft.com/en-us/sql/relational-databases/extended-events/use-the-powershell-provider-for-extended-events", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Name", "The Name of the session to be created.", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new XESession object - for the dogged.", "Name": "New-DbaXESession", "Links": "https://dbatools.io/New-DbaXESession", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$session = New-DbaXESession -SqlInstance sql2017 -Name XeSession_Test\nPS C:\\\u003e $event = $session.AddEvent(\"sqlserver.file_written\")\r\nPS C:\\\u003e $event.AddAction(\"package0.callstack\")\r\nPS C:\\\u003e $session.Create()\nReturns a new XE Session object from sql2017 then adds an event, an action then creates it.", "Syntax": "New-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaXESmartCsvWriter", "Description": "This response type is used to write Extended Events to a CSV file.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "OutputFile", "Specifies the path to the output CSV file.", "", true, "false", "" ], [ "Overwrite", "Specifies whether any existiting file should be overwritten or not.", "", false, "false", "False" ], [ "Event", "Specifies a list of events to be processed (with others being ignored. By default, all events are processed.", "", false, "false", "" ], [ "OutputColumn", "Specifies the list of columns to output from the events. XESmartTarget will capture in memory and write to the target table only the columns (fields or targets) that are present in this list.\nFields and actions are matched in a case-sensitive manner.\nExpression columns are supported. Specify a column with ColumnName AS Expression to add an expression column (Example: Total AS Reads + Writes)", "", false, "false", "" ], [ "Filter", "Specifies a filter expression in the same form as you would use in the WHERE clause of a SQL query.\nExample: duration \u003e 10000 AND cpu_time \u003e 10000", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "This response type is used to write Extended Events to a CSV file.", "Name": "New-DbaXESmartCsvWriter", "Links": "https://dbatools.io/New-DbaXESmartCsvWriter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$columns = \"cpu_time\", \"duration\", \"physical_reads\", \"logical_reads\", \"writes\", \"row_count\"\nPS C:\\\u003e $response = New-DbaXESmartCsvWriter -OutputFile c:\\temp\\workload.csv -OutputColumn $columns -OverWrite -Event \"sql_batch_completed\"\r\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance localhost\\sql2017 -Session \"Profiler Standard\" -Responder $response\nWrites Extended Events to the file \"C:\\temp\\workload.csv\".", "Syntax": "New-DbaXESmartCsvWriter [-OutputFile] \u003cString\u003e [-Overwrite] [[-Event] \u003cString[]\u003e] [[-OutputColumn] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaXESmartEmail", "Description": "This response type can be used to send an email each time an event is captured.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "SmtpServer", "Address of the SMTP server for outgoing mail.", "", true, "false", "" ], [ "Sender", "Sender\u0027s email address.", "", true, "false", "" ], [ "To", "Address of the To recipient(s).", "", true, "false", "" ], [ "Cc", "Address of the Cc recipient(s).", "", false, "false", "" ], [ "Bcc", "Address of the Bcc recipient(s).", "", false, "false", "" ], [ "Credential", "Credential object containing username and password used to authenticate on the SMTP server. When blank, no authentication is performed.", "", false, "false", "" ], [ "Subject", "Subject of the mail message. Accepts placeholders in the text.\nPlaceholders are in the form {PropertyName}, where PropertyName is one of the fields or actions available in the Event object.\nFor instance, a valid Subject in a configuration file looks like this: \"An event of name {Name} occurred at {collection_time}\"", "", true, "false", "" ], [ "Body", "Body of the mail message. The body can be static text or any property taken from the underlying event. See Subject for a description of how placeholders work.", "", true, "false", "" ], [ "Attachment", "Data to attach to the email message. At this time, it can be any of the fields/actions of the underlying event. The data from the field/action is attached to the message as an ASCII stream. A single \r\nattachment is supported.", "", false, "false", "" ], [ "AttachmentFileName", "File name to assign to the attachment.", "", false, "false", "" ], [ "PlainText", "If this switch is enabled, the email will be sent in plain text. By default, HTML formatting is used.", "", false, "false", "" ], [ "Event", "Each Response can be limited to processing specific events, while ignoring all the other ones. When this attribute is omitted, all events are processed.", "", false, "false", "" ], [ "Filter", "You can specify a filter expression by using this attribute. The filter expression is in the same form that you would use in a SQL query. For example, a valid example looks like this: duration \u003e \r\n10000 AND cpu_time \u003e 10000", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "This response type can be used to send an email each time an event is captured.", "Name": "New-DbaXESmartEmail", "Links": "https://dbatools.io/New-DbaXESmartEmail", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e SmtpServer = \"smtp.ad.local\"\r\n\u003e\u003e To = \"admin@ad.local\"\r\n\u003e\u003e Sender = \"reports@ad.local\"\r\n\u003e\u003e Subject = \"Query executed\"\r\n\u003e\u003e Body = \"Query executed at {collection_time}\"\r\n\u003e\u003e Attachment = \"batch_text\"\r\n\u003e\u003e AttachmentFileName = \"query.sql\"\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e $emailresponse = New-DbaXESmartEmail @params\r\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2017 -Session querytracker -Responder $emailresponse\nSends an email each time a querytracker event is captured.", "Syntax": "New-DbaXESmartEmail [-SmtpServer] \u003cString\u003e [-Sender] \u003cString\u003e [-To] \u003cString[]\u003e [[-Cc] \u003cString[]\u003e] [[-Bcc] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Subject] \u003cString\u003e [-Body] \u003cString\u003e [[-Attachment] \u003cString\u003e] [[-AttachmentFileName] \u003cString\u003e] [[-PlainText] \u003cString\u003e] [[-Event] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaXESmartQueryExec", "Description": "This response type executes a T-SQL command against a target database whenever an event is recorded.", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies the name of the database that contains the target table.", "", false, "false", "" ], [ "Query", "The T-SQL command to execute. This string can contain placeholders for properties taken from the events.\nPlaceholders are in the form {PropertyName}, where PropertyName is one of the fields or actions available in the Event object.", "", 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" ], [ "Event", "Each Response can be limited to processing specific events, while ignoring all the other ones. When this attribute is omitted, all events are processed.", "", false, "false", "" ], [ "Filter", "You can specify a filter expression by using this attribute. The filter expression is in the same form that you would use in a SQL query. For example, a valid example looks like this: duration \u003e \r\n10000 AND cpu_time \u003e 10000", "", 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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "This response type executes a T-SQL command against a target database whenever an event is recorded.", "Name": "New-DbaXESmartQueryExec", "Links": "https://dbatools.io/New-DbaXESmartQueryExec", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query \"update table set whatever = 1\"\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\nExecutes a T-SQL command against dbadb on sql2017 whenever a deadlock event is recorded.", "Syntax": "New-DbaXESmartQueryExec [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [[-Query] \u003cString\u003e] [-EnableException] [[-Event] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaXESmartReplay", "Description": "This response type can be used to replay execution related events to a target SQL Server instance. The events that you can replay are of the type sql_batch_completed and rpc_completed: all other events are ignored.", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Name of the initial catalog to connect to. Statements will be replayed by changing database to the same database where the event was originally captured, so this property only controls the initial \r\ndatabase to connect to.", "", false, "false", "" ], [ "Event", "Each Response can be limited to processing specific events, while ignoring all the other ones. When this attribute is omitted, all events are processed.", "", false, "false", "sql_batch_completed" ], [ "Filter", "Specifies a filter expression in the same form as you would use in the WHERE clause of a SQL query.\nExample: duration \u003e 10000 AND cpu_time \u003e 10000", "", false, "false", "" ], [ "DelaySeconds", "Specifies the duration of the delay in seconds.", "", false, "false", "0" ], [ "StopOnError", "If this switch is enabled, the replay will be stopped when the first error is encountered. By default, error messages are piped to the log and console output, and replay proceeds.", "", false, "false", "False" ], [ "ReplayIntervalSeconds", "Specifies the duration of the replay interval in seconds.", "", false, "false", "0" ], [ "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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "This response type can be used to replay execution related events to a target SQL Server instance.", "Name": "New-DbaXESmartReplay", "Links": "https://dbatools.io/New-DbaXESmartReplay", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$response = New-DbaXESmartReplay -SqlInstance sql2017 -Database planning\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2016 -Session loadrelay -Responder $response\nReplays events from sql2016 on sql2017 in the planning database. Returns a PowerShell job object.\nTo see a list of all SmartTarget job objects, use Get-DbaXESmartTarget.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$response = New-DbaXESmartReplay -SqlInstance sql2017 -Database planning\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2017 -Session \u0027Profiler Standard\u0027 -Responder $response -NotAsJob\nReplays events from the \u0027Profiler Standard\u0027 session on sql2016 to sql2017\u0027s planning database. Does not run as a job so you can see the raw output.", "Syntax": "New-DbaXESmartReplay [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [[-Event] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [[-DelaySeconds] \u003cInt32\u003e] [-StopOnError] [[-ReplayIntervalSeconds] \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "New-DbaXESmartTableWriter", "Description": "This response type is used to write Extended Events to a database table. The events are temporarily stored in memory before being written to the database at regular intervals.\n\nThe target table can be created manually upfront or you can let the TableAppenderResponse create a target table based on the fields and actions available in the events captured.\n\nThe columns of the target table and the fields/actions of the events are mapped by name (case-sensitive).", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies the name of the database that contains the target table.", "", true, "false", "" ], [ "Table", "Specifies the name of the target table.", "", true, "false", "" ], [ "AutoCreateTargetTable", "If this switch is enabled, XESmartTarget will infer the definition of the target table from the columns captured in the Extended Events session.\nIf the target table already exists, it will not be recreated.", "", false, "false", "False" ], [ "UploadIntervalSeconds", "Specifies the number of seconds XESmartTarget will keep the events in memory before dumping them to the target table. The default is 10 seconds.", "", false, "false", "10" ], [ "Event", "Specifies a list of events to be processed (with others being ignored. By default, all events are processed.", "", false, "false", "" ], [ "OutputColumn", "Specifies the list of columns to output from the events. XESmartTarget will capture in memory and write to the target table only the columns (fields or targets) that are present in this list.\nFields and actions are matched in a case-sensitive manner.\nExpression columns are supported. Specify a column with ColumnName AS Expression to add an expression column (Example: Total AS Reads + Writes)", "", false, "false", "" ], [ "Filter", "Specifies a filter expression in the same form as you would use in the WHERE clause of a SQL query.\nExample: duration \u003e 10000 AND cpu_time \u003e 10000", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "This response type is used to write Extended Events to a database table.", "Name": "New-DbaXESmartTableWriter", "Links": "https://dbatools.io/New-DbaXESmartTableWriter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$columns = \"cpu_time\", \"duration\", \"physical_reads\", \"logical_reads\", \"writes\", \"row_count\", \"batch_text\"\nPS C:\\\u003e $response = New-DbaXESmartTableWriter -SqlInstance sql2017 -Database dbadb -Table deadlocktracker -OutputColumn $columns -Filter \"duration \u003e 10000\"\r\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\nWrites Extended Events to the deadlocktracker table in dbadb on sql2017.", "Syntax": "New-DbaXESmartTableWriter [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \u003cString\u003e [-Table] \u003cString\u003e [-AutoCreateTargetTable] [[-UploadIntervalSeconds] \u003cInt32\u003e] [[-Event] \u003cString[]\u003e] [[-OutputColumn] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Publish-DbaDacPackage", "Description": "Deploying a dacpac uses the DacFx which historically needed to be installed on a machine prior to use. In 2016 the DacFx was supplied by Microsoft as a nuget package (Microsoft.Data.Tools.MSBuild) and this uses that nuget package.", "Tags": [ "Migration", "Database", "Dacpac" ], "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)", "Credential", false, "false", "" ], [ "Path", "Specifies the filesystem path to the DACPAC", "", true, "true (ByPropertyName)", "" ], [ "PublishXml", "Specifies the publish profile which will include options and sqlCmdVariables.", "", true, "false", "" ], [ "Database", "Specifies the name of the database being published.", "", true, "true (ByPropertyName)", "" ], [ "ConnectionString", "Specifies the connection string to the database you are upgrading. This is not required if SqlInstance is specified.", "", false, "false", "" ], [ "GenerateDeploymentScript", "If this switch is enabled, the publish script will be generated.", "", false, "false", "False" ], [ "GenerateDeploymentReport", "If this switch is enabled, the publish XML report will be generated.", "", false, "false", "False" ], [ "ScriptOnly", "If this switch is enabled, only the change scripts will be generated.", "", false, "false", "False" ], [ "Type", "Selecting the type of the export: Dacpac (default) or Bacpac.", "", false, "false", "Dacpac" ], [ "OutputPath", "Specifies the filesystem path (directory) where output files will be generated.", "", false, "false", "\"$home\\Documents\"" ], [ "IncludeSqlCmdVars", "If this switch is enabled, SqlCmdVars in publish.xml will have their values overwritten.", "", false, "false", "False" ], [ "DacOption", "Export options for a corresponding export type. Can be created by New-DbaDacOption -Type Dacpac | Bacpac", "Option", 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" ], [ "DacFxPath", "Path to the dac dll. If this is ommited, then the version of dac dll which is packaged with dbatools is used.", "", false, "false", "" ] ], "Alias": "Publish-DbaDacpac", "Author": "Richie lee (@richiebzzzt)", "Synopsis": "The Publish-DbaDacPackage command takes a dacpac which is the output from an SSDT project and publishes it to a database. Changing the schema to match the dacpac and also to run any scripts in the dacpac (pre/post deploy scripts).", "Name": "Publish-DbaDacPackage", "Links": "https://dbatools.io/Publish-DbaDacPackage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$options = New-DbaDacOption -Type Dacpac -Action Publish\nPS C:\\\u003e $options.DeployOptions.DropObjectsNotInSource = $true\r\nPS C:\\\u003e Publish-DbaDacPackage -SqlInstance sql2016 -Database DB1 -DacOption $options -Path c:\\temp\\db.dacpac\nUses DacOption object to set Deployment Options and updates DB1 database on sql2016 from the db.dacpac dacpac file, dropping objects that are missing from source\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003ePublish-DbaDacPackage -SqlInstance sql2017 -Database WideWorldImporters -Path C:\\temp\\sql2016-WideWorldImporters.dacpac -PublishXml C:\\temp\\sql2016-WideWorldImporters-publish.xml\nUpdates WideWorldImporters on sql2017 from the sql2016-WideWorldImporters.dacpac using the sql2016-WideWorldImporters-publish.xml publish profile\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eNew-DbaDacProfile -SqlInstance sql2016 -Database db2 -Path C:\\temp\nPS C:\\\u003e Export-DbaDacPackage -SqlInstance sql2016 -Database db2 | Publish-DbaDacPackage -PublishXml C:\\temp\\sql2016-db2-publish.xml -Database db1, db2 -SqlInstance sql2017\nCreates a publish profile at C:\\temp\\sql2016-db2-publish.xml, exports the .dacpac to $home\\Documents\\sql2016-db2.dacpac\r\nthen publishes it to the sql2017 server database db2\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$loc = \"C:\\Users\\bob\\source\\repos\\Microsoft.Data.Tools.Msbuild\\lib\\net46\\Microsoft.SqlServer.Dac.dll\"\nPS C:\\\u003e Publish-DbaDacPackage -SqlInstance \"local\" -Database WideWorldImporters -Path C:\\temp\\WideWorldImporters.dacpac -PublishXml C:\\temp\\WideWorldImporters.publish.xml -DacFxPath $loc\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003ePublish-DbaDacPackage -SqlInstance sql2017 -Database WideWorldImporters -Path C:\\temp\\sql2016-WideWorldImporters.dacpac -PublishXml C:\\temp\\sql2016-WideWorldImporters-publish.xml \r\n-GenerateDeploymentScript -ScriptOnly\nDoes not deploy the changes, but will generate the deployment script that would be executed against WideWorldImporters.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003ePublish-DbaDacPackage -SqlInstance sql2017 -Database WideWorldImporters -Path C:\\temp\\sql2016-WideWorldImporters.dacpac -PublishXml C:\\temp\\sql2016-WideWorldImporters-publish.xml \r\n-GenerateDeploymentReport -ScriptOnly\nDoes not deploy the changes, but will generate the deployment report that would be executed against WideWorldImporters.", "Syntax": "Publish-DbaDacPackage [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] -Path \u003cString\u003e -Database \u003cString[]\u003e [-ConnectionString \u003cString[]\u003e] [-ScriptOnly] [-Type \u003cString\u003e] [-OutputPath \u003cString\u003e] [-IncludeSqlCmdVars] [-DacOption \u003cObject\u003e] [-EnableException] [-DacFxPath \u003cString\u003e] [\u003cCommonParameters\u003e]\nPublish-DbaDacPackage [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] -Path \u003cString\u003e -PublishXml \u003cString\u003e -Database \u003cString[]\u003e [-ConnectionString \u003cString[]\u003e] [-GenerateDeploymentScript] [-GenerateDeploymentReport] [-ScriptOnly] [-Type \u003cString\u003e] [-OutputPath \u003cString\u003e] [-IncludeSqlCmdVars] [-EnableException] [-DacFxPath \u003cString\u003e] [\u003cCommonParameters\u003e]" }, { "CommandName": "Read-DbaAuditFile", "Description": "Read Audit details from *.sqlaudit files.", "Tags": [ "ExtendedEvent", "Audit" ], "Params": [ [ "Path", "The path to the *.sqlaudit file. This is relative to the computer executing the command. UNC paths are supported.", "FullName", true, "true (ByValue)", "" ], [ "Exact", "If this switch is enabled, only an exact search will be used for the Path. By default, this command will add a wildcard to the Path because Eventing uses the file name as a template and adds \r\ncharacters.", "", false, "false", "False" ], [ "Raw", "If this switch is enabled, the Microsoft.SqlServer.XEvent.Linq.PublishedEvent enumeration object will be returned.", "", 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": "Read Audit details from *.sqlaudit files.", "Name": "Read-DbaAuditFile", "Links": "https://dbatools.io/Read-DbaAuditFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRead-DbaAuditFile -Path C:\\temp\\logins.sqlaudit\nReturns events from C:\\temp\\logins.sqlaudit.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-ChildItem C:\\temp\\audit\\*.sqlaudit | Read-DbaAuditFile\nReturns events from all .sqlaudit files in C:\\temp\\audit.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaServerAudit -SqlInstance sql2014 -Audit LoginTracker | Read-DbaAuditFile\nReads remote Audit details by accessing the file over the admin UNC share.", "Syntax": "Read-DbaAuditFile [-Path] \u003cObject[]\u003e [-Exact] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Read-DbaBackupHeader", "Description": "Reads full, differential and transaction log backups. An online SQL Server is required to parse the backup files and the path specified must be relative to that SQL Server.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "Path to SQL Server backup file. This can be a full, differential or log backup file. Accepts valid filesystem paths and URLs.", "", true, "true (ByValue)", "" ], [ "Simple", "If this switch is enabled, fewer columns are returned, giving an easy overview.", "", false, "false", "False" ], [ "FileList", "If this switch is enabled, detailed information about the files within the backup is returned.", "", false, "false", "False" ], [ "AzureCredential", "Name of the SQL Server credential that should be used for Azure storage access.", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because \r\nit 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Reads and displays detailed information about a SQL Server backup.", "Name": "Read-DbaBackupHeader", "Links": "https://dbatools.io/Read-DbaBackupHeader", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance sql2016 -Path S:\\backups\\mydb\\mydb.bak\nLogs into sql2016 using Windows authentication and reads the local file on sql2016, S:\\backups\\mydb\\mydb.bak.\nIf you are running this command on a workstation and connecting remotely, remember that sql2016 cannot access files on your own workstation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance sql2016 -Path \\\\nas\\sql\\backups\\mydb\\mydb.bak, \\\\nas\\sql\\backups\\otherdb\\otherdb.bak\nLogs into sql2016 and reads two backup files - mydb.bak and otherdb.bak. The SQL Server service account must have rights to read this file.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak -Simple\nLogs into the local workstation (or computer) and shows simplified output about C:\\temp\\myfile.bak. The SQL Server service account must have rights to read this file.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$backupinfo = Read-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak\nPS C:\\\u003e $backupinfo.FileList\nDisplays detailed information about each of the datafiles contained in the backupset.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak -FileList\nAlso returns detailed information about each of the datafiles contained in the backupset.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e\"C:\\temp\\myfile.bak\", \"\\backupserver\\backups\\myotherfile.bak\" | Read-DbaBackupHeader -SqlInstance sql2016\nSimilar to running Read-DbaBackupHeader -SqlInstance sql2016 -Path \"C:\\temp\\myfile.bak\", \"\\backupserver\\backups\\myotherfile.bak\"\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eGet-ChildItem \\\\nas\\sql\\*.bak | Read-DbaBackupHeader -SqlInstance sql2016\nGets a list of all .bak files on the \\\\nas\\sql share and reads the headers using the server named \"sql2016\". This means that the server, sql2016, must have read access to the \\\\nas\\sql share.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eRead-DbaBackupHeader -Path https://dbatoolsaz.blob.core.windows.net/azbackups/restoretime/restoretime_201705131850.bak -AzureCredential AzureBackupUser\nGets the backup header information from the SQL Server backup file stored at https://dbatoolsaz.blob.core.windows.net/azbackups/restoretime/restoretime_201705131850.bak on Azure", "Syntax": "Read-DbaBackupHeader [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cObject[]\u003e [-Simple] [-FileList] [[-AzureCredential] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Read-DbaTraceFile", "Description": "Using the fn_trace_gettable function, a trace file is read and returned as a PowerShell object\n\nThis function returns the whole of the trace file. The information is presented in the format that the trace subsystem uses.", "Tags": [ "Security", "Trace" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByPropertyName)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "true (ByPropertyName)", "" ], [ "Path", "Path to the trace file. This path is relative to the SQL Server instance.", "", false, "true (ByPropertyName)", "" ], [ "Database", "Search for results only with specific DatabaseName. Uses IN for comparisons.", "", false, "false", "" ], [ "Login", "Search for results only with specific Logins. Uses IN for comparisons.", "", false, "false", "" ], [ "Spid", "Search for results only with specific Spids. Uses IN for comparisons.", "", false, "false", "" ], [ "EventClass", "Search for results only with specific EventClasses. Uses IN for comparisons.", "", false, "false", "" ], [ "ObjectType", "Search for results only with specific ObjectTypes. Uses IN for comparisons.", "", false, "false", "" ], [ "ErrorId", "Search for results only with specific Errors. Filters \u0027Error in ($ErrorId)\u0027 Uses IN for comparisons.", "", false, "false", "" ], [ "EventSequence", "Search for results only with specific EventSequences. Uses IN for comparisons.", "", false, "false", "" ], [ "TextData", "Search for results only with specific TextData. Uses LIKE for comparisons.", "", false, "false", "" ], [ "ApplicationName", "Search for results only with specific ApplicationNames. Uses LIKE for comparisons.", "", false, "false", "" ], [ "ObjectName", "Search for results only with specific ObjectNames. Uses LIKE for comparisons.", "", false, "false", "" ], [ "Where", "Custom where clause - use without the word \"WHERE\". Here are the available columns:\nTextData\r\nBinaryData\r\nDatabaseID\r\nTransactionID\r\nLineNumber\r\nNTUserName\r\nNTDomainName\r\nHostName\r\nClientProcessID\r\nApplicationName\r\nLoginName\r\nSPID\r\nDuration\r\nStartTime\r\nEndTime\r\nReads\r\nWrites\r\nCPU\r\nPermissions\r\nSeverity\r\nEventSubClass\r\nObjectID\r\nSuccess\r\nIndexID\r\nIntegerData\r\nServerName\r\nEventClass\r\nObjectType\r\nNestLevel\r\nState\r\nError\r\nMode\r\nHandle\r\nObjectName\r\nDatabaseName\r\nFileName\r\nOwnerName\r\nRoleName\r\nTargetUserName\r\nDBUserName\r\nLoginSid\r\nTargetLoginName\r\nTargetLoginSid\r\nColumnPermissions\r\nLinkedServerName\r\nProviderName\r\nMethodName\r\nRowCounts\r\nRequestID\r\nXactSequence\r\nEventSequence\r\nBigintData1\r\nBigintData2\r\nGUID\r\nIntegerData2\r\nObjectID2\r\nType\r\nOwnerID\r\nParentName\r\nIsSystem\r\nOffset\r\nSourceDatabaseID\r\nSqlHandle\r\nSessionLoginName\r\nPlanHandle\r\nGroupID", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Reads SQL Server trace files", "Name": "Read-DbaTraceFile", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRead-DbaTraceFile -SqlInstance sql2016 -Database master, tempdb -Path C:\\traces\\big.trc\nReads the tracefile C:\\traces\\big.trc, stored on the sql2016 sql server. Filters only results that have master or tempdb as the DatabaseName.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRead-DbaTraceFile -SqlInstance sql2016 -Database master, tempdb -Path C:\\traces\\big.trc -TextData \u0027EXEC SP_PROCOPTION\u0027\nReads the tracefile C:\\traces\\big.trc, stored on the sql2016 sql server.\r\nFilters only results that have master or tempdb as the DatabaseName and that have \u0027EXEC SP_PROCOPTION\u0027 somewhere in the text.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRead-DbaTraceFile -SqlInstance sql2016 -Path C:\\traces\\big.trc -Where \"LinkedServerName = \u0027myls\u0027 and StartTime \u003e \u00275/30/2017 4:27:52 PM\u0027\"\nReads the tracefile C:\\traces\\big.trc, stored on the sql2016 sql server.\r\nFilters only results where LinkServerName = myls and StartTime is greater than \u00275/30/2017 4:27:52 PM\u0027.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2014 | Read-DbaTraceFile\nReads every trace file on sql2014", "Syntax": "Read-DbaTraceFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Path \u003cString[]\u003e] [-Database \u003cString[]\u003e] [-Login \u003cString[]\u003e] [-Spid \u003cInt32[]\u003e] [-EventClass \u003cString[]\u003e] [-ObjectType \u003cString[]\u003e] [-ErrorId \u003cInt32[]\u003e] [-EventSequence \u003cInt32[]\u003e] [-TextData \u003cString[]\u003e] [-ApplicationName \u003cString[]\u003e] [-ObjectName \u003cString[]\u003e] [-Where \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Read-DbaTransactionLog", "Description": "Using the fn_dblog function, the live transaction log is read and returned as a PowerShell object\n\nThis function returns the whole of the log. The information is presented in the format that the logging subsystem uses.\n\nA soft limit of 0.5GB of log as been implemented. This is based on testing. This limit can be overridden\nat the users request, but please be aware that this may have an impact on your target databases and on the\nsystem running this function", "Tags": [ "Database", "Log", "LogFile" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "A credential to use to connect to the SQL Instance rather than using Windows Authentication", "", false, "false", "" ], [ "Database", "Database to read the transaction log of", "", true, "false", "" ], [ "IgnoreLimit", "Switch to indicate that you wish to bypass the recommended limits of the function", "", false, "false", "False" ], [ "RowLimit", "Will limit the number of rows returned from the transaction log", "", false, "false", "0" ], [ "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": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Reads the live Transaction log from specified SQL Server Database", "Name": "Read-DbaTransactionLog", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase\nWill read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell object $Log\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase -IgnoreLimit\nWill read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell object $Log, ignoring the recommendation of not returning more that 0.5GB of log", "Syntax": "Read-DbaTransactionLog [-SqlInstance] \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject\u003e [-IgnoreLimit] [-RowLimit \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Read-DbaXEFile", "Description": "Read XEvents from a *.xel or *.xem file.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "Path", "The path to the *.xem or *.xem file. This is relative to the computer executing the command. UNC paths are supported.", "FullName", true, "true (ByValue)", "" ], [ "Exact", "If this switch is enabled, only an exact search will be used for the Path. By default, this command will add a wildcard to the Path because Eventing uses the file name as a template and adds \r\ncharacters.", "", false, "false", "False" ], [ "Raw", "If this switch is enabled, the Microsoft.SqlServer.XEvent.Linq.PublishedEvent enumeration object will be returned.", "", 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": "Read-DbaXEventFile", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Read XEvents from a *.xel or *.xem file.", "Name": "Read-DbaXEFile", "Links": "https://dbatools.io/Read-DbaXEFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\deadocks.xel\nReturns events from C:\\temp\\deadocks.xel.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-ChildItem C:\\temp\\xe\\*.xel | Read-DbaXEFile\nReturns events from all .xel files in C:\\temp\\xe.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2014 -Session deadlocks | Read-DbaXEFile\nReads remote XEvents by accessing the file over the admin UNC share.", "Syntax": "Read-DbaXEFile [-Path] \u003cObject[]\u003e [-Exact] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Register-DbatoolsConfig", "Description": "Registers an existing configuration object in registry.\nThis allows simple persisting of settings across powershell consoles.\nIt also can be used to generate a registry template, which can then be used to create policies.", "Tags": [ "Config", "Module" ], "Params": [ [ "Config", "The configuration object to write to registry. Can be retrieved using Get-DbatoolsConfig.", "", false, "true (ByValue)", "" ], [ "FullName", "The full name of the setting to be written to registry.", "", false, "true (ByValue)", "" ], [ "Module", "The name of the module, whose settings should be written to registry.", "", true, "false", "" ], [ "Name", "Default: \"*\"\r\nUsed in conjunction with the -Module parameter to restrict the number of configuration items written to registry.", "", false, "false", "*" ], [ "Scope", "Default: UserDefault\r\nWho will be affected by this export how? Current user or all? Default setting or enforced?\r\nLegal values: UserDefault, UserMandatory, SystemDefault, SystemMandatory", "", false, "false", "UserDefault" ], [ "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": "Register-DbaConfig", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Registers an existing configuration object in registry.", "Name": "Register-DbatoolsConfig", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbatoolsConfig message.* | Register-DbatoolsConfig\nRetrieves all configuration items that that start with message. and registers them in registry for the current user.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRegister-DbatoolsConfig -FullName \"developer.mode.enable\" -Scope SystemDefault\nRetrieves the configuration item \"developer.mode.enable\" and registers it in registry as the default setting for all users on this machine.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRegister-DbatoolsConfig -Module message -Scope SystemMandatory\nRetrieves all configuration items of the module MyModule, then registers them in registry to enforce them for all users on the current system.", "Syntax": "Register-DbatoolsConfig [[-Config] \u003cConfig[]\u003e] [[-FullName] \u003cString[]\u003e] [-Scope {UserDefault | UserMandatory | SystemDefault | SystemMandatory}] [-EnableException] [\u003cCommonParameters\u003e]\nRegister-DbatoolsConfig [-Module] \u003cString\u003e [[-Name] \u003cString\u003e] [-Scope {UserDefault | UserMandatory | SystemDefault | SystemMandatory}] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgDatabase", "Description": "Removes a database from an availability group on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database or databases to remove.", "", false, "false", "" ], [ "AvailabilityGroup", "Only remove databases from specific availability groups.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", 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" ], [ "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": "Removes a database from an availability group on a SQL Server instance.", "Name": "Remove-DbaAgDatabase", "Links": "https://dbatools.io/Remove-DbaAgDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgDatabase -SqlInstance sqlserver2012 -AvailabilityGroup ag1, ag2 -Confirm:$false\nRemoves the ag1 and ag2 availability groups on sqlserver2012. Does not prompt for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2012 -AvailabilityGroup availabilitygroup1 | Remove-DbaAgDatabase\nRemoves the availability groups returned from the Get-DbaAvailabilityGroup function. Prompts for confirmation.", "Syntax": "Remove-DbaAgDatabase [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgentJob", "Description": "Remove-DbaAgentJob removes a job in the SQL Server Agent.", "Tags": [ "Agent", "Job" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server 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", "" ], [ "Job", "The name of the job. Can be null if the the job id is being used.", "", false, "false", "" ], [ "KeepHistory", "Specifies to keep the history for the job. By default history is deleted.", "", false, "false", "False" ], [ "KeepUnusedSchedule", "Specifies to keep the schedules attached to this job if they are not attached to any other job.\r\nBy default the unused schedule is deleted.", "", false, "false", "False" ], [ "Mode", "Default: Strict\r\nHow strict does the command take lesser issues?\r\nStrict: Interrupt if the job specified doesn\u0027t exist.\r\nLazy: Silently skip over jobs that don\u0027t exist.", "", false, "false", "(Get-DbatoolsConfigValue -FullName \u0027message.mode.default\u0027 -Fallback \"Strict\")" ], [ "InputObject", "Accepts piped input from Get-DbaAgentJob", "", 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.", "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": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Remove-DbaAgentJob removes a job.", "Name": "Remove-DbaAgentJob", "Links": "https://dbatools.io/Remove-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgentJob -SqlInstance sql1 -Job Job1\nRemoves the job from the instance with the name Job1\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGetDbaAgentJob -SqlInstance sql1 -Job Job1 | Remove-DbaAgentJob -KeepHistory\nRemoves teh job but keeps the history\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaAgentJob -SqlInstance sql1 -Job Job1 -KeepUnusedSchedule\nRemoves the job but keeps the unused schedules\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRemove-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job Job1\nRemoves the job from multiple servers", "Syntax": "Remove-DbaAgentJob [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [-KeepHistory] [-KeepUnusedSchedule] [[-Mode] {Strict | Lazy | Report}] [[-InputObject] \u003cJob[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgentJobCategory", "Description": "Remove-DbaAgentJobCategory makes it possible to remove a job category.\nBe assured that the category you want to remove is not used with other jobs. If another job uses this category it will be get the category [Uncategorized (Local)].", "Tags": [ "Agent", "Job", "JobCategory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Category", "The name of the category", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Remove-DbaAgentJobCategory removes a job category.", "Name": "Remove-DbaAgentJobCategory", "Links": "https://dbatools.io/Remove-DbaAgentJobCategory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 1\u0027\nRemove the job category Category 1 from the instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaAgentJobCategory -SqlInstance sql1 -Category Category1, Category2, Category3\nRemove multiple job categories from the instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaAgentJobCategory -SqlInstance sql1, sql2, sql3 -Category Category1, Category2, Category3\nRemove multiple job categories from the multiple instances.", "Syntax": "Remove-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgentJobStep", "Description": "Removes a job step from a SQL Server Agent job.", "Tags": [ "Agent", "Job", "JobStep" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "Job", "The name of the job.", "", true, "false", "" ], [ "StepName", "The name of the job step.", "", true, "false", "" ], [ "Mode", "Default: Strict\r\nHow strict does the command take lesser issues?\r\nStrict: Interrupt if the configuration already has the same value as the one specified.\r\nLazy: Silently skip over instances that already have this configuration at the specified value.", "", false, "false", "(Get-DbatoolsConfigValue -Name \u0027message.mode.default\u0027 -Fallback \"Strict\")" ], [ "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", "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": "", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Removes a step from the specified SQL Agent job.", "Name": "Remove-DbaAgentJobStep", "Links": "https://dbatools.io/Remove-DbaAgentJobStep", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1\nRemove \u0027Step1\u0027 from job \u0027Job1\u0027 on sql1.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaAgentJobStep -SqlInstance sql1 -Job Job1, Job2, Job3 -StepName Step1\nRemove the job step from multiple jobs.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1 -StepName Step1\nRemove the job step from the job on multiple servers.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003esql1, sql2, sql3 | Remove-DbaAgentJobStep -Job Job1 -StepName Step1\nRemove the job step from the job on multiple servers using pipeline.", "Syntax": "Remove-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e [-StepName] \u003cString\u003e [[-Mode] {Strict | Lazy | Report}] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgentSchedule", "Description": "Remove-DbaAgentJobSchedule removes a job in the SQL Server Agent.", "Tags": [ "Agent", "Job", "Schedule" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Schedule", "The name of the job schedule.", "Schedules", true, "false", "" ], [ "InputObject", "A collection of schedule (such as returned by Get-DbaAgentSchedule), to be removed.", "", 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" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.\r\nIt will also remove the any present schedules with the same name for the specific job.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Remove-DbaAgentJobSchedule removes a job schedule.", "Name": "Remove-DbaAgentSchedule", "Links": "https://dbatools.io/Remove-DbaAgentJobSchedule", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1 -Schedule weekly\nRemove the schedule weekly\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1 -Schedule weekly -Force\nRemove the schedule weekly from the job even if the schedule is being used by another job.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1 -Schedule daily, weekly\nRemove multiple schedule\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -Schedule daily, weekly\nRemove the schedule on multiple servers for multiple schedules\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003esql1, sql2, sql3 | Remove-DbaAgentSchedule -Schedule daily, weekly\nRemove the schedule on multiple servers using pipe line\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance sql1 -Schedule sched1, sched2, sched3 | Remove-DbaAgentSchedule\nRemove the schedules using a pipeline", "Syntax": "Remove-DbaAgentSchedule -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Schedule \u003cObject[]\u003e [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaAgentSchedule [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cScheduleBase[]\u003e [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgListener", "Description": "Removes a listener from an availability group on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Listener", "The listener or listeners to remove.", "", false, "false", "" ], [ "AvailabilityGroup", "Only remove listeners from specific availability groups.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaListener", "", 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" ], [ "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": "Removes a listener from an availability group on a SQL Server instance.", "Name": "Remove-DbaAgListener", "Links": "https://dbatools.io/Remove-DbaAgListener", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgListener -SqlInstance sqlserver2012 -AvailabilityGroup ag1, ag2 -Confirm:$false\nRemoves the ag1 and ag2 availability groups on sqlserver2012. Does not prompt for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2012 -AvailabilityGroup availabilitygroup1 | Remove-DbaAgListener\nRemoves the listeners returned from the Get-DbaAvailabilityGroup function. Prompts for confirmation.", "Syntax": "Remove-DbaAgListener [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Listener] \u003cString[]\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityGroupListener[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAgReplica", "Description": "Removes availability group replicas from availability groups.", "Tags": [ "AG", "HA", "AvailabilityGroup", "Replica" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The specific availability group to query.", "", false, "false", "" ], [ "Replica", "The replica to remove.", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaAgReplica.", "", 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" ], [ "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": "Removes availability group replicas from availability groups.", "Name": "Remove-DbaAgReplica", "Links": "https://dbatools.io/Remove-DbaAgReplica", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAgReplica -SqlInstance sql2017a -AvailabilityGroup SharePoint -Replica sp1\nRemoves the sp1 replica from the SharePoint ag on sql2017a. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaAgReplica -SqlInstance sql2017a | Select-Object *\nReturns full object properties on all availability group replicas found on sql2017a", "Syntax": "Remove-DbaAgReplica [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-Replica] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityReplica[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaAvailabilityGroup", "Description": "Removes availability groups on a SQL Server instance.\n\nIf possible, remove the availability group only while connected to the server instance that hosts the primary replica.\nWhen the availability group is dropped from the primary replica, changes are allowed in the former primary databases (without high availability protection).\nDeleting an availability group from a secondary replica leaves the primary replica in the RESTORING state, and changes are not allowed on the databases.\n\nAvoid dropping an availability group when the Windows Server Failover Clustering (WSFC) cluster has no quorum.\nIf you must drop an availability group while the cluster lacks quorum, the metadata availability group that is stored in the cluster is not removed.\nAfter the cluster regains quorum, you will need to drop the availability group again to remove it from the WSFC cluster.\n\nFor more information: https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-availability-group-transact-sql", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "Only remove specific availability groups.", "", false, "false", "" ], [ "AllAvailabilityGroups", "Remove all availability groups on an instance.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup.", "", 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" ], [ "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": "Removes availability groups on a SQL Server instance.", "Name": "Remove-DbaAvailabilityGroup", "Links": "https://dbatools.io/Remove-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaAvailabilityGroup -SqlInstance sqlserver2012 -AllAvailabilityGroups\nRemoves all availability groups on the sqlserver2014 instance. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaAvailabilityGroup -SqlInstance sqlserver2012 -AvailabilityGroup ag1, ag2 -Confirm:$false\nRemoves the ag1 and ag2 availability groups on sqlserver2012. Does not prompt for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2012 -AvailabilityGroup availabilitygroup1 | Remove-DbaAvailabilityGroup\nRemoves the availability groups returned from the Get-DbaAvailabilityGroup function. Prompts for confirmation.", "Syntax": "Remove-DbaAvailabilityGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [-AllAvailabilityGroups] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaBackup", "Description": "Removes SQL Server backups from disk.\n\nProvides all of the same functionality for removing SQL backups from disk as a standard maintenance plan would.\n\nAs an addition you have the ability to check the Archive bit on files before deletion. This will allow you to ensure backups have been archived to your archive location before removal.\n\nAlso included is the ability to remove empty folders as part of this cleanup activity.", "Tags": [ "Storage", "DisasterRecovery", "Backup" ], "Params": [ [ "Path", "Specifies the name of the base level folder to search for backup files. Deletion of backup files will be recursive from this location.", "BackupFolder", true, "false", "" ], [ "BackupFileExtension", "Specifies the filename extension of the backup files you wish to remove (typically \u0027bak\u0027, \u0027trn\u0027 or \u0027log\u0027). Do not include the period.", "", true, "false", "" ], [ "RetentionPeriod", "Specifies the retention period for backup files. Correct format is ##U.\n## is the retention value and must be an integer value\r\nU signifies the units where the valid units are:\r\nh = hours\r\nd = days\r\nw = weeks\r\nm = months\nFormatting Examples:\r\n\u002748h\u0027 = 48 hours\r\n\u00277d\u0027 = 7 days\r\n\u00274w\u0027 = 4 weeks\r\n\u00271m\u0027 = 1 month", "", true, "false", "" ], [ "CheckArchiveBit", "If this switch is enabled, the filesystem Archive bit is checked before deletion. If this bit is set (which translates to \"it has not been backed up to another location yet\", the file won\u0027t be \r\ndeleted.", "", false, "false", "False" ], [ "RemoveEmptyBackupFolder", "If this switch is enabled, empty folders will be removed after the cleanup process is complete.", "", 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", "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.i", "cf", false, "false", "" ] ], "Alias": "", "Author": "Chris Sommer (@cjsommer), www.cjsommer.com", "Synopsis": "Removes SQL Server backups from disk.", "Name": "Remove-DbaBackup", "Links": "https://dbatools.io/Remove-DbaBackup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\SQL Backup\\\u0027 -BackupFileExtension trn -RetentionPeriod 48h\n\u0027*.trn\u0027 files in \u0027C:\\MSSQL\\SQL Backup\\\u0027 and all subdirectories that are more than 48 hours old will be removed.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\SQL Backup\\\u0027 -BackupFileExtension trn -RetentionPeriod 48h -WhatIf\nSame as example #1, but doesn\u0027t actually remove any files. The function will instead show you what would be done.\r\nThis is useful when first experimenting with using the function.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\Backup\\\u0027 -BackupFileExtension bak -RetentionPeriod 7d -CheckArchiveBit\n\u0027*.bak\u0027 files in \u0027C:\\MSSQL\\Backup\\\u0027 and all subdirectories that are more than 7 days old will be removed, but only if the files have been backed up to another location as verified by checking the \r\nArchive bit.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\Backup\\\u0027 -BackupFileExtension bak -RetentionPeriod 1w -RemoveEmptyBackupFolder\n\u0027*.bak\u0027 files in \u0027C:\\MSSQL\\Backup\\\u0027 and all subdirectories that are more than 1 week old will be removed. Any folders left empty will be removed as well.", "Syntax": "Remove-DbaBackup [-Path] \u003cString\u003e [-BackupFileExtension] \u003cString\u003e [-RetentionPeriod] \u003cString\u003e [-CheckArchiveBit] [-RemoveEmptyBackupFolder] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaClientAlias", "Description": "Removes a sql alias for the specified server by altering HKLM:\\SOFTWARE\\Microsoft\\MSSQLServer\\Client - mimics cliconfg.exe.", "Tags": "Alias", "Params": [ [ "ComputerName", "The target computer where the alias will be created.", "", false, "true (ByPropertyName)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to remote computers using alternative credentials", "", false, "false", "" ], [ "Alias", "The alias or array of aliases to be deleted", "AliasName", true, "true (ByPropertyName)", "" ], [ "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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes a sql alias for the specified server - mimics cliconfg.exe", "Name": "Remove-DbaClientAlias", "Links": "https://dbatools.io/Remove-DbaClientAlias", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaClientAlias -ComputerName workstationx -Alias sqlps\nRemoves the sqlps SQL client alias on workstationx\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaClientAlias | Remove-DbaClientAlias\nRemoves all SQL Server client aliases on the local computer", "Syntax": "Remove-DbaClientAlias [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Alias] \u003cString[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaCmConnection", "Description": "Removes connection objects from the connection cache used for remote computer management.", "Tags": [ "ComputerManagement", "CIM" ], "Params": [ [ "ComputerName", "The target computer. Accepts both text as well as the output of Get-DbaCmConnection.", "", 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", "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": "", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Removes connection objects from the connection cache used for remote computer management.", "Name": "Remove-DbaCmConnection", "Links": "https://dbatools.io/Remove-DbaCmConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaCmConnection -ComputerName sql2014\nRemoves the cached connection to the server sql2014 from the cache.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmConnection | Remove-DbaCmConnection\nClears the entire connection cache.", "Syntax": "Remove-DbaCmConnection [-ComputerName] \u003cDbaCmConnectionParameter[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaCmsRegServer", "Description": "Removes registered servers found in SQL Server Central Management Server (CMS).", "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", "" ], [ "Name", "Specifies one or more names to include. Name is the visible name in SSMS CMS interface (labeled Registered Server Name)", "", false, "false", "" ], [ "ServerName", "Specifies one or more server names to include. Server Name is the actual instance name (labeled Server Name)", "", false, "false", "" ], [ "Group", "Specifies one or more groups to include from SQL Server Central Management Server.", "", false, "false", "" ], [ "InputObject", "Allows results from Get-DbaCmsRegServer to be piped in", "", false, "true (ByValue)", "" ], [ "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" ], [ "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": "Remove-DbaRegisteredServer", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes registered servers found in SQL Server Central Management Server (CMS).", "Name": "Remove-DbaCmsRegServer", "Links": "https://dbatools.io/Remove-DbaCmsRegServer", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaCmsRegServer -SqlInstance sql2012 -Group HR, Accounting\nRemoves all servers from the HR and Accounting groups on sql2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaCmsRegServer -SqlInstance sql2012 -Group HR\\Development\nRemoves all servers from the HR and sub-group Development from the CMS on sql2012.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaCmsRegServer -SqlInstance sql2012 -Confirm:$false\nRemoves all registered servers on sql2012 and turns off all prompting", "Syntax": "Remove-DbaCmsRegServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-Group] \u003cString[]\u003e] [[-InputObject] \u003cRegisteredServer[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaCmsRegServerGroup", "Description": "Returns an array of Server Groups found in the CMS.", "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", "" ], [ "Name", "Specifies one or more groups to include from SQL Server Central Management Server.", "Group", false, "false", "" ], [ "InputObject", "Allows results from Get-DbaCmsRegServerGroup to be piped in", "", false, "true (ByValue)", "" ], [ "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" ], [ "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": "Remove-DbaRegisteredServerGroup", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets list of Server Groups objects stored in SQL Server Central Management Server (CMS).", "Name": "Remove-DbaCmsRegServerGroup", "Links": "https://dbatools.io/Remove-DbaCmsRegServerGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaCmsRegServerGroup -SqlInstance sql2012 -Group HR, Accounting\nRemoves the HR and Accounting groups on sql2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaCmsRegServerGroup -SqlInstance sql2012 -Group HR\\Development -Confirm:$false\nRemoves the Development subgroup within the HR group on sql2012 and turns off all prompting", "Syntax": "Remove-DbaCmsRegServerGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaComputerCertificate", "Description": "Removes a computer certificate from a local or remote compuer", "Tags": "Certificate", "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "ServerInstance,SqlServer,SqlInstance", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to $ComputerName using alternative credentials", "", false, "false", "" ], [ "Thumbprint", "The thumbprint of the certificate object", "", true, "true (ByPropertyName)", "" ], [ "Store", "Certificate store - defaults to LocalMachine (otherwise exceptions can be thrown on remote connections)", "", false, "false", "LocalMachine" ], [ "Folder", "Certificate folder", "", false, "false", "My" ], [ "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": "Removes a computer certificate - useful for removing easily certs from remote computers", "Name": "Remove-DbaComputerCertificate", "Links": "https://dbatools.io/Remove-DbaComputerCertificate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaComputerCertificate -ComputerName Server1 -Thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94\nRemoves certificate with thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94 in the LocalMachine store on Server1\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaComputerCertificate | Where-Object Thumbprint -eq E0A071E387396723C45E92D42B2D497C6A182340 | Remove-DbaComputerCertificate\nRemoves certificate using the pipeline\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaComputerCertificate -ComputerName Server1 -Thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94 -Store User -Folder My\nRemoves certificate with thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94 in the User\\My (Personal) store on Server1", "Syntax": "Remove-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Thumbprint] \u003cString[]\u003e [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDatabase", "Description": "Tries a bunch of different ways to remove a database or two or more.", "Tags": [ "Delete", "Databases" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (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.", "Databases", true, "false", "" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase), to be removed.", "", true, "true (ByValue)", "" ], [ "IncludeSystemDb", "Use this switch to disable any kind of verbose messages", "", 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": "Drops a database, hopefully even the really stuck ones.", "Name": "Remove-DbaDatabase", "Links": "https://dbatools.io/Remove-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDatabase -SqlInstance sql2016 -Database containeddb\nPrompts then removes the database containeddb on SQL Server sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaDatabase -SqlInstance sql2016 -Database containeddb, mydb\nPrompts then removes the databases containeddb and mydb on SQL Server sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaDatabase -SqlInstance sql2016 -Database containeddb -Confirm:$false\nDoes not prompt and swiftly removes containeddb on SQL Server sql2016\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance server\\instance -ExcludeAllSystemDb | Remove-DbaDatabase\nRemoves all the user databases from server\\instance\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance server\\instance -ExcludeAllSystemDb | Remove-DbaDatabase -Confirm:$false\nRemoves all the user databases from server\\instance without any confirmation", "Syntax": "Remove-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-IncludeSystemDb] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaDatabase -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject[]\u003e [-IncludeSystemDb] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cDatabase[]\u003e [-IncludeSystemDb] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDatabaseSafely", "Description": "Performs a DBCC CHECKDB on the database, backs up the database with Checksum and verify only to a final (golden) backup location, creates an Agent Job to restore from that backup, drops the database, runs the agent job to restore the database, performs a DBCC CHECKDB and drops the database.\n\nWith huge thanks to Grant Fritchey and his verify your backups video. Take a look, it\u0027s only 3 minutes long. http://sqlps.io/backuprant", "Tags": [ "Database", "Remove" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 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)", "Credential", false, "false", "" ], [ "Database", "Specifies one or more databases to remove.", "Databases", false, "false", "" ], [ "Destination", "If specified, Agent jobs will be created on this server. By default, the jobs will be created on the server specified by SqlInstance. You must have sysadmin access and the server must be SQL Server \r\n2000 or higher. The SQL Agent service will be started if it is not already running.", "", false, "false", "$sqlinstance" ], [ "DestinationCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "NoDbccCheckDb", "If this switch is enabled, the initial DBCC CHECK DB will be skipped. This will make the process quicker but will also allow you to create an Agent job that restores a database backup containing a \r\ncorrupt database.\nA second DBCC CHECKDB is performed on the restored database so you will still be notified BUT USE THIS WITH CARE.", "NoCheck", false, "false", "False" ], [ "BackupFolder", "Specifies the path to a folder where the final backups of the removed databases will be stored. If you are using separate source and destination servers, you must specify a UNC path such as \r\n\\\\SERVER1\\BACKUPSHARE\\", "", true, "false", "" ], [ "CategoryName", "Specifies the Category Name for the Agent job that is created for restoring the database(s). By default, the name is \"Rationalisation\".", "", false, "false", "Rationalisation" ], [ "JobOwner", "Specifies the name of the account which will own the Agent jobs. By default, sa is used.", "", false, "false", "" ], [ "AllDatabases", "If this switch is enabled, all user databases on the server will be removed. This is useful when decommissioning a server. You should use a Destination with this switch.", "", false, "false", "False" ], [ "BackupCompression", "If this switch is enabled, compression will be used for the backup regardless of the SQL Server instance setting. By default, the SQL Server instance setting for backup compression is used.", "", false, "false", "Default" ], [ "ReuseSourceFolderStructure", "If this switch is enabled, the source folder structure will be used when restoring instead of using the destination instance default folder structure.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, all actions will be performed even if DBCC errors are detected. An Agent job will be created with \u0027DBCCERROR\u0027 in the name and the backup file will have \u0027DBCC\u0027 in its name.", "", 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", "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": "Remove-SqlDatabaseSafely", "Author": "Rob Sewell (@SQLDBAWithBeard), sqldbawithabeard.com", "Synopsis": "Safely removes a SQL Database and creates an Agent Job to restore it.", "Name": "Remove-DbaDatabaseSafely", "Links": "https://dbatools.io/Remove-DbaDatabaseSafely", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance \u0027Fade2Black\u0027 -Database RideTheLightning -BackupFolder \u0027C:\\MSSQL\\Backup\\Rationalised - DO NOT DELETE\u0027\nPerforms a DBCC CHECKDB on database RideTheLightning on server Fade2Black. If there are no errors, the database is backup to the folder C:\\MSSQL\\Backup\\Rationalised - DO NOT DELETE. Then, an Agent \r\njob to restore the database from that backup is created. The database is then dropped, the Agent job to restore it run, a DBCC CHECKDB run against the restored database, and then it is dropped again.\nAny DBCC errors will be written to your documents folder\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$Database = \u0027DemoNCIndex\u0027,\u0027RemoveTestDatabase\u0027\nPS C:\\\u003e Remove-DbaDatabaseSafely -SqlInstance \u0027Fade2Black\u0027 -Database $Database -BackupFolder \u0027C:\\MSSQL\\Backup\\Rationalised - DO NOT DELETE\u0027\nPerforms a DBCC CHECKDB on two databases, \u0027DemoNCIndex\u0027 and \u0027RemoveTestDatabase\u0027 on server Fade2Black. Then, an Agent job to restore each database from those backups is created. The databases are \r\nthen dropped, the Agent jobs to restore them run, a DBCC CHECKDB run against the restored databases, and then they are dropped again.\nAny DBCC errors will be written to your documents folder\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance \u0027Fade2Black\u0027 -Destination JusticeForAll -Database RideTheLightning -BackupFolder \u0027\\\\BACKUPSERVER\\BACKUPSHARE\\MSSQL\\Rationalised - DO NOT DELETE\u0027\nPerforms a DBCC CHECKDB on database RideTheLightning on server Fade2Black. If there are no errors, the database is backup to the folder \\\\BACKUPSERVER\\BACKUPSHARE\\MSSQL\\Rationalised - DO NOT DELETE . \r\nThen, an Agent job is created on server JusticeForAll to restore the database from that backup is created. The database is then dropped on Fade2Black, the Agent job to restore it on JusticeForAll is \r\nrun, a DBCC CHECKDB run against the restored database, and then it is dropped from JusticeForAll.\nAny DBCC errors will be written to your documents folder\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance IronMaiden -Database $Database -Destination TheWildHearts -BackupFolder Z:\\Backups -NoDbccCheckDb -JobOwner \u0027THEBEARD\\Rob\u0027\nFor the databases $Database on the server IronMaiden a DBCC CHECKDB will not be performed before backing up the databases to the folder Z:\\Backups. Then, an Agent job is created on server \r\nTheWildHearts with a Job Owner of THEBEARD\\Rob to restore each database from that backup using the instance\u0027s default file paths. The database(s) is(are) then dropped on IronMaiden, the Agent job(s) \r\nrun, a DBCC CHECKDB run on the restored database(s), and then the database(s) is(are) dropped.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance IronMaiden -Database $Database -Destination TheWildHearts -BackupFolder Z:\\Backups\nThe databases $Database on the server IronMaiden will be backed up the to the folder Z:\\Backups. Then, an Agent job is created on server TheWildHearts with a Job Owner of THEBEARD\\Rob to restore each \r\ndatabase from that backup using the instance\u0027s default file paths. The database(s) is(are) then dropped on IronMaiden, the Agent job(s) run, a DBCC CHECKDB run on the restored database(s), and then \r\nthe database(s) is(are) dropped.\nIf there is a DBCC Error, the function will continue to perform rest of the actions and will create an Agent job with \u0027DBCCERROR\u0027 in the name and a Backup file with \u0027DBCCError\u0027 in the name.", "Syntax": "Remove-DbaDatabaseSafely [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-Destination] \u003cDbaInstanceParameter\u003e] [[-DestinationCredential] \u003cPSCredential\u003e] [-NoDbccCheckDb] [-BackupFolder] \u003cString\u003e [[-CategoryName] \u003cString\u003e] [[-JobOwner] \u003cString\u003e] [-AllDatabases] [[-BackupCompression] \u003cString\u003e] [-ReuseSourceFolderStructure] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbBackupRestoreHistory", "Description": "Reduces the size of the backup and restore history tables by deleting the entries for backup sets.\n\nCan be used at server level, in this case a retention period -KeepDays can be set (default is 30 days).\nCan also be used at database level, in this case the complete history for the database(s) is deleted.\n\nThe backup and restore history tables reside in the msdb database.\n\nTo periodically remove old data from backup and restore history tables it is recommended to schedule the agent job sp_delete_backuphistory from the\nSQL Server Maintenance Solution created by Ola Hallengren (https://ola.hallengren.com).", "Tags": "Delete", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "KeepDays", "The number of days of history to keep. Defaults to 30 days.", "", false, "false", "30" ], [ "Database", "The database(s) to process. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "InputObject", "Enables piped input from Get-DbaDatabase", "", 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" ], [ "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": "IJeb Reitsma", "Synopsis": "Reduces the size of the backup and restore history tables by deleting old entries for backup sets.", "Name": "Remove-DbaDbBackupRestoreHistory", "Links": "https://dbatools.io/Remove-DbaDbBackupRestoreHistory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDbBackupRestoreHistory -SqlInstance sql2016\nPrompts for confirmation then deletes backup and restore history on SQL Server sql2016 older than 30 days (default period)\nPS C:\\\u003e Remove-DbaDbBackupRestoreHistory -SqlInstance sql2016 -KeepDays 100 -Confirm:$false\nRemove backup and restore history on SQL Server sql2016 older than 100 days. Does not prompt for confirmation.\nPS C:\\\u003e Remove-DbaDbBackupRestoreHistory -SqlInstance sql2016 -Database db1\nPrompts for confirmation then deletes all backup and restore history for database db1 on SQL Server sql2016\nPS C:\\\u003e Get-DbaDatabase -SqlInstance sql2016 | Remove-DbaDbBackupRestoreHistory -WhatIf\nRemove complete backup and restore history for all databases on SQL Server sql2016", "Syntax": "Remove-DbaDbBackupRestoreHistory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-KeepDays] \u003cInt32\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbCertificate", "Description": "Deletes specified database certificate", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The SQL Server to create the certificates on.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials.", "", false, "false", "" ], [ "Database", "The database where the certificate will be removed.", "", false, "false", "" ], [ "Certificate", "The certificate that will be removed", "", false, "false", "" ], [ "InputObject", "Piped certificate objects", "", 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" ], [ "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": "Remove-DbaDatabaseCertificate", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Deletes specified database certificate", "Name": "Remove-DbaDbCertificate", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDbCertificate -SqlInstance Server1\nThe certificate in the master database on server1 will be removed if it exists.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaDbCertificate -SqlInstance Server1 -Database db1 -Confirm:$false\nSuppresses all prompts to remove the certificate in the \u0027db1\u0027 database and drops the key.", "Syntax": "Remove-DbaDbCertificate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-Certificate] \u003cString[]\u003e] [[-InputObject] \u003cCertificate[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbMasterKey", "Description": "Deletes specified database master key", "Tags": [ "Certificate", "Masterkey" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Allows you to login to SQL Server using alternative credentials", "", false, "false", "" ], [ "Database", "The database where the master key will be removed.", "", false, "false", "" ], [ "ExcludeDatabase", "List of databases to exclude from clearing all master keys", "", false, "false", "" ], [ "All", "Purge the master keys from all databases on an instance", "", false, "false", "False" ], [ "InputObject", "Enables pipeline input from Get-DbaDatabase", "", 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" ], [ "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": "Remove-DbaDatabaseMasterKey", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Deletes specified database master key", "Name": "Remove-DbaDbMasterKey", "Links": "https://dbatools.io/Remove-DbaMasterKey", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDbMasterKey -SqlInstance sql2017, sql2016 -Database pubs\nThe master key in the pubs database on sql2017 and sql2016 will be removed if it exists.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaDbMasterKey -SqlInstance sql2017 -Database db1 -Confirm:$false\nSuppresses all prompts to remove the master key in the \u0027db1\u0027 database and drops the key.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbMasterKey -SqlInstance sql2017 -Database db1 | Remove-DbaDbMasterKey -Confirm:$false\nSuppresses all prompts to remove the master key in the \u0027db1\u0027 database and drops the key.", "Syntax": "Remove-DbaDbMasterKey [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [-All] [[-InputObject] \u003cMasterKey[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbMirror", "Description": "Removes database mirrors. Does not set databases in recovery to recovered.", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The target database.", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaDatabase.", "", 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" ], [ "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": "Removes database mirrors.", "Name": "Remove-DbaDbMirror", "Links": "https://dbatools.io/Set-DbaDbMirror", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbMirror -SqlInstance localhost\nReturns all Endpoint(s) on the local default SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbMirror -SqlInstance localhost, sql2016\nReturns all Endpoint(s) for the local and sql2016 SQL Server instances", "Syntax": "Remove-DbaDbMirror [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbMirrorMonitor", "Description": "Stops and deletes the mirroring monitor job for all the databases on the server instance.\n\nBasically executes sp_dbmmonitordropmonitoring.", "Tags": [ "Mirror", "HA", "Monitor" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-Credential).", "", 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" ], [ "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": "Stops and deletes the mirroring monitor job for all the databases on the server instance.", "Name": "Remove-DbaDbMirrorMonitor", "Links": "https://dbatools.io/Remove-DbaDbMirrorMonitor", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDbMirrorMonitor -SqlInstance sql2008, sql2012\nStops and deletes the mirroring monitor job for all the databases on sql2008 and sql2012.", "Syntax": "Remove-DbaDbMirrorMonitor [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbSnapshot", "Description": "Removes (drops) database snapshots from the server", "Tags": [ "Snapshot", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "Credential", false, "false", "" ], [ "Database", "Removes snapshots for only this specific base db", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Removes snapshots excluding this specific base dbs", "", false, "false", "" ], [ "Snapshot", "Restores databases from snapshot with this name only", "", false, "false", "" ], [ "InputObject", "Enables input from Get-DbaDbSnapshot", "", false, "true (ByValue)", "" ], [ "AllSnapshots", "Specifies that you want to remove all snapshots from the server", "", false, "false", "False" ], [ "Force", "Will forcibly kill all running queries that prevent the drop process.", "", 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", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step.", "cf", false, "false", "" ] ], "Alias": "Remove-DbaDatabaseSnapshot", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Removes database snapshots", "Name": "Remove-DbaDbSnapshot", "Links": "https://dbatools.io/Remove-DbaDbSnapshot", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, HR_snap_20161101\nRemoves database snapshots named HR_snap_20161201 and HR_snap_20161101\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting\nRemoves all database snapshots having HR and Accounting as base dbs\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting | Remove-DbaDbSnapshot\nRemoves all database snapshots having HR and Accounting as base dbs\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snapshot, Accounting_snapshot\nRemoves HR_snapshot and Accounting_snapshot\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 | Where SnapshotOf -like \u0027*dumpsterfire*\u0027 | Remove-DbaDbSnapshot\nRemoves all snapshots associated with databases that have dumpsterfire in the name\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -Passthru | Remove-DbaDbSnapshot\nAllows the selection of snapshots on sql2016 to remove\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots\nRemoves all database snapshots from sql2014\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots -Confirm\nRemoves all database snapshots from sql2014 and prompts for each database", "Syntax": "Remove-DbaDbSnapshot [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Snapshot] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-AllSnapshots] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaDbUser", "Description": "If user is the owner of a schema with the same name and if if the schema does not have any underlying objects the schema will be\ndropped. If user owns more than one schema, the owner of the schemas that does not have the same name as the user, will be\nchanged to \u0027dbo\u0027. If schemas have underlying objects, you must specify the -Force parameter so the user can be dropped.", "Tags": [ "Database", "User", "Login", "Security" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user.", "Credential", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "User", "Specifies the list of users to remove.", "", true, "false", "" ], [ "InputObject", "Support piping from Get-DbaDbUser.", "", true, "true (ByValue)", "" ], [ "Force", "If enabled this will force the change of the owner to \u0027dbo\u0027 for any schema which owner is the User.", "", 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", "If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Doug Meyers (@dgmyrs)", "Synopsis": "Drop database user", "Name": "Remove-DbaDbUser", "Links": "https://dbatools.io/Remove-DbaDbUser", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaDbUser -SqlInstance sqlserver2014 -User user1\nDrops user1 from all databases it exists in on server \u0027sqlserver2014\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaDbUser -SqlInstance sqlserver2014 -Database database1 -User user1\nDrops user1 from the database1 database on server \u0027sqlserver2014\u0027.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaDbUser -SqlInstance sqlserver2014 -ExcludeDatabase model -User user1\nDrops user1 from all databases it exists in on server \u0027sqlserver2014\u0027 except for the model database.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbUser sqlserver2014 | Where-Object Name -In \"user1\" | Remove-DbaDbUser\nDrops user1 from all databases it exists in on server \u0027sqlserver2014\u0027.", "Syntax": "Remove-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -User \u003cObject[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaDbUser -InputObject \u003cUser[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaEndpoint", "Description": "Removes endpoints from a SQL Server instance.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "EndPoint", "Only remove specific endpoints.", "", false, "false", "" ], [ "AllEndpoints", "Remove all endpoints on an instance.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-Endpoint.", "", 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" ], [ "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": "Removes endpoints from a SQL Server instance.", "Name": "Remove-DbaEndpoint", "Links": "https://dbatools.io/Remove-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaEndpoint -SqlInstance sqlserver2012 -AllEndpoints\nRemoves all endpoints on the sqlserver2014 instance. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaEndpoint -SqlInstance sqlserver2012 -Endpoint endpoint1,endpoint2 -Confirm:$false\nRemoves the endpoint1 and endpoint2 endpoints. Does not prompt for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance sqlserver2012 -Endpoint endpoint1 | Remove-DbaEndpoint\nRemoves the endpoints returned from the Get-DbaEndpoint function. Prompts for confirmation.", "Syntax": "Remove-DbaEndpoint [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-EndPoint] \u003cString[]\u003e] [-AllEndpoints] [[-InputObject] \u003cEndpoint[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaLogin", "Description": "Tries a bunch of different ways to remove a Login or two or more.", "Tags": [ "Delete", "Login" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Allows you to login to servers using alternative credentials.", "Credential", false, "false", "" ], [ "Login", "The Login(s) to process - this list is auto-populated from the server. If unspecified, all Logins will be processed.", "", true, "false", "" ], [ "InputObject", "A collection of Logins (such as returned by Get-DbaLogin), to be removed.", "", true, "true (ByValue)", "" ], [ "Force", "Kills any sessions associated with the login prior to drop", "", 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" ], [ "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": "Drops a Login", "Name": "Remove-DbaLogin", "Links": "https://dbatools.io/Remove-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaLogin -SqlInstance sql2016 -Login mylogin\nPrompts then removes the Login mylogin on SQL Server sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaLogin -SqlInstance sql2016 -Login mylogin, yourlogin\nPrompts then removes the Logins mylogin and yourlogin on SQL Server sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaLogin -SqlInstance sql2016 -Login mylogin -Confirm:$false\nDoes not prompt and swiftly removes mylogin on SQL Server sql2016\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance server\\instance -Login yourlogin | Remove-DbaLogin\nRemoves mylogin on SQL Server server\\instance", "Syntax": "Remove-DbaLogin [-SqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaLogin -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Login \u003cString[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaLogin [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cLogin[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaNetworkCertificate", "Description": "Removes the network certificate for SQL Server instance. This setting is found in Configuration Manager.", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost. If target is a cluster, you must also specify InstanceClusterName (see below)", "ServerInstance,SqlServer,ComputerName", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the computer (not sql instance) using alternative credentials.", "", 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": "Removes the network certificate for SQL Server instance", "Name": "Remove-DbaNetworkCertificate", "Links": "https://dbatools.io/Remove-DbaNetworkCertificate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaNetworkCertificate\nRemoves the Network Certificate for the default instance (MSSQLSERVER) on localhost\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaNetworkCertificate -SqlInstance sql1\\SQL2008R2SP2\nRemoves the Network Certificate for the SQL2008R2SP2 instance on sql1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaNetworkCertificate -SqlInstance localhost\\SQL2008R2SP2 -WhatIf\nShows what would happen if the command were run", "Syntax": "Remove-DbaNetworkCertificate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaOrphanUser", "Description": "An orphan user is defined by a user that does not have their matching login. (Login property = \"\").\n\nIf user is the owner of the schema with the same name and if if the schema does not have any underlying objects the schema will be dropped.\n\nIf user owns more than one schema, the owner of the schemas that does not have the same name as the user, will be changed to \u0027dbo\u0027. If schemas have underlying objects, you must specify the -Force parameter so the user can be dropped.\n\nIf exists a login to map the drop will not be performed unless you specify the -Force parameter (only when calling from Repair-DbaOrphanUser.", "Tags": [ "Orphan", "Database", "Security", "Login" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server", "", false, "false", "" ], [ "User", "Specifies the list of users to remove.", "", false, "true (ByValue)", "" ], [ "Force", "If this switch is enabled:\r\nIf exists any schema which owner is the User, this will force the change of the owner to \u0027dbo\u0027.\r\nIf exists a login to map the drop will not be performed unless you specify this parameter.", "", 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", "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": "Remove-SqlOrphanUser", "Author": "Claudio Silva (@ClaudioESSilva) | Simone Bizzotto (@niphlod)", "Synopsis": "Drop orphan users with no existing login to map", "Name": "Remove-DbaOrphanUser", "Links": "https://dbatools.io/Remove-DbaOrphanUser", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sql2005\nFinds and drops all orphan users without matching Logins in all databases present on server \u0027sql2005\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -SqlCredential $cred\nFinds and drops all orphan users without matching Logins in all databases present on server \u0027sqlserver2014a\u0027. SQL Server authentication will be used in connecting to the server.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -Database db1, db2 -Force\nFinds and drops orphan users even if they have a matching Login on both db1 and db2 databases.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -ExcludeDatabase db1, db2 -Force\nFinds and drops orphan users even if they have a matching Login from all databases except db1 and db2.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -User OrphanUser\nRemoves user OrphanUser from all databases only if there is no matching login.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -User OrphanUser -Force\nRemoves user OrphanUser from all databases even if they have a matching Login. Any schema that the user owns will change ownership to dbo.", "Syntax": "Remove-DbaOrphanUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-User] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaPfDataCollectorCounter", "Description": "Removes a Performance Data Collector Counter.", "Tags": "PerfMon", "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the target computer 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 to search.", "DataCollectorSet", false, "false", "" ], [ "Collector", "The name of the Collector to remove.", "DataCollector", false, "false", "" ], [ "Counter", "The name of the Counter - in the form of \u0027\\Processor(_Total)\\% Processor Time\u0027.", "Name", true, "true (ByPropertyName)", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSet 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes a Performance Data Collector Counter.", "Name": "Remove-DbaPfDataCollectorCounter", "Links": "https://dbatools.io/Remove-DbaPfDataCollectorCounter", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaPfDataCollectorCounter -ComputerName sql2017 -CollectorSet \u0027System Correlation\u0027 -Collector DataCollector01 -Counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027\nPrompts for confirmation then removes the \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 counter within the DataCollector01 collector within the System Correlation collector set on sql2017.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorCounter | Out-GridView -PassThru | Remove-DbaPfDataCollectorCounter -Confirm:$false\nAllows you to select which counters you\u0027d like on localhost and does not prompt for confirmation.", "Syntax": "Remove-DbaPfDataCollectorCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [-Counter] \u003cObject[]\u003e [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaPfDataCollectorSet", "Description": "Removes a Performance Monitor Data Collector Set. When removing data collector sets from the local instance, Run As Admin is required.", "Tags": "PerfMon", "Params": [ [ "ComputerName", "The target computer. Defaults to localhost.", "", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the target computer 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 to remove.", "DataCollectorSet", false, "false", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSet 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes a Performance Monitor Data Collector Set", "Name": "Remove-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Remove-DbaPfDataCollectorSet", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaPfDataCollectorSet\nPrompts for confirmation then removes all ready Collectors on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaPfDataCollectorSet -ComputerName sql2017 -Confirm:$false\nAttempts to remove all ready Collectors on localhost and does not prompt to confirm.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaPfDataCollectorSet -ComputerName sql2017, sql2016 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nPrompts for confirmation then removes the \u0027System Correlation\u0027 Collector on sql2017 and sql2016 using alternative credentials.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Remove-DbaPfDataCollectorSet\nRemoves the \u0027System Correlation\u0027 Collector.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Stop-DbaPfDataCollectorSet | Remove-DbaPfDataCollectorSet\nStops and removes the \u0027System Correlation\u0027 Collector.", "Syntax": "Remove-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaSpn", "Description": "This function will connect to Active Directory and search for an account. If the account is found, it will attempt to remove the specified SPN. Once the SPN is removed, the function will also remove delegation to that service.\n\nIn order to run this function, the credential you provide must have write access to Active Directory.", "Tags": "SPN", "Params": [ [ "SPN", "The SPN you want to remove", "RequiredSPN", true, "true (ByPropertyName)", "" ], [ "ServiceAccount", "The account you want the SPN remove from", "InstanceServiceAccount,AccountName", true, "true (ByPropertyName)", "" ], [ "Credential", "The credential you want to use to connect to Active Directory to make the changes", "", false, "true (ByPropertyName)", "" ], [ "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 was executed", "wi", false, "false", "" ], [ "Confirm", "Turns confirmations before changes on or off", "cf", false, "false", "" ] ], "Alias": "", "Author": "Drew Furgiuele (@pittfurg), http://www.port1433.com", "Synopsis": "Removes an SPN for a given service account in active directory and also removes delegation to the same SPN, if found", "Name": "Remove-DbaSpn", "Links": "https://dbatools.io/Remove-DbaSpn", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account\nConnects to Active Directory and removes a provided SPN from the given account (and also the relative delegation)\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -EnableException\nConnects to Active Directory and removes a provided SPN from the given account, suppressing all error messages and throw exceptions that can be caught instead\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRemove-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -Credential ad\\sqldba\nConnects to Active Directory and removes a provided SPN to the given account. Uses alternative account to connect to AD.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2005 | Where { $_.isSet -eq $true } | Remove-DbaSpn -WhatIf\nShows what would happen trying to remove all set SPNs for sql2005 and the relative delegations\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2005 | Where { $_.isSet -eq $true } | Remove-DbaSpn\nRemoves all set SPNs for sql2005 and the relative delegations", "Syntax": "Remove-DbaSpn [-SPN] \u003cString\u003e [-ServiceAccount] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaTrace", "Description": "Stops and closes the specified trace and deletes its definition from the server.", "Tags": [ "Security", "Trace" ], "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", "" ], [ "Id", "A list of trace ids.", "", false, "false", "" ], [ "InputObject", "Internal parameter for piping.", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops and closes the specified trace and deletes its definition from the server.", "Name": "Remove-DbaTrace", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaTrace -SqlInstance sql2008\nStops and removes all traces on sql2008\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaTrace -SqlInstance sql2008 -Id 1\nStops and removes all trace with ID 1 on sql2008\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2008 | Out-GridView -PassThru | Remove-DbaTrace\nStops and removes selected traces on sql2008", "Syntax": "Remove-DbaTrace [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Id] \u003cInt32[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaXESession", "Description": "This script removes Extended Events sessions on a SQL Server instance.", "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", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "Specifies a list of Extended Events sessions to remove.", "Sessions", true, "false", "" ], [ "AllSessions", "If this switch is enabled, all Extended Events sessions will be removed except the packaged sessions AlwaysOn_health, system_health, telemetry_xevents.", "", true, "false", "False" ], [ "InputObject", "Accepts a collection of XEsession objects as output by Get-DbaXESession.", "", 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.", "", false, "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes Extended Events sessions.", "Name": "Remove-DbaXESession", "Links": "https://dbatools.io/Remove-DbaXESession", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRemove-DbaXESession -SqlInstance sql2012 -AllSessions\nRemoves all Extended Event Session on the sqlserver2014 instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRemove-DbaXESession -SqlInstance sql2012 -Session xesession1,xesession2\nRemoves the xesession1 and xesession2 Extended Event sessions.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 | Remove-DbaXESession -Confirm:$false\nRemoves all sessions from sql2017, bypassing prompts.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2012 -Session xesession1 | Remove-DbaXESession\nRemoves the sessions returned from the Get-DbaXESession function.", "Syntax": "Remove-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Session \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -AllSessions [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRemove-DbaXESession -InputObject \u003cSession[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Remove-DbaXESmartTarget", "Description": "Removes XESmartTarget PowerShell jobs.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "InputObject", "Specifies one or more XESmartTarget job objects as output by Get-DbaXESmartTarget.", "", 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.", "", false, "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "Removes XESmartTarget PowerShell jobs.", "Name": "Remove-DbaXESmartTarget", "Links": "https://dbatools.io/Remove-DbaXESmartTarget", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXESmartTarget | Remove-DbaXESmartTarget\nRemoves all XESmartTarget jobs.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESmartTarget | Where-Object Id -eq 2 | Remove-DbaXESmartTarget\nRemoves a specific XESmartTarget job.", "Syntax": "Remove-DbaXESmartTarget [-InputObject] \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Rename-DbaDatabase", "Description": "Can change every database metadata that can be renamed.\nThe ultimate goal is choosing to have a default template to enforce in your environment\nso your naming convention for every bit can be put in place in no time.\nThe process is as follows (it follows the hierarchy of the entities):\n- database name is changed (optionally, forcing users out)\n- filegroup name(s) are changed accordingly\n- logical name(s) are changed accordingly\n- physical file(s) are changed accordingly\n- if Move is specified, the database will be taken offline and the move will initiate, then it will be taken online\n- if Move is not specified, the database remains online (unless SetOffline), and you are in charge of moving files\nIf any of the above fails, the process stops.\nPlease take a backup of your databases BEFORE using this, and remember to backup AFTER (also a FULL backup of master)\n\nIt returns an object for each database with all the renames done, plus hidden properties showing a \"human\" representation of them.\n\nIt\u0027s better you store the resulting object in a variable so you can inspect it in case of issues, e.g. \"$result = Rename-DbaDatabase .....\"\n\nTo get a grasp without worrying of what would happen under the hood, use \"Rename-DbaDatabase .... -Preview | Select-Object *\"", "Tags": [ "Database", "Rename" ], "Params": [ [ "SqlInstance", "Target any number of instances, in order to return their build state.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "When connecting to an instance, use the credentials specified.", "Credential", false, "false", "" ], [ "Database", "Targets only specified databases", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Excludes only specified databases", "", false, "false", "" ], [ "AllDatabases", "If you want to apply the naming convention system wide, you need to pass this parameter", "", false, "false", "False" ], [ "DatabaseName", "Pass a template to rename the database name. Valid placeholders are:\r\n- \u003cDBN\u003e current database name\r\n- \u003cDATE\u003e date (yyyyMMdd)", "", false, "false", "" ], [ "FileGroupName", "Pass a template to rename file group name. Valid placeholders are:\r\n- \u003cFGN\u003e current filegroup name\r\n- \u003cDBN\u003e current database name\r\n- \u003cDATE\u003e date (yyyyMMdd)\r\nIf distinct names cannot be generated, a counter will be appended (0001, 0002, 0003, etc)", "", false, "false", "" ], [ "LogicalName", "Pass a template to rename logical name. Valid placeholders are:\r\n- \u003cFT\u003e file type (ROWS, LOG)\r\n- \u003cLGN\u003e current logical name\r\n- \u003cFGN\u003e current filegroup name\r\n- \u003cDBN\u003e current database name\r\n- \u003cDATE\u003e date (yyyyMMdd)\r\nIf distinct names cannot be generated, a counter will be appended (0001, 0002, 0003, etc)", "", false, "false", "" ], [ "FileName", "Pass a template to rename file name. Valid placeholders are:\r\n- \u003cFNN\u003e current file name (the basename, without directory nor extension)\r\n- \u003cFT\u003e file type (ROWS, LOG, MMO, FS)\r\n- \u003cLGN\u003e current logical name\r\n- \u003cFGN\u003e current filegroup name\r\n- \u003cDBN\u003e current database name\r\n- \u003cDATE\u003e date (yyyyMMdd)\r\nIf distinct names cannot be generated, a counter will be appended (0001, 0002, 0003, etc)", "", false, "false", "" ], [ "ReplaceBefore", "If you pass this switch, all upper level \"current names\" will be inspected and replaced BEFORE doing the\r\nrename according to the template in the current level (remember the hierarchy):\r\nLet\u0027s say you have a database named \"dbatools_HR\", composed by 3 files\r\n- dbatools_HR_Data.mdf\r\n- dbatools_HR_Index.ndf\r\n- dbatools_HR_log.ldf\r\nRename-DbaDatabase .... -Database \"dbatools_HR\" -DatabaseName \"dbatools_HRARCHIVE\" -FileName \u0027\u003cDBN\u003e\u003cFNN\u003e\u0027\r\nwould end up with this logic:\r\n- database --\u003e no placeholders specified\r\n- dbatools_HR to dbatools_HRARCHIVE\r\n- filenames placeholders specified\r\n\u003cDBN\u003e\u003cFNN\u003e --\u003e current database name + current filename\"\r\n- dbatools_HR_Data.mdf to dbatools_HRARCHIVEdbatools_HR_Data.mdf\r\n- dbatools_HR_Index.mdf to dbatools_HRARCHIVEdbatools_HR_Data.mdf\r\n- dbatools_HR_log.ldf to dbatools_HRARCHIVEdbatools_HR_log.ldf\r\nPassing this switch, instead, e.g.\r\nRename-DbaDatabase .... -Database \"dbatools_HR\" -DatabaseName \"dbatools_HRARCHIVE\" -FileName \u0027\u003cDBN\u003e\u003cFNN\u003e\u0027 -ReplaceBefore\r\nend up with this logic instead:\r\n- database --\u003e no placeholders specified\r\n- dbatools_HR to dbatools_HRARCHIVE\r\n- filenames placeholders specified,\r\n\u003cDBN\u003e\u003cFNN\u003e, plus -ReplaceBefore --\u003e current database name + replace OLD \"upper level\" names inside the current filename\r\n- dbatools_HR_Data.mdf to dbatools_HRARCHIVE_Data.mdf\r\n- dbatools_HR_Index.mdf to dbatools_HRARCHIVE_Data.mdf\r\n- dbatools_HR_log.ldf to dbatools_HRARCHIVE_log.ldf", "", false, "false", "False" ], [ "Force", "Kills any open session to be able to do renames.", "", false, "false", "False" ], [ "Move", "If you want this function to move files, else you\u0027re the one in charge of it.\r\nThis enables the same functionality as SetOffline, killing open transactions and putting the database\r\noffline, then do the actual rename and setting it online again afterwards", "", false, "false", "False" ], [ "SetOffline", "Kills any open session and sets the database offline to be able to move files", "", false, "false", "False" ], [ "Preview", "Shows the renames without performing any operation (recommended to find your way around this function parameters ;-) )", "", false, "false", "False" ], [ "InputObject", "Accepts piped database objects", "", 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", "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": "", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Changes database name, logical file names, file group names and physical file names (optionally handling the move). BETA VERSION.", "Name": "Rename-DbaDatabase", "Links": "https://dbatools.io/Rename-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName HR2 -Preview | select *\nShows the detailed result set you\u0027ll get renaming the HR database to HR2 without doing anything\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName HR2\nRenames the HR database to HR2\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sqlserver2014a -Database HR | Rename-DbaDatabase -DatabaseName HR2\nSame as before, but with a piped database (renames the HR database to HR2)\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\"\nRenames the HR database to dbatools_HR\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e_\u003cDATE\u003e\"\nRenames the HR database to dbatools_HR_20170807 (if today is 07th Aug 2017)\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -FileGroupName \"dbatools_\u003cFGN\u003e\"\nRenames every FileGroup within HR to \"dbatools_[the original FileGroup name]\"\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileGroupName \"\u003cDBN\u003e_\u003cFGN\u003e\"\nRenames the HR database to \"dbatools_HR\", then renames every FileGroup within to \"dbatools_HR_[the original FileGroup name]\"\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -FileGroupName \"dbatools_\u003cDBN\u003e_\u003cFGN\u003e\"\nPS C:\\\u003e Rename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\"\nRenames the HR database to \"dbatools_HR\", then renames every FileGroup within to \"dbatools_HR_[the original FileGroup name]\"\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileName \"\u003cDBN\u003e_\u003cFGN\u003e_\u003cFNN\u003e\"\nRenames the HR database to \"dbatools_HR\" and then all filenames as \"dbatools_HR_[Name of the FileGroup]_[original_filename]\"\r\nThe db stays online (watch out!). You can then proceed manually to move/copy files by hand, set the db offline and then online again to finish the rename process\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileName \"\u003cDBN\u003e_\u003cFGN\u003e_\u003cFNN\u003e\" -SetOffline\nRenames the HR database to \"dbatools_HR\" and then all filenames as \"dbatools_HR_[Name of the FileGroup]_[original_filename]\"\r\nThe db is then set offline (watch out!). You can then proceed manually to move/copy files by hand and then set it online again to finish the rename process\n-------------------------- EXAMPLE 11 --------------------------\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileName \"\u003cDBN\u003e_\u003cFGN\u003e_\u003cFNN\u003e\" -Move\nRenames the HR database to \"dbatools_HR\" and then all filenames as \"dbatools_HR_[Name of the FileGroup]_[original_filename]\"\r\nThe db is then set offline (watch out!). The function tries to do a simple rename and then sets the db online again to finish the rename process", "Syntax": "Rename-DbaDatabase -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-DatabaseName \u003cString\u003e] [-FileGroupName \u003cString\u003e] [-LogicalName \u003cString\u003e] [-FileName \u003cString\u003e] [-ReplaceBefore] [-Force] [-Move] [-SetOffline] [-Preview] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRename-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-DatabaseName \u003cString\u003e] [-FileGroupName \u003cString\u003e] [-LogicalName \u003cString\u003e] [-FileName \u003cString\u003e] [-ReplaceBefore] [-Force] [-Move] [-SetOffline] [-Preview] -InputObject \u003cDatabase[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Rename-DbaLogin", "Description": "There are times where you might want to rename a login that was copied down, or if the name is not descriptive for what it does.\n\nIt can be a pain to update all of the mappings for a specific user, this does it for you.", "Tags": "Login", "Params": [ [ "SqlInstance", "Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Login", "The current Login on the server - this list is auto-populated from the server.", "", true, "false", "" ], [ "NewLogin", "The new Login that you wish to use. If it is a windows user login, then the SID must match.", "", 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" ], [ "WhatIf", "Shows what would happen if the command were to run. No actions are actually performed.", "wi", false, "false", "" ], [ "Confirm", "Prompts to confirm actions", "cf", false, "false", "" ] ], "Alias": "", "Author": "Mitchell Hamann (@SirCaptainMitch)", "Synopsis": "Rename-DbaLogin will rename login and database mapping for a specified login.", "Name": "Rename-DbaLogin", "Links": "https://dbatools.io/Rename-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRename-DbaLogin -SqlInstance localhost -Login DbaToolsUser -NewLogin captain\nSQL Login Example\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRename-DbaLogin -SqlInstance localhost -Login domain\\oldname -NewLogin domain\\newname\nChange the windowsuser login name.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRename-DbaLogin -SqlInstance localhost -Login dbatoolsuser -NewLogin captain -WhatIf\nWhatIf Example", "Syntax": "Rename-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Login] \u003cString\u003e [-NewLogin] \u003cString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Repair-DbaDbMirror", "Description": "Attempts to repair a suspended mirroring database.\n\nRestarts the endpoints then sets the partner to resume. See this article for more info:\n\nhttp://www.sqlservercentral.com/blogs/vivekssqlnotes/2016/09/03/how-to-resume-suspended-database-mirroring-in-sql-server-/", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The target database.", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaDatabase.", "", 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" ], [ "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": "Attempts to repair a suspended or paused mirroring database.", "Name": "Repair-DbaDbMirror", "Links": "https://dbatools.io/Repair-DbaDbMirror", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRepair-DbaDbMirror -SqlInstance sql2017 -Database pubs\nAttempts to repair the mirrored but suspended pubs database on sql2017.\r\nRestarts the endpoints then sets the partner to resume. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017 -Database pubs | Repair-DbaDbMirror -Confirm:$false\nAttempts to repair the mirrored but suspended pubs database on sql2017.\r\nRestarts the endpoints then sets the partner to resume. Does not prompt for confirmation.", "Syntax": "Repair-DbaDbMirror [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Repair-DbaOrphanUser", "Description": "An orphan user is defined by a user that does not have a matching login (Login property = \"\").\n\nIf the matching login exists it must be:\nEnabled\nNot a system object\nNot locked\nHave the same name that user\n\nYou can drop users that does not have their matching login by specifying the parameter -RemoveNotExisting.", "Tags": "Orphan", "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server", "", false, "false", "" ], [ "Users", "Specifies the list of usernames to repair.", "", false, "true (ByValue)", "" ], [ "RemoveNotExisting", "If this switch is enabled, all users that do not have a matching login will be dropped from the database.", "", false, "false", "False" ], [ "Force", "Forces alter schema to dbo owner so users can be dropped.", "", 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", "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": "Repair-SqlOrphanUser", "Author": "Claudio Silva (@ClaudioESSilva) | Simone Bizzotto (@niphlod)", "Synopsis": "Finds orphan users with existing login and remaps them.", "Name": "Repair-DbaOrphanUser", "Links": "https://dbatools.io/Repair-DbaOrphanUser", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sql2005\nFinds and repairs all orphan users of all databases present on server \u0027sql2005\u0027\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -SqlCredential $cred\nFinds and repair all orphan users in all databases present on server \u0027sqlserver2014a\u0027. SQL credentials are used to authenticate to the server.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -Database db1, db2\nFinds and repairs all orphan users in both db1 and db2 databases.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -Database db1 -Users OrphanUser\nFinds and repairs user \u0027OrphanUser\u0027 in \u0027db1\u0027 database.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -Users OrphanUser\nFinds and repairs user \u0027OrphanUser\u0027 on all databases\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -RemoveNotExisting\nFinds all orphan users of all databases present on server \u0027sqlserver2014a\u0027. Removes all users that do not have matching Logins.", "Syntax": "Repair-DbaOrphanUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Users] \u003cObject[]\u003e] [-RemoveNotExisting] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Repair-DbaServerName", "Description": "When a SQL Server\u0027s host OS is renamed, the SQL Server should be as well. This helps with Availability Groups and Kerberos.\n\nThis command renames @@SERVERNAME to match with the Windows name. The new name is automatically determined. It does not matter if you use an alias to connect to the SQL instance.\n\nIf the automatically determined new name matches the old name, the command will not run.\n\nhttps://www.mssqltips.com/sqlservertip/2525/steps-to-change-the-server-name-for-a-sql-server-machine/", "Tags": "SPN", "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "AutoFix", "If this switch is enabled, the repair will be performed automatically.", "", false, "false", "False" ], [ "Force", "If this switch is enabled, most confirmation prompts will be skipped.", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Renames @@SERVERNAME to match with the Windows name.", "Name": "Repair-DbaServerName", "Links": "https://dbatools.io/Repair-DbaServerName", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRepair-DbaServerName -SqlInstance sql2014\nChecks to see if the server name is updatable and changes the name with a number of prompts.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRepair-DbaServerName -SqlInstance sql2014 -AutoFix\nChecks to see if the server name is updatable and automatically performs the change. Replication or mirroring will be broken if necessary.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRepair-DbaServerName -SqlInstance sql2014 -AutoFix -Force\nChecks to see if the server name is updatable and automatically performs the change, bypassing most prompts and confirmations. Replication or mirroring will be broken if necessary.", "Syntax": "Repair-DbaServerName [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-AutoFix] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Reset-DbaAdmin", "Description": "This function allows administrators to regain access to local or remote SQL Servers by either resetting the sa password, adding the sysadmin role to existing login, or adding a new login (SQL or Windows) and granting it sysadmin privileges.\n\nThis is accomplished by stopping the SQL services or SQL Clustered Resource Group, then restarting SQL via the command-line using the /mReset-DbaAdmin parameter which starts the server in Single-User mode and only allows this script to connect.\n\nOnce the service is restarted, the following tasks are performed:\n- Login is added if it doesn\u0027t exist\n- If login is a Windows User, an attempt is made to ensure it exists\n- If login is a SQL Login, password policy will be set to OFF when creating the login, and SQL Server authentication will be set to Mixed Mode.\n- Login will be enabled and unlocked\n- Login will be added to sysadmin role\n\nIf failures occur at any point, a best attempt is made to restart the SQL Server.\n\nIn order to make this script as portable as possible, System.Data.SqlClient and Get-WmiObject are used (as opposed to requiring the Failover Cluster Admin tools or SMO).\n\nIf using this function against a remote SQL Server, ensure WinRM is configured and accessible. If this is not possible, run the script locally.\n\nTested on Windows XP, 7, 8.1, Server 2012 and Windows Server Technical Preview 2.\nTested on SQL Server 2005 SP4 through 2016 CTP2.", "Tags": "WSMan", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. SQL Server must be 2005 and above, and can be a clustered or stand-alone instance.", "ServerInstance,SqlServer", true, "false", "" ], [ "Login", "By default, the Login parameter is \"sa\" but any other SQL or Windows account can be specified. If a login does not currently exist, it will be added.\nWhen adding a Windows login to remote servers, ensure the SQL Server can add the login (ie, don\u0027t add WORKSTATION\\Admin to remoteserver\\instance. Domain users and Groups are valid input.", "", false, "false", "sa" ], [ "SecurePassword", "By default, if a SQL Login is detected, you will be prompted for a password. Use this to securely bypass the prompt.", "", false, "false", "" ], [ "Force", "If this switch is enabled, the Login(s) will be dropped and recreated on Destination. Logins that own Agent jobs cannot be dropped at this time.", "", 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", "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": "Reset-SqlAdmin", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "This function allows administrators to regain access to SQL Servers in the event that passwords or access was lost.\n\nSupports SQL Server 2005 and above. Windows administrator access is required.", "Name": "Reset-DbaAdmin", "Links": "https://dbatools.io/Reset-DbaAdmin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eReset-DbaAdmin -SqlInstance sqlcluster\nPrompts for password, then resets the \"sa\" account password on sqlcluster.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eReset-DbaAdmin -SqlInstance sqlserver\\sqlexpress -Login ad\\administrator\nPrompts user to confirm that they understand the SQL Service will be restarted.\nAdds the domain account \"ad\\administrator\" as a sysadmin to the SQL instance.\r\nIf the account already exists, it will be added to the sysadmin role.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eReset-DbaAdmin -SqlInstance sqlserver\\sqlexpress -Login sqladmin -Force\nSkips restart confirmation, prompts for password, then adds a SQL Login \"sqladmin\" with sysadmin privileges.\r\nIf the account already exists, it will be added to the sysadmin role and the password will be reset.", "Syntax": "Reset-DbaAdmin [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-Login] \u003cString\u003e] [[-SecurePassword] \u003cSecureString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Resolve-DbaNetworkName", "Description": "Retrieves the IPAddress, ComputerName from one computer.\nThe object can be used to take action against its name or IPAddress.\n\nFirst ICMP is used to test the connection, and get the connected IPAddress.\n\nMultiple protocols (e.g. WMI, CIM, etc) are attempted before giving up.\n\nImportant: Remember that FQDN doesn\u0027t always match \"ComputerName dot Domain\" as AD intends.\nThere are network setup (google \"disjoint domain\") where AD and DNS do not match.\n\"Full computer name\" (as reported by sysdm.cpl) is the only match between the two,\nand it matches the \"DNSHostName\" property of the computer object stored in AD.\nThis means that the notation of FQDN that matches \"ComputerName dot Domain\" is incorrect\nin those scenarios.\nIn other words, the \"suffix\" of the FQDN CAN be different from the AD Domain.\n\nThis cmdlet has been providing good results since its inception but for lack of useful\nnames some doubts may arise.\nLet this clear the doubts:\n- InputName: whatever has been passed in\n- ComputerName: hostname only\n- IPAddress: IP Address\n- DNSHostName: hostname only, coming strictly from DNS (as reported from the calling computer)\n- DNSDomain: domain only, coming strictly from DNS (as reported from the calling computer)\n- Domain: domain only, coming strictly from AD (i.e. the domain the ComputerName is joined to)\n- DNSHostEntry: Fully name as returned by DNS [System.Net.Dns]::GetHostEntry\n- FQDN: \"legacy\" notation of ComputerName \"dot\" Domain (coming from AD)\n- FullComputerName: Full name as configured from within the Computer (i.e. the only secure match between AD and DNS)\n\nSo, if you need to use something, go with FullComputerName, always, as it is the most correct in every scenario.", "Tags": [ "Network", "Resolve" ], "Params": [ [ "ComputerName", "The target SQL Server instance or instances.\r\nThis can be the name of a computer, a SMO object, an IP address or a SQL Instance.", "cn,host,ServerInstance,Server,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the SQL Server as a different user", "", false, "false", "" ], [ "Turbo", "Resolves without accessing the server itself. Faster but may be less accurate because it relies on DNS only,\r\nso it may fail spectacularly for disjoin-domain setups. Also, everyone has its own DNS (i.e. results may vary\r\nchanging the computer where the function runs)", "FastParrot", 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": "Klaas Vandenberghe (@PowerDBAKlaas) | Simone Bizzotto (@niphold)", "Synopsis": "Returns information about the network connection of the target computer including NetBIOS name, IP Address, domain name and fully qualified domain name (FQDN).", "Name": "Resolve-DbaNetworkName", "Links": "https://dbatools.io/Resolve-DbaNetworkName", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eResolve-DbaNetworkName -ComputerName ServerA\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for ServerA\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eResolve-DbaNetworkName -SqlInstance sql2016\\sqlexpress\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for the SQL instance sql2016\\sqlexpress\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eResolve-DbaNetworkName -SqlInstance sql2016\\sqlexpress, sql2014\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, FQDN, DNSHostEntry for the SQL instance sql2016\\sqlexpress and sql2014\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2014 | Resolve-DbaNetworkName\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, Domain, FQDN for all SQL Servers returned by Get-DbaCmsRegServer", "Syntax": "Resolve-DbaNetworkName [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Turbo] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Restart-DbaService", "Description": "Restarts the SQL Server related services on one or more computers. Will follow SQL Server service dependencies.\n\nRequires Local Admin rights on destination computer(s).", "Tags": [ "Service", "Instance", "Restart" ], "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "false", "$env:COMPUTERNAME" ], [ "InstanceName", "Only affects services that belong to the specific instances.", "Instance", false, "false", "" ], [ "Type", "Use -Type to collect only services of the desired SqlServiceType.\r\nCan be one of the following: \"Agent\",\"Browser\",\"Engine\",\"FullText\",\"SSAS\",\"SSIS\",\"SSRS\"", "", false, "false", "" ], [ "InputObject", "A collection of services from Get-DbaService", "ServiceCollection", true, "true (ByValue)", "" ], [ "Timeout", "How long to wait for the start/stop request completion before moving on. Specify 0 to wait indefinitely.", "", false, "false", "60" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", false, "false", "" ], [ "Force", "Will stop dependent SQL Server agents when stopping Engine services.", "", 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 cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "Restart-DbaSqlService", "Author": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Restarts SQL Server services on a computer.", "Name": "Restart-DbaService", "Links": "https://dbatools.io/Restart-DbaService", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRestart-DbaService -ComputerName sqlserver2014a\nRestarts the SQL Server related services on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027| Get-DbaService | Restart-DbaService\nGets the SQL Server related services on computers sql1, sql2 and sql3 and restarts them.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eRestart-DbaService -ComputerName sql1,sql2 -Instance MSSQLSERVER\nRestarts the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eRestart-DbaService -ComputerName $MyServers -Type SSRS\nRestarts the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRestart-DbaService -ComputerName sql1 -Type Engine -Force\nRestarts SQL Server database engine services on sql1 forcing dependent SQL Server Agent services to restart as well.", "Syntax": "Restart-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-Timeout \u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRestart-DbaService [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-Timeout \u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Restore-DbaBackupFromDirectory", "Description": "Please use `Get-ChildItem | Restore-DbaDatabase` instead. This command is no longer supported.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "SqlInstance", "The SQL Server instance to which you will be restoring the database.", "ServerInstance,SqlServer", true, "false", "" ], [ "Path", "Specifies the full path to the directory that contains the database backups. The SQL Server service must have read access to this path.", "", true, "false", "" ], [ "NoRecovery", "If this switch is enabled, the database is left in the No Recovery state to enable further backups to be added.", "", false, "false", "False" ], [ "ReuseSourceFolderStructure", "If this switch is enabled, the folder structure used on the instance where the backup was made will be recreated. By default, the database files will be restored to the default data and log \r\ndirectories for the instance you\u0027re restoring onto.", "ReuseFolderStructure", false, "false", "False" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Force", "If this switch is enabled, any existing database matching the name of a database being restored will be overwritten.", "", false, "false", "False" ] ], "Alias": "Restore-SqlBackupFromDirectory", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Please use `Get-ChildItem | Restore-DbaDatabase` instead. This command is no longer supported.", "Name": "Restore-DbaBackupFromDirectory", "Links": "https://dbatools.io/Restore-SqlBackupFromDirectory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRestore-SqlBackupFromDirectory -SqlInstance sqlcluster -Path \\\\fileserver\\share\\sqlbackups\\SQLSERVER2014A\nAll user databases contained within \\\\fileserver\\share\\sqlbackups\\SQLSERVERA will be restored to sqlcluster, down the most recent full/differential/logs.\nRequires -Version 3.0", "Syntax": "Restore-DbaBackupFromDirectory [-SqlInstance] \u003cDbaInstanceParameter\u003e [-Path] \u003cString\u003e [-NoRecovery] [-ReuseSourceFolderStructure] [[-SqlCredential] \u003cPSCredential\u003e] [-Force] [\u003cCommonParameters\u003e]" }, { "CommandName": "Restore-DbaDatabase", "Description": "Upon being passed a list of potential backups files this command will scan the files, select those that contain SQL Server\nbackup sets. It will then filter those files down to a set that can perform the requested restore, checking that we have a\nfull restore chain to the point in time requested by the caller.\n\nThe function defaults to working on a remote instance. This means that all paths passed in must be relative to the remote instance.\nXpDirTree will be used to perform the file scans\n\nVarious means can be used to pass in a list of files to be considered. The default is to non recursively scan the folder\npassed in.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted.", "", false, "false", "" ], [ "Path", "Path to SQL Server backup files.\nPaths passed in as strings will be scanned using the desired method, default is a non recursive folder scan\r\nAccepts multiple paths separated by \u0027,\u0027\nOr it can consist of FileInfo objects, such as the output of Get-ChildItem or Get-Item. This allows you to work with\r\nyour own file structures as needed", "", true, "true (ByValue)", "" ], [ "DatabaseName", "Name to restore the database under.\r\nOnly works with a single database restore. If multiple database are found in the provided paths then we will exit", "Name", false, "true (ByValue)", "" ], [ "DestinationDataDirectory", "Path to restore the SQL Server backups to on the target instance.\r\nIf only this parameter is specified, then all database files (data and log) will be restored to this location", "", false, "false", "" ], [ "DestinationLogDirectory", "Path to restore the database log files to.\r\nThis parameter can only be specified alongside DestinationDataDirectory.", "", false, "false", "" ], [ "DestinationFileStreamDirectory", "Path to restore FileStream data to\r\nThis parameter can only be specified alongside DestinationDataDirectory", "", false, "false", "" ], [ "RestoreTime", "Specify a DateTime object to which you want the database restored to. Default is to the latest point available in the specified backups", "", false, "false", "(Get-Date).AddYears(1)" ], [ "NoRecovery", "Indicates if the databases should be recovered after last restore. Default is to recover", "", false, "false", "False" ], [ "WithReplace", "Switch indicated is the restore is allowed to replace an existing database.", "", false, "false", "False" ], [ "XpDirTree", "Switch that indicated file scanning should be performed by the SQL Server instance using xp_dirtree\r\nThis will scan recursively from the passed in path\r\nYou must have sysadmin role membership on the instance for this to work.", "", false, "false", "False" ], [ "OutputScriptOnly", "Switch indicates that ONLY T-SQL scripts should be generated, no restore takes place", "", false, "false", "False" ], [ "VerifyOnly", "Switch indicate that restore should be verified", "", false, "false", "False" ], [ "MaintenanceSolutionBackup", "Switch to indicate the backup files are in a folder structure as created by Ola Hallengreen\u0027s maintenance scripts.\r\nThis switch enables a faster check for suitable backups. Other options require all files to be read first to ensure we have an anchoring full backup. Because we can rely on specific locations for \r\nbackups performed with OlaHallengren\u0027s backup solution, we can rely on file locations.", "", false, "false", "False" ], [ "FileMapping", "A hashtable that can be used to move specific files to a location.\r\n`$FileMapping = @{\u0027DataFile1\u0027=\u0027c:\\restoredfiles\\Datafile1.mdf\u0027;\u0027DataFile3\u0027=\u0027d:\\DataFile3.mdf\u0027}`\r\nAnd files not specified in the mapping will be restored to their original location\r\nThis Parameter is exclusive with DestinationDataDirectory", "", false, "false", "" ], [ "IgnoreLogBackup", "This switch tells the function to ignore transaction log backups. The process will restore to the latest full or differential backup point only", "", false, "false", "False" ], [ "UseDestinationDefaultDirectories", "Switch that tells the restore to use the default Data and Log locations on the target server. If they don\u0027t exist, the function will try to create them", "", false, "false", "False" ], [ "ReuseSourceFolderStructure", "By default, databases will be migrated to the destination Sql Server\u0027s default data and log directories. You can override this by specifying -ReuseSourceFolderStructure.\r\nThe same structure on the SOURCE will be kept exactly, so consider this if you\u0027re migrating between different versions and use part of Microsoft\u0027s default Sql structure (MSSql12.INSTANCE, etc)\n*Note, to reuse destination folder structure, specify -WithReplace", "", false, "false", "False" ], [ "DestinationFilePrefix", "This value will be prefixed to ALL restored files (log and data). This is just a simple string prefix. If you want to perform more complex rename operations then please use the FileMapping parameter\nThis will apply to all file move options, except for FileMapping", "", false, "false", "" ], [ "RestoredDatabaseNamePrefix", "A string which will be prefixed to the start of the restore Database\u0027s Name\r\nUseful if restoring a copy to the same sql server for testing.", "", false, "false", "" ], [ "TrustDbBackupHistory", "This switch can be used when piping the output of Get-DbaBackupHistory or Backup-DbaDatabase into this command.\r\nIt allows the user to say that they trust that the output from those commands is correct, and skips the file header read portion of the process. This means a faster process, but at the risk of not \r\nknowing till halfway through the restore that something is wrong with a file.", "", false, "false", "False" ], [ "MaxTransferSize", "Parameter to set the unit of transfer. Values must be a multiple by 64kb", "", false, "false", "0" ], [ "BlockSize", "Specifies the block size to use. Must be one of 0.5kb,1kb,2kb,4kb,8kb,16kb,32kb or 64kb\r\nCan be specified in bytes\r\nRefer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail", "", false, "false", "0" ], [ "BufferCount", "Number of I/O buffers to use to perform the operation.\r\nRefer to https://msdn.microsoft.com/en-us/library/ms178615.aspx for more detail", "", false, "false", "0" ], [ "DirectoryRecurse", "If specified the specified directory will be recursed into", "", 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" ], [ "StandbyDirectory", "If a directory is specified the database(s) will be restored into a standby state, with the standby file placed into this directory (which must exist, and be writable by the target Sql Server \r\ninstance)", "", false, "false", "" ], [ "Continue", "If specified we will to attempt to recover more transaction log backups onto database(s) in Recovering or Standby states", "", false, "false", "False" ], [ "AzureCredential", "The name of the SQL Server credential to be used if restoring from an Azure hosted backup using Storage Access Keys\r\nIf a backup path beginning http is passed in and this parameter is not specified then if a credential with a name matching the URL", "", false, "false", "" ], [ "ReplaceDbNameInFile", "If switch set and occurrence of the original database\u0027s name in a data or log file will be replace with the name specified in the DatabaseName parameter", "", false, "false", "False" ], [ "DestinationFileSuffix", "This value will be suffixed to ALL restored files (log and data). This is just a simple string suffix. If you want to perform more complex rename operations then please use the FileMapping parameter\nThis will apply to all file move options, except for FileMapping", "", false, "false", "" ], [ "Recover", "If set will perform recovery on the indicated database", "", false, "false", "False" ], [ "KeepCDC", "Indicates whether CDC information should be restored as part of the database", "", false, "false", "False" ], [ "AllowContinue", "By default, Restore-DbaDatabase will stop restoring any databases if it comes across an error.\r\nUse this switch to enable it to restore all databases without issues.", "", false, "false", "False" ], [ "GetBackupInformation", "Passing a string value into this parameter will cause a global variable to be created holding the output of Get-DbaBackupInformation", "", false, "false", "" ], [ "StopAfterGetBackupInformation", "Switch which will cause the function to exit after returning GetBackupInformation", "", false, "false", "False" ], [ "SelectBackupInformation", "Passing a string value into this parameter will cause a global variable to be created holding the output of Select-DbaBackupInformation", "", false, "false", "" ], [ "StopAfterSelectBackupInformation", "Switch which will cause the function to exit after returning SelectBackupInformation", "", false, "false", "False" ], [ "FormatBackupInformation", "Passing a string value into this parameter will cause a global variable to be created holding the output of Format-DbaBackupInformation", "", false, "false", "" ], [ "StopAfterFormatBackupInformation", "Switch which will cause the function to exit after returning FormatBackupInformation", "", false, "false", "False" ], [ "TestBackupInformation", "Passing a string value into this parameter will cause a global variable to be created holding the output of Test-DbaBackupInformation", "", false, "false", "" ], [ "StopAfterTestBackupInformation", "Switch which will cause the function to exit after returning TestBackupInformation", "", false, "false", "False" ], [ "PageRestore", "Passes in an object from Get-DbaSuspectPages containing suspect pages from a single database.\r\nSetting this Parameter will cause an Online Page restore if the target Instance is Enterprise Edition, or offline if not.\r\nThis will involve taking a tail log backup, so you must check your restore chain once it has completed", "", true, "false", "" ], [ "PageRestoreTailFolder", "This parameter passes in a location for the tail log backup required for page level restore", "", true, "false", "" ], [ "StatementTimeout", "Timeout in minutes. Defaults to infinity (restores can take a while.)", "", false, "false", "0" ], [ "WhatIf", "Shows what would happen if the command would execute, but does not actually perform the command", "wi", false, "false", "" ], [ "Confirm", "Prompts to confirm certain actions", "cf", false, "false", "" ] ], "Alias": "", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Restores a SQL Server Database from a set of backup files", "Name": "Restore-DbaDatabase", "Links": "https://dbatools.io/Restore-DbaDatabase", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups\nScans all the backup files in \\\\server2\\backups, filters them and restores the database to server1\\instance1\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups -MaintenanceSolutionBackup -DestinationDataDirectory c:\\restores\nScans all the backup files in \\\\server2\\backups$ stored in an Ola Hallengren style folder structure,\r\nfilters them and restores the database to the c:\\restores folder on server1\\instance1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-ChildItem c:\\SQLbackups1\\, \\\\server\\sqlbackups2 | Restore-DbaDatabase -SqlInstance server1\\instance1\nTakes the provided files from multiple directories and restores them on server1\\instance1\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$RestoreTime = Get-Date(\u002711:19 23/12/2016\u0027)\nPS C:\\\u003e Restore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups -MaintenanceSolutionBackup -DestinationDataDirectory c:\\restores -RestoreTime $RestoreTime\nScans all the backup files in \\\\server2\\backups stored in an Ola Hallengren style folder structure,\r\nfilters them and restores the database to the c:\\restores folder on server1\\instance1 up to 11:19 23/12/2016\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$result = Restore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups -DestinationDataDirectory c:\\restores -OutputScriptOnly\nPS C:\\\u003e $result | Select-Object -ExpandProperty Tsql | Out-File -Filepath c:\\scripts\\restore.sql\nScans all the backup files in \\\\server2\\backups stored in an Ola Hallengren style folder structure,\r\nfilters them and generate the T-SQL Scripts to restore the database to the latest point in time,\r\nand then stores the output in a file for later retrieval\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path c:\\backups -DestinationDataDirectory c:\\DataFiles -DestinationLogDirectory c:\\LogFile\nScans all the files in c:\\backups and then restores them onto the SQL Server Instance server1\\instance1, placing data files\r\nc:\\DataFiles and all the log files into c:\\LogFiles\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path http://demo.blob.core.windows.net/backups/dbbackup.bak -AzureCredential MyAzureCredential\nWill restore the backup held at http://demo.blob.core.windows.net/backups/dbbackup.bak to server1\\instance1. The connection to Azure will be made using the\r\ncredential MyAzureCredential held on instance Server1\\instance1\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path http://demo.blob.core.windows.net/backups/dbbackup.bak\nWill attempt to restore the backups from http://demo.blob.core.windows.net/backups/dbbackup.bak if a SAS credential with the name http://demo.blob.core.windows.net/backups exists on server1\\instance1\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003e$File = Get-ChildItem c:\\backups, \\\\server1\\backups -recurse\nPS C:\\\u003e $File | Restore-DbaDatabase -SqlInstance Server1\\Instance -UseDestinationDefaultDirectories\nThis will take all of the files found under the folders c:\\backups and \\\\server1\\backups, and pipeline them into\r\nRestore-DbaDatabase. Restore-DbaDatabase will then scan all of the files, and restore all of the databases included\r\nto the latest point in time covered by their backups. All data and log files will be moved to the default SQL Server\r\nfolder for those file types as defined on the target instance.\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003e$files = Get-ChildItem C:\\dbatools\\db1\nPS C:\\\u003e $files | Restore-DbaDatabase -SqlInstance server\\instance1 `\r\n\u003e\u003e -DestinationFilePrefix prefix -DatabaseName Restored `\r\n\u003e\u003e -RestoreTime (get-date \"14:58:30 22/05/2017\") `\r\n\u003e\u003e -NoRecovery -WithReplace -StandbyDirectory C:\\dbatools\\standby\r\n\u003e\u003e\r\nPS C:\\\u003e #It\u0027s in standby so we can peek at it\r\nPS C:\\\u003e Invoke-DbaQuery -SQLInstance server\\instance1 -Query \"select top 1 * from Restored.dbo.steps order by dt desc\"\r\nPS C:\\\u003e #Not quite there so let\u0027s roll on a bit:\r\nPS C:\\\u003e $files | Restore-DbaDatabase -SqlInstance server\\instance1 `\r\n\u003e\u003e -DestinationFilePrefix prefix -DatabaseName Restored `\r\n\u003e\u003e -continue -WithReplace -RestoreTime (get-date \"15:09:30 22/05/2017\") `\r\n\u003e\u003e -StandbyDirectory C:\\dbatools\\standby\r\n\u003e\u003e\r\nPS C:\\\u003e Invoke-DbaQuery -SQLInstance server\\instance1 -Query \"select top 1 * from restored.dbo.steps order by dt desc\"\r\nPS C:\\\u003e Restore-DbaDatabase -SqlInstance server\\instance1 -DestinationFilePrefix prefix -DatabaseName Restored -Continue -WithReplace\nIn this example we step through the backup files held in c:\\dbatools\\db1 folder.\r\nFirst we restore the database to a point in time in standby mode. This means we can check some details in the databases\r\nWe then roll it on a further 9 minutes to perform some more checks\r\nAnd finally we continue by rolling it all the way forward to the latest point in the backup.\r\nAt each step, only the log files needed to roll the database forward are restored.\n-------------------------- EXAMPLE 11 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server\\instance1 -Path c:\\backups -DatabaseName example1 -NoRecovery\nPS C:\\\u003e Restore-DbaDatabase -SqlInstance server\\instance1 -Recover -DatabaseName example1\nIn this example we restore example1 database with no recovery, and then the second call is to set the database to recovery.\n-------------------------- EXAMPLE 12 --------------------------\nPS C:\\\u003eGet-DbaBackupHistory - SqlInstance server\\instance1 -Database ProdFinance -Last | Restore-DbaDatabase -PageRestore\nPS C:\\\u003e $SuspectPage -PageRestoreTailFolder c:\\temp -TrustDbBackupHistory -AllowContinues\nGets a list of Suspect Pages using Get-DbaSuspectPage. The uses Get-DbaBackupHistory and Restore-DbaDatabase to perform a restore of the suspect pages and bring them up to date\r\nIf server\\instance1 is Enterprise edition this will be done online, if not it will be performed offline\r\nAllowContinue is required to make sure we cope with existing files\n-------------------------- EXAMPLE 13 --------------------------\nPS C:\\\u003e$BackupHistory = Get-DbaBackupInformation -SqlInstance sql2005 -Path \\\\backups\\sql2000\\ProdDb\nPS C:\\\u003e $BackupHistory | Restore-DbaDatabase -SqlInstance sql2000 -TrustDbBackupHistory\nDue to SQL Server 2000 not returning all the backup headers we cannot restore directly. As this is an issues with the SQL engine all we can offer is the following workaround\r\nThis will use a SQL Server instance \u003e 2000 to read the headers, and then pass them in to Restore-DbaDatabase as a BackupHistory object.\n-------------------------- EXAMPLE 14 --------------------------\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \"C:\\Temp\\devops_prod_full.bak\" -DatabaseName \"DevOps_DEV\" -ReplaceDbNameInFile\nPS C:\\\u003e Rename-DbaDatabase -SqlInstance server1\\instance1 -Database \"DevOps_DEV\" -LogicalName \"\u003cDBN\u003e_\u003cFT\u003e\"\nThis will restore the database from the \"C:\\Temp\\devops_prod_full.bak\" file, with the new name \"DevOps_DEV\" and store the different physical files with the new name. It will use the system default \r\nconfigured data and log locations.\r\nAfter the restore the logical names of the database files will be renamed with the \"DevOps_DEV_ROWS\" for MDF/NDF and \"DevOps_DEV_LOG\" for LDF\n-------------------------- EXAMPLE 15 --------------------------\nPS C:\\\u003e$FileStructure = @{\n\u003e\u003e \u0027database_data\u0027 = \u0027C:\\Data\\database_data.mdf\u0027\r\n\u003e\u003e \u0027database_log\u0027 = \u0027C:\\Log\\database_log.ldf\u0027\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Restore-DbaDatabase -SqlInstance server1 -Path \\\\ServerName\\ShareName\\File -DatabaseName database -FileMapping $FileStructure\nRestores \u0027database\u0027 to \u0027server1\u0027 and moves the files to new locations. The format for the $FileStructure HashTable is the file logical name as the Key, and the new location as the Value.", "Syntax": "Restore-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] -Path \u003cObject[]\u003e [-DatabaseName \u003cObject[]\u003e] [-DestinationDataDirectory \u003cString\u003e] [-DestinationLogDirectory \u003cString\u003e] [-DestinationFileStreamDirectory \u003cString\u003e] [-RestoreTime \u003cDateTime\u003e] [-NoRecovery] [-WithReplace] [-XpDirTree] [-OutputScriptOnly] [-VerifyOnly] [-MaintenanceSolutionBackup] [-FileMapping \u003cHashtable\u003e] [-IgnoreLogBackup] [-UseDestinationDefaultDirectories] [-ReuseSourceFolderStructure] [-DestinationFilePrefix \u003cString\u003e] [-RestoredDatabaseNamePrefix \u003cString\u003e] [-TrustDbBackupHistory] \r\n[-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-DirectoryRecurse] [-EnableException] [-StandbyDirectory \u003cString\u003e] [-Continue] [-AzureCredential \u003cString\u003e] [-ReplaceDbNameInFile] [-DestinationFileSuffix \u003cString\u003e] [-KeepCDC] [-AllowContinue] [-GetBackupInformation \u003cString\u003e] [-StopAfterGetBackupInformation] [-SelectBackupInformation \u003cString\u003e] [-StopAfterSelectBackupInformation] [-FormatBackupInformation \u003cString\u003e] [-StopAfterFormatBackupInformation] [-TestBackupInformation \u003cString\u003e] [-StopAfterTestBackupInformation] [-StatementTimeout \u003cInt32\u003e] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\nRestore-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] -Path \u003cObject[]\u003e [-DatabaseName \u003cObject[]\u003e] [-OutputScriptOnly] [-TrustDbBackupHistory] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-EnableException] [-AzureCredential \u003cString\u003e] [-AllowContinue] [-GetBackupInformation \u003cString\u003e] [-StopAfterGetBackupInformation] [-SelectBackupInformation \u003cString\u003e] [-StopAfterSelectBackupInformation] [-FormatBackupInformation \u003cString\u003e] [-StopAfterFormatBackupInformation] [-TestBackupInformation \u003cString\u003e] [-StopAfterTestBackupInformation] \r\n-PageRestore \u003cObject\u003e -PageRestoreTailFolder \u003cString\u003e [-StatementTimeout \u003cInt32\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nRestore-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-DatabaseName \u003cObject[]\u003e] [-OutputScriptOnly] [-EnableException] [-AzureCredential \u003cString\u003e] [-Recover] [-AllowContinue] [-GetBackupInformation \u003cString\u003e] [-StopAfterGetBackupInformation] [-SelectBackupInformation \u003cString\u003e] [-StopAfterSelectBackupInformation] [-FormatBackupInformation \u003cString\u003e] [-StopAfterFormatBackupInformation] [-TestBackupInformation \u003cString\u003e] [-StopAfterTestBackupInformation] [-StatementTimeout \u003cInt32\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Restore-DbaDbCertificate", "Description": "Imports certificates from.cer files using SMO.", "Tags": [ "Migration", "Certificate" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Path", "The Path the contains the certificate and private key files. The path can be a directory or a specific certificate.", "FullName", true, "true (ByValue)", "" ], [ "EncryptionPassword", "If specified this will be used to encrypt the private key.", "", false, "false", "" ], [ "Database", "The database where the certificate imports into. Defaults to master.", "", false, "false", "master" ], [ "Password", "Secure string used to decrypt the private key.", "", false, "false", "(Read-Host \"Password\" -AsSecureString)" ], [ "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" ], [ "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": "Restore-DbaDatabaseCertificate", "Author": "Jess Pomfret (@jpomfret), jesspomfret.com", "Synopsis": "Imports certificates from .cer files using SMO.", "Name": "Restore-DbaDbCertificate", "Links": "https://dbatools.io/Restore-DbaDbCertificate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRestore-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates -Password (ConvertTo-SecureString -Force -AsPlainText GoodPass1234!!)\nRestores all the certificates in the specified path, password is used to both decrypt and encrypt the private key.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRestore-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates\\DatabaseTDE.cer -Password (ConvertTo-SecureString -force -AsPlainText GoodPass1234!!)\nRestores the DatabaseTDE certificate to Server1 and uses the MasterKey to encrypt the private key.", "Syntax": "Restore-DbaDbCertificate [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cObject[]\u003e [[-EncryptionPassword] \u003cSecureString\u003e] [[-Database] \u003cString\u003e] [[-Password] \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Restore-DbaDbSnapshot", "Description": "Restores the database from the snapshot, discarding every modification made to the database\nNB: Restoring to a snapshot will result in every other snapshot of the same database to be dropped\nIt also fixes some long-standing bugs in SQL Server when restoring from snapshots", "Tags": [ "Snapshot", "Backup", "Restore", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "Credential", false, "false", "" ], [ "Database", "Restores from the last snapshot databases with this names only. You can pass either Databases or Snapshots", "Databases", false, "false", "" ], [ "ExcludeDatabase", "The database(s) to exclude - this list is auto-populated from the server", "", false, "false", "" ], [ "Snapshot", "Restores databases from snapshots with this names only. You can pass either Databases or Snapshots", "", false, "false", "" ], [ "InputObject", "Allows piping from other Snapshot commands", "", false, "true (ByValue)", "" ], [ "Force", "If restoring from a snapshot involves dropping any other snapshot, you need to explicitly\r\nuse -Force to let this command delete the ones not involved in the restore process.\r\nAlso, -Force will forcibly kill all running queries that prevent the restore process.", "", 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", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step.", "cf", false, "false", "" ] ], "Alias": "Restore-DbaDatabaseSnapshot", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Restores databases from snapshots", "Name": "Restore-DbaDbSnapshot", "Links": "https://dbatools.io/Restore-DbaDbSnapshot", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRestore-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting\nRestores HR and Accounting databases using the latest snapshot available\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRestore-DbaDbSnapshot -SqlInstance sql2014 -Database HR -Force\nRestores HR database from latest snapshot and kills any active connections in the database on sql2014.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 -Database HR | Restore-DbaDbSnapshot -Force\nRestores HR database from latest snapshot and kills any active connections in the database on sql2016.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -PassThru | Restore-DbaDbSnapshot\nAllows the selection of snapshots on sql2016 to restore\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eRestore-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, Accounting_snap_20161101\nRestores databases from snapshots named HR_snap_20161201 and Accounting_snap_20161101", "Syntax": "Restore-DbaDbSnapshot [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Snapshot] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Resume-DbaAgDbDataMovement", "Description": "Resumes data movement for an availability group database on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The availability group where the database movement will be resumeed.", "", false, "false", "" ], [ "Database", "The database or databases to resume movement upon.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaAgDatabase", "", 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" ], [ "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": "Resumes data movement for an availability group database on a SQL Server instance.", "Name": "Resume-DbaAgDbDataMovement", "Links": "https://dbatools.io/Resume-DbaAgDbDataMovement", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eResume-DbaAgDbDataMovement -SqlInstance sql2017a -AvailabilityGroup ag1 -Database db1, db2\nResumes data movement on db1 and db2 to ag1 on sql2017a. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sql2017a, sql2019 | Out-GridView -Passthru | Resume-DbaAgDbDataMovement -Confirm:$false\nResumes data movement on the selected availability group databases. Does not prompt for confirmation.", "Syntax": "Resume-DbaAgDbDataMovement [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Revoke-DbaAgPermission", "Description": "Revokes endpoint and availability group permissions to a login.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Login", "The login or logins to modify.", "", false, "false", "" ], [ "AvailabilityGroup", "Only modify specific availability groups.", "", false, "false", "" ], [ "Type", "Specify type: Endpoint or AvailabilityGroup. Endpoint will modify the DatabaseMirror endpoint type.", "", true, "false", "" ], [ "Permission", "Revokes one or more permissions:\r\n Alter\r\n Connect\r\n Control\r\n CreateAnyDatabase\r\n CreateSequence\r\n Delete\r\n Execute\r\n Impersonate\r\n Insert\r\n Receive\r\n References\r\n Select\r\n Send\r\n TakeOwnership\r\n Update\r\n ViewChangeTracking\r\n ViewDefinition\nConnect is default.", "", false, "false", "Connect" ], [ "InputObject", "Enables piping from Get-DbaLogin.", "", 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" ], [ "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": "Revokes endpoint and availability group permissions to a login.", "Name": "Revoke-DbaAgPermission", "Links": "https://dbatools.io/Revoke-DbaAgPermission", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eRevoke-DbaAgPermission -SqlInstance sql2017a -Type AvailabilityGroup -AvailabilityGroup SharePoint -Login ad\\spservice -Permission CreateAnyDatabase\nRemoves CreateAnyDatabase permissions from ad\\spservice on the SharePoint availability group on sql2017a. Does not prompt for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eRevoke-DbaAgPermission -SqlInstance sql2017a -Type AvailabilityGroup -AvailabilityGroup ag1, ag2 -Login ad\\spservice -Permission CreateAnyDatabase -Confirm\nRemoves CreateAnyDatabase permissions from ad\\spservice on the ag1 and ag2 availability groups on sql2017a. Prompts for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2017a | Out-GridView -Passthru | Revoke-DbaAgPermission -Type EndPoint\nRevokes the selected logins Connect permissions on the DatabaseMirroring endpoint for sql2017a.", "Syntax": "Revoke-DbaAgPermission [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [-Type] \u003cString[]\u003e [[-Permission] \u003cString[]\u003e] [[-InputObject] \u003cLogin[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Save-DbaDiagnosticQueryScript", "Description": "The dbatools module will have the diagnostic queries pre-installed. Use this only to update to a more recent version or specific versions.\n\nThis function is mainly used by Invoke-DbaDiagnosticQuery, but can also be used independently to download the Glenn Berry DMV scripts.\n\nUse this function to pre-download the scripts from a device with an Internet connection.\n\nThe function Invoke-DbaDiagnosticQuery will try to download these scripts automatically, but it obviously needs an internet connection to do that.", "Tags": [ "Diagnostic", "DMV", "Troubleshooting" ], "Params": [ [ "Path", "Specifies the path to the output", "", false, "false", "[Environment]::GetFolderPath(\"mydocuments\")" ], [ "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": "Save-DbaDiagnosticQueryScript downloads the most recent version of all Glenn Berry DMV scripts", "Name": "Save-DbaDiagnosticQueryScript", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSave-DbaDiagnosticQueryScript -Path c:\\temp\nDownloads the most recent version of all Glenn Berry DMV scripts to the specified location.\r\nIf Path is not specified, the \"My Documents\" location will be used.", "Syntax": "Save-DbaDiagnosticQueryScript [[-Path] \u003cFileInfo\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Select-DbaBackupInformation", "Description": "Select-DbaBackupInformation filters out a subset of backups from the dbatools backup history object with parameters supplied.", "Tags": [ "Backup", "Restore" ], "Params": [ [ "BackupHistory", "A dbatools.BackupHistory object containing backup history records", "", true, "true (ByValue)", "" ], [ "RestoreTime", "The point in time you want to restore to", "", false, "false", "(get-date).addmonths(1)" ], [ "IgnoreLogs", "This switch will cause Log Backups to be ignored. So will restore to the last Full or Diff backup only", "", false, "false", "False" ], [ "IgnoreDiffs", "This switch will cause Differential backups to be ignored. Unless IgnoreLogs is specified, restore to point in time will still occur, just using all available log backups", "", false, "false", "False" ], [ "DatabaseName", "A string array of Database Names that you want to filter to", "", false, "false", "" ], [ "ServerName", "A string array of Server Names that you want to filter", "", false, "false", "" ], [ "ContinuePoints", "The Output of Get-RestoreContinuableDatabase while provides \u0027Database\u0027,redo_start_lsn,\u0027FirstRecoveryForkID\u0027 values. Used to filter backups to continue a restore on a database\r\nSets IgnoreDiffs, and also filters databases to only those within the ContinuePoints object, or the ContinuePoints object AND DatabaseName if both specified", "", false, "false", "" ], [ "LastRestoreType", "The Output of Get-DbaDbRestoreHistory -last\r\nThis is used to check the last type of backup to a database to see if a differential backup can be restored", "", 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": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Select a subset of backups from a dbatools backup history object", "Name": "Select-DbaBackupInformation", "Links": "https://dbatools.io/Select-DbaBackupInformation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\nPS C:\\\u003e $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1)\nReturns all backups needed to restore all the backups in \\\\server1\\backups$ to 1 hour ago\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\nPS C:\\\u003e $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -DatabaseName ProdFinance\nReturns all the backups needed to restore Database ProdFinance to an hour ago\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\nPS C:\\\u003e $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreLogs\nReturns all the backups in \\\\server1\\backups$ to restore to as close prior to 1 hour ago as can be managed with only full and differential backups\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\nPS C:\\\u003e $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreDiffs\nReturns all the backups in \\\\server1\\backups$ to restore to 1 hour ago using only Full and Diff backups.", "Syntax": "Select-DbaBackupInformation [-BackupHistory] \u003cObject\u003e [[-RestoreTime] \u003cDateTime\u003e] [-IgnoreLogs] [-IgnoreDiffs] [[-DatabaseName] \u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-ContinuePoints] \u003cObject\u003e] [[-LastRestoreType] \u003cObject\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgentAlert", "Description": "Set-DbaAgentAlert updates an alert in the SQL Server Agent with parameters supplied.", "Tags": [ "Agent", "Alert" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Alert", "The name of the alert.", "", false, "false", "" ], [ "NewName", "The new name for the alert.", "", false, "false", "" ], [ "Enabled", "Enabled the alert.", "", false, "false", "False" ], [ "Disabled", "Disabled the alert.", "", false, "false", "False" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", false, "false", "False" ], [ "InputObject", "Enables piping alert objects", "", 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.", "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": "Garry Bargsley (@gbargsley), garrybargsley.com", "Synopsis": "Set-DbaAgentAlert updates a the status of a SQL Agent Alert.", "Name": "Set-DbaAgentAlert", "Links": "https://dbatools.io/Set-DbaAgentAlert", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1 -Alert \u0027Severity 025: Fatal Error\u0027 -Disabled\nChanges the alert to disabled.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1 -Alert \u0027Severity 025: Fatal Error\u0027, \u0027Error Number 825\u0027, \u0027Error Number 824\u0027 -Enabled\nChanges multiple alerts to enabled.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1, sql2, sql3 -Alert \u0027Severity 025: Fatal Error\u0027, \u0027Error Number 825\u0027, \u0027Error Number 824\u0027 -Enabled\nChanges multiple alerts to enabled on multiple servers.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1 -Alert \u0027Severity 025: Fatal Error\u0027 -Disabled -WhatIf\nDoesn\u0027t Change the alert but shows what would happen.", "Syntax": "Set-DbaAgentAlert [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Alert] \u003cObject[]\u003e] [[-NewName] \u003cString\u003e] [-Enabled] [-Disabled] [-Force] [[-InputObject] \u003cAlert[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgentJob", "Description": "Set-DbaAgentJob updates a job in the SQL Server Agent with parameters supplied.", "Tags": [ "Agent", "Job" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Job", "The name of the job.", "", false, "false", "" ], [ "Schedule", "Schedule to attach to job. This can be more than one schedule.", "", false, "false", "" ], [ "ScheduleId", "Schedule ID to attach to job. This can be more than one schedule ID.", "", false, "false", "" ], [ "NewName", "The new name for the job.", "", false, "false", "" ], [ "Enabled", "Enabled the job.", "", false, "false", "False" ], [ "Disabled", "Disabled the job", "", false, "false", "False" ], [ "Description", "The description of the job.", "", false, "false", "" ], [ "StartStepId", "The identification number of the first step to execute for the job.", "", false, "false", "0" ], [ "Category", "The category of the job.", "", false, "false", "" ], [ "OwnerLogin", "The name of the login that owns the job.", "", false, "false", "" ], [ "EventLogLevel", "Specifies when to place an entry in the Microsoft Windows application log for this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "EmailLevel", "Specifies when to send an e-mail upon the completion of this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "NetsendLevel", "Specifies when to send a network message upon the completion of this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "PageLevel", "Specifies when to send a page upon the completion of this job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "EmailOperator", "The e-mail name of the operator to whom the e-mail is sent when EmailLevel is reached.", "", false, "false", "" ], [ "NetsendOperator", "The name of the operator to whom the network message is sent.", "", false, "false", "" ], [ "PageOperator", "The name of the operator to whom a page is sent.", "", false, "false", "" ], [ "DeleteLevel", "Specifies when to delete the job.\r\nAllowed values 0, \"Never\", 1, \"OnSuccess\", 2, \"OnFailure\", 3, \"Always\"\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", false, "false", "False" ], [ "InputObject", "Enables piping job objects", "", 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.", "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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Set-DbaAgentJob updates a job.", "Name": "Set-DbaAgentJob", "Links": "https://dbatools.io/Set-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgentJob sql1 -Job Job1 -Disabled\nChanges the job to disabled\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaAgentJob sql1 -Job Job1 -OwnerLogin user1\nChanges the owner of the job\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1 -EventLogLevel OnSuccess\nChanges the job and sets the notification to write to the Windows Application event log on success\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1 -EmailLevel OnFailure -EmailOperator dba\nChanges the job and sets the notification to send an e-mail to the e-mail operator\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1, Job2, Job3 -Enabled\nChanges multiple jobs to enabled\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job Job1, Job2, Job3 -Enabled\nChanges multiple jobs to enabled on multiple servers\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1 -Description \u0027Just another job\u0027 -Whatif\nDoesn\u0027t Change the job but shows what would happen.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job \u0027Job One\u0027 -Description \u0027Job One\u0027\nChanges a job with the name \"Job1\" on multiple servers to have another description\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003esql1, sql2, sql3 | Set-DbaAgentJob -Job Job1 -Description \u0027Job One\u0027\nChanges a job with the name \"Job1\" on multiple servers to have another description using pipe line", "Syntax": "Set-DbaAgentJob [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [[-Schedule] \u003cObject[]\u003e] [[-ScheduleId] \u003cInt32[]\u003e] [[-NewName] \u003cString\u003e] [-Enabled] [-Disabled] [[-Description] \u003cString\u003e] [[-StartStepId] \u003cInt32\u003e] [[-Category] \u003cString\u003e] [[-OwnerLogin] \u003cString\u003e] [[-EventLogLevel] \u003cObject\u003e] [[-EmailLevel] \u003cObject\u003e] [[-NetsendLevel] \u003cObject\u003e] [[-PageLevel] \u003cObject\u003e] [[-EmailOperator] \u003cString\u003e] [[-NetsendOperator] \u003cString\u003e] [[-PageOperator] \u003cString\u003e] [[-DeleteLevel] \u003cObject\u003e] [-Force] [[-InputObject] \u003cJob[]\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgentJobCategory", "Description": "Set-DbaAgentJobCategory makes it possible to change a job category.", "Tags": [ "Agent", "Job", "JobCategory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Category", "The name of the category", "", false, "false", "" ], [ "NewName", "New name of the job category", "", false, "false", "" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Set-DbaAgentJobCategory changes a job category.", "Name": "Set-DbaAgentJobCategory", "Links": "https://dbatools.io/Set-DbaAgentJobCategory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 1\u0027 -NewName \u0027Category 2\u0027\nChange the name of the category from \u0027Category 1\u0027 to \u0027Category 2\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaAgentJobCategory -SqlInstance sql1, sql2 -Category Category1, Category2 -NewName cat1, cat2\nRename multiple jobs in one go on multiple servers.", "Syntax": "Set-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \u003cString[]\u003e] [[-NewName] \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgentJobOutputFile", "Description": "Sets the Output File for a step of an agent job with the Job Names and steps provided dynamically if required", "Tags": [ "Agent", "Job", "SqlAgent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue, ByPropertyName)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user be it Windows or SQL Server. Windows users are determined by the existence of a backslash, so if you are intending to use an \r\nalternative Windows connection instead of a SQL login, ensure it contains a backslash.", "", false, "true (ByValue, ByPropertyName)", "" ], [ "Job", "The job to process - this list is auto-populated from the server.", "", false, "false", "" ], [ "Step", "The Agent Job Step to provide Output File Path for. Also available dynamically", "", false, "true (ByValue, ByPropertyName)", "" ], [ "OutputFile", "The Full Path to the New Output file", "", true, "true (ByValue, ByPropertyName)", "" ], [ "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": "Rob Sewell, https://sqldbawithabeard.com", "Synopsis": "Set the output file for a step within an Agent job.", "Name": "Set-DbaAgentJobOutputFile", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Job \u0027The Agent Job\u0027 -OutPutFile E:\\Logs\\AgentJobStepOutput.txt\nSets the Job step for The Agent job on SERVERNAME to E:\\Logs\\AgentJobStepOutput.txt", "Syntax": "Set-DbaAgentJobOutputFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-Step \u003cObject[]\u003e] -OutputFile \u003cString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgentJobStep", "Description": "Set-DbaAgentJobStep updates a job step in the SQL Server Agent with parameters supplied.", "Tags": [ "Agent", "Job", "JobStep" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Job", "The name of the job. Can be null if the the job id is being used.", "", true, "false", "" ], [ "StepName", "The name of the step.", "", true, "false", "" ], [ "NewName", "The new name for the step in case it needs to be renamed.", "", false, "false", "" ], [ "Subsystem", "The subsystem used by the SQL Server Agent service to execute command.\r\nAllowed values \u0027ActiveScripting\u0027,\u0027AnalysisCommand\u0027,\u0027AnalysisQuery\u0027,\u0027CmdExec\u0027,\u0027Distribution\u0027,\u0027LogReader\u0027,\u0027Merge\u0027,\u0027PowerShell\u0027,\u0027QueueReader\u0027,\u0027Snapshot\u0027,\u0027Ssis\u0027,\u0027TransactSql\u0027", "", false, "false", "" ], [ "Command", "The commands to be executed by SQLServerAgent service through subsystem.", "", false, "false", "" ], [ "CmdExecSuccessCode", "The value returned by a CmdExec subsystem command to indicate that command executed successfully.", "", false, "false", "0" ], [ "OnSuccessAction", "The action to perform if the step succeeds.\r\nAllowed values \"QuitWithSuccess\" (default), \"QuitWithFailure\", \"GoToNextStep\", \"GoToStep\".\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "OnSuccessStepId", "The ID of the step in this job to execute if the step succeeds and OnSuccessAction is \"GoToNextStep\".", "", false, "false", "0" ], [ "OnFailAction", "The action to perform if the step fails.\r\nAllowed values \"QuitWithSuccess\" (default), \"QuitWithFailure\", \"GoToNextStep\", \"GoToStep\".\r\nThe text value van either be lowercase, uppercase or something in between as long as the text is correct.", "", false, "false", "" ], [ "OnFailStepId", "The ID of the step in this job to execute if the step fails and OnFailAction is \"GoToNextStep\".", "", false, "false", "0" ], [ "Database", "The name of the database in which to execute a Transact-SQL step. The default is \u0027master\u0027.", "", false, "false", "" ], [ "DatabaseUser", "The name of the user account to use when executing a Transact-SQL step. The default is \u0027sa\u0027.", "", false, "false", "" ], [ "RetryAttempts", "The number of retry attempts to use if this step fails. The default is 0.", "", false, "false", "0" ], [ "RetryInterval", "The amount of time in minutes between retry attempts. The default is 0.", "", false, "false", "0" ], [ "OutputFileName", "The name of the file in which the output of this step is saved.", "", false, "false", "" ], [ "Flag", "Sets the flag(s) for the job step.\nFlag Description\r\n----------------------------------------------------------------------------\r\nAppendAllCmdExecOutputToJobHistory Job history, including command output, is appended to the job history file.\r\nAppendToJobHistory Job history is appended to the job history file.\r\nAppendToLogFile Job history is appended to the SQL Server log file.\r\nAppendToTableLog Job history is appended to a log table.\r\nLogToTableWithOverwrite Job history is written to a log table, overwriting previous contents.\r\nNone Job history is not appended to a file.\r\nProvideStopProcessEvent Job processing is stopped.", "", false, "false", "" ], [ "ProxyName", "The name of the proxy that the job step runs as.", "", 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" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.", "", 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": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Set-DbaAgentJobStep updates a job step.", "Name": "Set-DbaAgentJobStep", "Links": "https://dbatools.io/Set-DbaAgentJobStep", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1 -NewName Step2\nChanges the name of the step in \"Job1\" with the name Step1 to Step2\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1 -Database msdb\nChanges the database of the step in \"Job1\" with the name Step1 to msdb\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1 -Job Job1, Job2 -StepName Step1 -Database msdb\nChanges job steps in multiple jobs with the name Step1 to msdb\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1, Job2 -StepName Step1 -Database msdb\nChanges job steps in multiple jobs on multiple servers with the name Step1 to msdb\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1 -StepName Step1 -Database msdb\nChanges the database of the step in \"Job1\" with the name Step1 to msdb for multiple servers\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003esql1, sql2, sql3 | Set-DbaAgentJobStep -Job Job1 -StepName Step1 -Database msdb\nChanges the database of the step in \"Job1\" with the name Step1 to msdb for multiple servers using pipeline", "Syntax": "Set-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e [-StepName] \u003cString\u003e [[-NewName] \u003cString\u003e] [[-Subsystem] \u003cString\u003e] [[-Command] \u003cString\u003e] [[-CmdExecSuccessCode] \u003cInt32\u003e] [[-OnSuccessAction] \u003cString\u003e] [[-OnSuccessStepId] \u003cInt32\u003e] [[-OnFailAction] \u003cString\u003e] [[-OnFailStepId] \u003cInt32\u003e] [[-Database] \u003cString\u003e] [[-DatabaseUser] \u003cString\u003e] [[-RetryAttempts] \u003cInt32\u003e] [[-RetryInterval] \u003cInt32\u003e] [[-OutputFileName] \u003cString\u003e] [[-Flag] \u003cString[]\u003e] [[-ProxyName] \u003cString\u003e] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgentSchedule", "Description": "Set-DbaAgentSchedule will help update a schedule for a job. It does not attach the schedule to a job.", "Tags": [ "Agent", "Job", "JobStep" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Job", "The name of the job that has the schedule.", "", true, "true (ByValue)", "" ], [ "ScheduleName", "The name of the schedule.", "", true, "true (ByValue)", "" ], [ "NewName", "The new name for the schedule.", "", false, "false", "" ], [ "Enabled", "Set the schedule to enabled.", "", false, "false", "False" ], [ "Disabled", "Set the schedule to disabled.", "", false, "false", "False" ], [ "FrequencyType", "A value indicating when a job is to be executed.\r\nAllowed values are 1, \"Once\", 4, \"Daily\", 8, \"Weekly\", 16, \"Monthly\", 32, \"MonthlyRelative\", 64, \"AgentStart\", 128 or \"IdleComputer\"", "", false, "false", "" ], [ "FrequencyInterval", "The days that a job is executed\r\nAllowed values are 1, \"Sunday\", 2, \"Monday\", 4, \"Tuesday\", 8, \"Wednesday\", 16, \"Thursday\", 32, \"Friday\", 64, \"Saturday\", 62, \"Weekdays\", 65, \"Weekend\", 127, \"EveryDay\".\r\nIf 62, \"Weekdays\", 65, \"Weekend\", 127, \"EveryDay\" is used it overwwrites any other value that has been passed before.", "", false, "false", "" ], [ "FrequencySubdayType", "Specifies the units for the subday FrequencyInterval.\r\nAllowed values are 1, \"Time\", 2, \"Seconds\", 4, \"Minutes\", 8 or \"Hours\"", "", false, "false", "" ], [ "FrequencySubdayInterval", "The number of subday type periods to occur between each execution of a job.", "", false, "false", "0" ], [ "FrequencyRelativeInterval", "A job\u0027s occurrence of FrequencyInterval in each month, if FrequencyInterval is 32 (monthlyrelative).", "", false, "false", "" ], [ "FrequencyRecurrenceFactor", "The number of weeks or months between the scheduled execution of a job. FrequencyRecurrenceFactor is used only if FrequencyType is 8, \"Weekly\", 16, \"Monthly\", 32 or \"MonthlyRelative\".", "", false, "false", "0" ], [ "StartDate", "The date on which execution of a job can begin.", "", false, "false", "" ], [ "EndDate", "The date on which execution of a job can stop.", "", false, "false", "" ], [ "StartTime", "The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", false, "false", "" ], [ "EndTime", "The time on any day to end execution of a job. Format HHMMSS / 24 hour clock.\r\nExample: \u0027010000\u0027 for 01:00:00 AM.\r\nExample: \u0027140000\u0027 for 02:00:00 PM.", "", 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" ], [ "Force", "The force parameter will ignore some errors in the parameters and assume defaults.\r\nIt will also remove the any present schedules with the same name for the specific job.", "", 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": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Set-DbaAgentSchedule updates a schedule in the msdb database.", "Name": "Set-DbaAgentSchedule", "Links": "https://dbatools.io/Set-DbaAgentSchedule", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1 -Job Job1 -ScheduleName daily -Enabled\nChanges the schedule for Job1 with the name \u0027daily\u0027 to enabled\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1 -Job Job1 -ScheduleName daily -NewName weekly -FrequencyType Weekly -FrequencyInterval Monday, Wednesday, Friday\nChanges the schedule for Job1 with the name daily to have a new name weekly\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1 -Job Job1, Job2, Job3 -ScheduleName daily -StartTime \u0027230000\u0027\nChanges the start time of the schedule for Job1 to 11 PM for multiple jobs\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -Job Job1 -ScheduleName daily -Enabled\nChanges the schedule for Job1 with the name daily to enabled on multiple servers\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003esql1, sql2, sql3 | Set-DbaAgentSchedule -Job Job1 -ScheduleName \u0027daily\u0027 -Enabled\nChanges the schedule for Job1 with the name \u0027daily\u0027 to enabled on multiple servers using pipe line", "Syntax": "Set-DbaAgentSchedule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e [-ScheduleName] \u003cString\u003e [[-NewName] \u003cString\u003e] [-Enabled] [-Disabled] [[-FrequencyType] \u003cObject\u003e] [[-FrequencyInterval] \u003cObject[]\u003e] [[-FrequencySubdayType] \u003cObject\u003e] [[-FrequencySubdayInterval] \u003cInt32\u003e] [[-FrequencyRelativeInterval] \u003cObject\u003e] [[-FrequencyRecurrenceFactor] \u003cInt32\u003e] [[-StartDate] \u003cString\u003e] [[-EndDate] \u003cString\u003e] [[-StartTime] \u003cString\u003e] [[-EndTime] \u003cString\u003e] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgListener", "Description": "Sets a listener property for an availability group on a SQL Server instance.\n\nBasically, only the port is settable at this time, so this command updates the listener port.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The Availability Group to which a property will be changed.", "", false, "false", "" ], [ "Listener", "Modify only specific listeners.", "", false, "false", "" ], [ "Port", "Sets the port number used to communicate with the availability group.", "", true, "false", "0" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup", "", 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" ], [ "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": "Sets a listener property for an availability group on a SQL Server instance.", "Name": "Set-DbaAgListener", "Links": "https://dbatools.io/Set-DbaAgListener", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgListener -SqlInstance sql2017 -AvailabilityGroup SharePoint -Port 14333\nChanges the port for the SharePoint AG Listener on sql2017. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgListener -SqlInstance sql2017 | Out-GridView -Passthru | Set-DbaAgListener -Port 1433 -Confirm:$false\nChanges the port for selected AG listeners to 1433. Does not prompt for confirmation.", "Syntax": "Set-DbaAgListener [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [[-Listener] \u003cString[]\u003e] [-Port] \u003cInt32\u003e [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAgReplica", "Description": "Sets the properties for a replica to an availability group on a SQL Server instance.\n\nAutomatically creates a database mirroring endpoint if required.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The availability group of the replica.", "", false, "false", "" ], [ "Replica", "The replicas to modify.", "", false, "false", "" ], [ "AvailabilityMode", "Sets the availability mode of the availability group replica. Options are: AsynchronousCommit and SynchronousCommit. SynchronousCommit is default.", "", false, "false", "" ], [ "FailoverMode", "Sets the failover mode of the availability group replica. Options are Automatic and Manual.", "", false, "false", "" ], [ "BackupPriority", "Sets the backup priority availability group replica. Default is 50.", "", false, "false", "0" ], [ "ConnectionModeInPrimaryRole", "Sets the connection intent modes of an Availability Replica in primary role.", "", false, "false", "" ], [ "ConnectionModeInSecondaryRole", "Sets the connection modes of an Availability Replica in secondary role.", "", false, "false", "" ], [ "SeedingMode", "Specifies how the secondary replica will be initially seeded.\nAutomatic enables direct seeding. This method will seed the secondary replica over the network. This method does not require you to backup and restore a copy of the primary database on the replica.\nManual requires you to create a backup of the database on the primary replica and manually restore that backup on the secondary replica.", "", false, "false", "" ], [ "EndpointUrl", "The endpoint URL.", "", false, "false", "" ], [ "ReadonlyRoutingConnectionUrl", "Sets the read only routing connection url for the availability replica.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaAgReplica.", "", 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" ], [ "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": "Sets the properties for a replica to an availability group on a SQL Server instance.", "Name": "Set-DbaAgReplica", "Links": "https://dbatools.io/Set-DbaAgReplica", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaAgReplica -SqlInstance sql2016 -Replica sql2016 -AvailabilityGroup SharePoint -BackupPriority 5000\nSets the backup priority to 5000 for the sql2016 replica for the SharePoint availability group on sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sql2016 | Out-GridView -Passthru | Set-DbaAgReplica -BackupPriority 5000\nSets the backup priority to 5000 for the selected availability groups.", "Syntax": "Set-DbaAgReplica [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString\u003e] [[-Replica] \u003cString\u003e] [[-AvailabilityMode] \u003cString\u003e] [[-FailoverMode] \u003cString\u003e] [[-BackupPriority] \u003cInt32\u003e] [[-ConnectionModeInPrimaryRole] \u003cString\u003e] [[-ConnectionModeInSecondaryRole] \u003cString\u003e] [[-SeedingMode] \u003cString\u003e] [[-EndpointUrl] \u003cString\u003e] [[-ReadonlyRoutingConnectionUrl] \u003cString\u003e] [[-InputObject] \u003cAvailabilityReplica\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaAvailabilityGroup", "Description": "Sets availability group properties on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "Only set specific availability group properties.", "", false, "false", "" ], [ "AllAvailabilityGroups", "Set properties for all availability group on an instance.", "", false, "false", "False" ], [ "DtcSupportEnabled", "Enables DtcSupport.", "", false, "false", "False" ], [ "ClusterType", "Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.\r\nOptions include: External, Wsfc or None.", "", false, "false", "" ], [ "AutomatedBackupPreference", "Specifies how replicas in the primary role are treated in the evaluation to pick the desired replica to perform a backup.", "", false, "false", "" ], [ "FailureConditionLevel", "Specifies the different conditions that can trigger an automatic failover in Availability Group.", "", false, "false", "" ], [ "HealthCheckTimeout", "This setting used to specify the length of time, in milliseconds, that the SQL Server resource DLL should wait for information returned by the sp_server_diagnostics stored procedure before reporting \r\nthe Always On Failover Cluster Instance (FCI) as unresponsive.\nChanges that are made to the timeout settings are effective immediately and do not require a restart of the SQL Server resource.\nDefaults is 30000 (30 seconds).", "", false, "false", "0" ], [ "BasicAvailabilityGroup", "Indicates whether the availability group is basic. Basic availability groups like pumpkin spice and uggs.\nhttps://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/basic-availability-groups-always-on-availability-groups", "", false, "false", "False" ], [ "DatabaseHealthTrigger", "Indicates whether the availability group triggers the database health.", "", false, "false", "False" ], [ "IsDistributedAvailabilityGroup", "Indicates whether the availability group is distributed.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup.", "", 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" ], [ "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": "Sets availability group properties on a SQL Server instance.", "Name": "Set-DbaAvailabilityGroup", "Links": "https://dbatools.io/Set-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2016 | Set-DbaAvailabilityGroup -DtcSupportEnabled\nEnables DTC for all availability groups on sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2016 -AvailabilityGroup AG1 | Set-DbaAvailabilityGroup -DtcSupportEnabled:$false\nDisables DTC support for the availability group AG1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaAvailabilityGroup -SqlInstance sql2016 -AvailabilityGroup AG1 -DtcSupportEnabled:$false\nDisables DTC support for the availability group AG1", "Syntax": "Set-DbaAvailabilityGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString[]\u003e] [-AllAvailabilityGroups] [-DtcSupportEnabled] [[-ClusterType] \u003cString\u003e] [[-AutomatedBackupPreference] \u003cString\u003e] [[-FailureConditionLevel] \u003cString\u003e] [[-HealthCheckTimeout] \u003cInt32\u003e] [-BasicAvailabilityGroup] [-DatabaseHealthTrigger] [-IsDistributedAvailabilityGroup] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaCmConnection", "Description": "Configures a connection object for use in remote computer management.\nThis function will either create new records for computers that have no connection registered so far, or it will configure existing connections if already present.\n\nAs such it can be handy in making bulk-edits on connections or manually adjusting some settings.", "Tags": [ "ComputerManagement", "CIM" ], "Params": [ [ "ComputerName", "The computer to build the connection object for.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "The credential to register.", "", false, "false", "" ], [ "UseWindowsCredentials", "Whether using the default windows credentials is legit.\r\nNot setting this will not exclude using windows credentials, but only not pre-confirm them as working.", "", false, "false", "False" ], [ "OverrideExplicitCredential", "Setting this will enable the credential override.\r\nThe override will cause the system to ignore explicitly specified credentials, so long as known, good credentials are available.", "", false, "false", "False" ], [ "OverrideConnectionPolicy", "Setting this will configure the connection policy override.\r\nBy default, global configurations enforce, which connection type is available at all and which is disabled.", "", false, "false", "False" ], [ "DisabledConnectionTypes", "Explicitly disable connection types.\r\nThese types will then not be used for connecting to the computer.", "", false, "false", "None" ], [ "DisableBadCredentialCache", "Will prevent the caching of credentials if set to true.", "", false, "false", "False" ], [ "DisableCimPersistence", "Will prevent Cim-Sessions to be reused.", "", false, "false", "False" ], [ "DisableCredentialAutoRegister", "Will prevent working credentials from being automatically cached", "", false, "false", "False" ], [ "EnableCredentialFailover", "Will enable automatic failing over to known to work credentials, when using bad credentials.\r\nBy default, passing bad credentials will cause the Computer Management functions to interrupt with a warning (Or exception if in silent mode).", "", false, "false", "False" ], [ "WindowsCredentialsAreBad", "Will prevent the windows credentials of the currently logged on user from being used for the remote connection.", "", false, "false", "False" ], [ "CimWinRMOptions", "Specify a set of options to use when connecting to the target computer using CIM over WinRM.\r\nUse \u0027New-CimSessionOption\u0027 to create such an object.", "", false, "false", "" ], [ "CimDCOMOptions", "Specify a set of options to use when connecting to the target computer using CIM over DCOM.\r\nUse \u0027New-CimSessionOption\u0027 to create such an object.", "", false, "false", "" ], [ "AddBadCredential", "Adds credentials to the bad credential cache.\r\nThese credentials will not be used when connecting to the target remote computer.", "", false, "false", "" ], [ "RemoveBadCredential", "Removes credentials from the bad credential cache.", "", false, "false", "" ], [ "ClearBadCredential", "Clears the cache of credentials that didn\u0027t worked.\r\nWill be applied before adding entries to the credential cache.", "", false, "false", "False" ], [ "ClearCredential", "Clears the cache of credentials that worked.\r\nWill be applied before adding entries to the credential cache.", "", false, "false", "False" ], [ "ResetCredential", "Resets all credential-related caches:\r\n- Clears bad credential cache\r\n- Removes last working credential\r\n- Un-Confirms the windows credentials as working\r\n- Un-Confirms the windows credentials as not working\nAutomatically implies the parameters -ClearCredential and -ClearBadCredential. Using them together is redundant.\r\nWill be applied before adding entries to the credential cache.", "", false, "false", "False" ], [ "ResetConnectionStatus", "Restores all connection status to default, as if no connection protocol had ever been tested.", "", false, "false", "False" ], [ "ResetConfiguration", "Restores the configuration back to system default.\r\nConfiguration elements are the basic behavior controlling settings, such as whether to cache bad credentials, etc.\r\nThese can be configured globally using the dbatools configuration system and overridden locally on a per-connection basis.\r\nFor a list of all available settings, use \"Get-DbatoolsConfig -Module ComputerManagement\".", "", 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", "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": "", "Author": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Configures a connection object for use in remote computer management.", "Name": "Set-DbaCmConnection", "Links": "https://dbatools.io/set-DbaCmConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaCmConnection sql2014 | Set-DbaCmConnection -ClearBadCredential -UseWindowsCredentials\nRetrieves the already existing connection to sql2014, removes the list of not working credentials and configures it to default to the credentials of the logged on user.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmConnection | Set-DbaCmConnection -RemoveBadCredential $cred\nRemoves the credentials stored in $cred from all connections\u0027 list of \"known to not work\" credentials.\r\nHandy to update changes in privilege.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmConnection | Export-Clixml .\\connections.xml\nPS C:\\\u003e Import-Clixml .\\connections.xml | Set-DbaCmConnection -ResetConfiguration\nAt first, the current cached connections are stored in an xml file. At a later time - possibly in the profile when starting the console again - those connections are imported again and applied again \r\nto the connection cache.\nIn this example, the configuration settings will also be reset, since after re-import those will be set to explicit, rather than deriving them from the global settings.\r\nIn many cases, using the default settings is desirable. For specific settings, use New-DbaCmConnection as part of the profile in order to explicitly configure a connection.", "Syntax": "Set-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-OverrideExplicitCredential] [-OverrideConnectionPolicy] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] [-WindowsCredentialsAreBad] [-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] [-AddBadCredential \u003cPSCredential[]\u003e] [-RemoveBadCredential \u003cPSCredential[]\u003e] [-ClearBadCredential] [-ClearCredential] [-ResetCredential] \r\n[-ResetConnectionStatus] [-ResetConfiguration] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-UseWindowsCredentials] [-OverrideExplicitCredential] [-OverrideConnectionPolicy] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] [-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] [-AddBadCredential \u003cPSCredential[]\u003e] [-RemoveBadCredential \u003cPSCredential[]\u003e] [-ClearBadCredential] [-ClearCredential] [-ResetCredential] [-ResetConnectionStatus] \r\n[-ResetConfiguration] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbCompatibility", "Description": "Sets the current database compatibility level for all databases on a server or list of databases passed in to the function.", "Tags": [ "Compatibility", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "", false, "false", "" ], [ "Database", "The database or databases to process. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "TargetCompatibility", "The target compatibility level version. This is an int and follows Microsoft\u0027s versioning:\n9 = SQL Server 2005\r\n10 = SQL Server 2008\r\n11 = SQL Server 2012\r\n12 = SQL Server 2014\r\n13 = SQL Server 2016\r\n14 = SQL Server 2017\r\n15 = SQL Server 2019", "", false, "false", "0" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase)", "", 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" ], [ "WhatIf", "Shows what would happen if the command were to run", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step. For example:\nAre you sure you want to perform this action?\r\nPerforming the operation \"Update database\" on target \"pubs on SQL2016\\VNEXT\".\r\n[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is \"Y\"):", "cf", false, "false", "" ] ], "Alias": "", "Author": "Garry Bargsley, http://blog.garrybargsley.com/", "Synopsis": "Sets the compatibility level for SQL Server databases.", "Name": "Set-DbaDbCompatibility", "Links": "https://dbatools.io/Set-DbaDbCompatibility", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbCompatibility -SqlInstance localhost\\sql2017\nChanges database compatibility level for all user databases on server localhost\\sql2017 that have a Compatibility level that do not match\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbCompatibility -SqlInstance localhost\\sql2017 -TargetCompatibility 12\nChanges database compatibility level for all user databases on server localhost\\sql2017 to Version120\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaDbCompatibility -SqlInstance localhost\\sql2017 -Database Test -TargetCompatibility 12\nChanges database compatibility level for database Test on server localhost\\sql2017 to Version 120", "Syntax": "Set-DbaDbCompatibility [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-TargetCompatibility] \u003cInt32\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbCompression", "Description": "This function sets the appropriate compression recommendation, determined either by using the Tiger Team\u0027s query or set to the CompressionType parameter.\n\nRemember Uptime is critical for the Tiger Team query, the longer uptime, the more accurate the analysis is.\nYou would probably be best if you utilized Get-DbaUptime first, before running this command.\n\nSet-DbaDbCompression script derived from GitHub and the tigertoolbox\n(https://github.com/Microsoft/tigertoolbox/tree/master/Evaluate-Compression-Gains)", "Tags": [ "Compression", "Table", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "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", "" ], [ "CompressionType", "Control the compression type applied. Default is \u0027Recommended\u0027 which uses the Tiger Team query to use the most appropriate setting per object. Other option is to compress all objects to either Row or \r\nPage.", "", false, "false", "Recommended" ], [ "MaxRunTime", "Will continue to alter tables and indexes for the given amount of minutes.", "", false, "false", "0" ], [ "PercentCompression", "Will only work on the tables/indexes that have the calculated savings at and higher for the given number provided.", "", false, "false", "0" ], [ "InputObject", "Takes the output of Test-DbaDbCompression as an object and applied compression based on those recommendations.", "", 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", "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": "", "Author": "Jason Squires (@js_0505), jstexasdba@gmail.com", "Synopsis": "Sets tables and indexes with preferred compression setting.", "Name": "Set-DbaDbCompression", "Links": "https://dbatools.io/Set-DbaDbCompression", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbCompression -SqlInstance localhost -MaxRunTime 60 -PercentCompression 25\nSet the compression run time to 60 minutes and will start the compression of tables/indexes that have a difference of 25% or higher between current and recommended.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbCompression -SqlInstance ServerA -Database DBName -CompressionType Page\nUtilizes Page compression for all objects in DBName on ServerA with no time limit.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaDbCompression -SqlInstance ServerA -Database DBName -PercentCompression 25 | Out-GridView\nWill compress tables/indexes within the specified database that would show any % improvement with compression and with no time limit. The results will be piped into a nicely formatted GridView.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$testCompression = Test-DbaDbCompression -SqlInstance ServerA -Database DBName\nPS C:\\\u003e Set-DbaDbCompression -SqlInstance ServerA -Database DBName -InputObject $testCompression\nGets the compression suggestions from Test-DbaDbCompression into a variable, this can then be reviewed and passed into Set-DbaDbCompression.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Set-DbaDbCompression -SqlInstance ServerA -ExcludeDatabase Database -SqlCredential $cred -MaxRunTime 60 -PercentCompression 25\nSet the compression run time to 60 minutes and will start the compression of tables/indexes for all databases except the specified excluded database. Only objects that have a difference of 25% or \r\nhigher between current and recommended will be compressed.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$servers = \u0027Server1\u0027,\u0027Server2\u0027\nPS C:\\\u003e foreach ($svr in $servers) {\r\n\u003e\u003e Set-DbaDbCompression -SqlInstance $svr -MaxRunTime 60 -PercentCompression 25 | Export-Csv -Path C:\\temp\\CompressionAnalysisPAC.csv -Append\r\n\u003e\u003e }\nSet the compression run time to 60 minutes and will start the compression of tables/indexes across all listed servers that have a difference of 25% or higher between current and recommended. Output \r\nof command is exported to a csv.", "Syntax": "Set-DbaDbCompression [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-CompressionType] \u003cObject\u003e] [[-MaxRunTime] \u003cInt32\u003e] [[-PercentCompression] \u003cInt32\u003e] [[-InputObject] \u003cObject\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbMirror", "Description": "Sets properties of database mirrors.", "Tags": [ "Mirror", "HA" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function\r\nto be executed against multiple SQL Server instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The target database.", "", false, "false", "" ], [ "Partner", "Sets the partner fqdn.", "", false, "false", "" ], [ "Witness", "Sets the witness fqdn.", "", false, "false", "" ], [ "SafetyLevel", "Sets the mirroring safety level.", "", false, "false", "" ], [ "State", "Sets the mirror state.", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaDatabase.", "", 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" ], [ "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": "Sets properties of database mirrors.", "Name": "Set-DbaDbMirror", "Links": "https://dbatools.io/Set-DbaDbMirror", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbMirror -SqlInstance sql2005 -Database dbatools -Partner TCP://SQL2008.ad.local:5374\nPrompts for confirmation then sets the partner to TCP://SQL2008.ad.local:5374 for the database \"dbtools\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbMirror -SqlInstance sql2005 -Database dbatools -Witness TCP://SQL2012.ad.local:5502 -Confirm:$false\nDoes not prompt for confirmation and sets the witness to TCP://SQL2012.ad.local:5502 for the database \"dbtools\"\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2005 | Out-GridView -PassThru | Set-DbaDbMirror -SafetyLevel Full -Confirm:$false\nSets the safety level to Full for databases selected from a grid view. Does not prompt for confirmation.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaDbMirror -SqlInstance sql2005 -Database dbatools -State Suspend -Confirm:$false\nDoes not prompt for confirmation and sets the state to suspend for the database \"dbtools\"", "Syntax": "Set-DbaDbMirror [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-Partner] \u003cString\u003e] [[-Witness] \u003cString\u003e] [[-SafetyLevel] \u003cString\u003e] [[-State] \u003cString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbOwner", "Description": "This function will alter database ownership to match a specified login if their current owner does not match the target login. By default, the target login will be \u0027sa\u0027, but the function will allow the user to specify a different login for ownership. The user can also apply this to all databases or only to a select list of databases (passed as either a comma separated list or a string array).\n\nBest Practice reference: http://weblogs.sqlteam.com/dang/archive/2008/01/13/Database-Owner-Troubles.aspx", "Tags": [ "Database", "Owner", "DbOwner" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "TargetLogin", "Specifies the login that you wish check for ownership. This defaults to \u0027sa\u0027 or the sysadmin name if sa was renamed. This must be a valid security principal which exists on the target server.", "Login", 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", "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": "Set-DbaDatabaseOwner", "Author": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Sets database owners with a desired login if databases do not match that owner.", "Name": "Set-DbaDbOwner", "Links": "https://dbatools.io/Set-DbaDbOwner", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbOwner -SqlInstance localhost\nSets database owner to \u0027sa\u0027 on all databases where the owner does not match \u0027sa\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbOwner -SqlInstance localhost -TargetLogin DOMAIN\\account\nSets the database owner to DOMAIN\\account on all databases where the owner does not match DOMAIN\\account.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaDbOwner -SqlInstance sqlserver -Database db1, db2\nSets database owner to \u0027sa\u0027 on the db1 and db2 databases if their current owner does not match \u0027sa\u0027.", "Syntax": "Set-DbaDbOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-TargetLogin] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbQueryStoreOption", "Description": "Configure Query Store settings for a specific or multiple databases.", "Tags": "QueryStore", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "SqlCredential object used to connect to the SQL Server as a different user.", "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", "" ], [ "AllDatabases", "Run command against all user databases", "", false, "false", "False" ], [ "State", "Set the state of the Query Store. Valid options are \"ReadWrite\", \"ReadOnly\" and \"Off\".", "", false, "false", "" ], [ "FlushInterval", "Set the flush to disk interval of the Query Store in seconds.", "", false, "false", "0" ], [ "CollectionInterval", "Set the runtime statistics collection interval of the Query Store in minutes.", "", false, "false", "0" ], [ "MaxSize", "Set the maximum size of the Query Store in MB.", "", false, "false", "0" ], [ "CaptureMode", "Set the query capture mode of the Query Store. Valid options are \"Auto\" and \"All\".", "", false, "false", "" ], [ "CleanupMode", "Set the query cleanup mode policy. Valid options are \"Auto\" and \"Off\".", "", false, "false", "" ], [ "StaleQueryThreshold", "Set the stale query threshold in days.", "", false, "false", "0" ], [ "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", "wi", false, "false", "" ], [ "Confirm", "Prompts for confirmation of every step. For example:\nAre you sure you want to perform this action?\r\nPerforming the operation \"Changing Desired State\" on target \"pubs on SQL2016\\VNEXT\".\r\n[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is \"Y\"):", "cf", false, "false", "" ] ], "Alias": "Set-DbaDbQueryStoreOptions,Set-DbaQueryStoreConfig", "Author": "Enrico van de Laar (@evdlaar)", "Synopsis": "Configure Query Store settings for a specific or multiple databases.", "Name": "Set-DbaDbQueryStoreOption", "Links": "https://dbatools.io/Set-DbaQueryStoreOptions", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -State ReadWrite -FlushInterval 600 -CollectionInterval 10 -MaxSize 100 -CaptureMode All -CleanupMode Auto -StaleQueryThreshold 100 \r\n-AllDatabases\nConfigure the Query Store settings for all user databases in the ServerA\\SQL Instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -FlushInterval 600\nOnly configure the FlushInterval setting for all Query Store databases in the ServerA\\SQL Instance.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -Database AdventureWorks -State ReadWrite -FlushInterval 600 -CollectionInterval 10 -MaxSize 100 -CaptureMode all -CleanupMode Auto \r\n-StaleQueryThreshold 100\nConfigure the Query Store settings for the AdventureWorks database in the ServerA\\SQL Instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -Exclude AdventureWorks -State ReadWrite -FlushInterval 600 -CollectionInterval 10 -MaxSize 100 -CaptureMode all -CleanupMode Auto \r\n-StaleQueryThreshold 100\nConfigure the Query Store settings for all user databases except the AdventureWorks database in the ServerA\\SQL Instance.", "Syntax": "Set-DbaDbQueryStoreOption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-AllDatabases] [[-State] \u003cString[]\u003e] [[-FlushInterval] \u003cInt64\u003e] [[-CollectionInterval] \u003cInt64\u003e] [[-MaxSize] \u003cInt64\u003e] [[-CaptureMode] \u003cString[]\u003e] [[-CleanupMode] \u003cString[]\u003e] [[-StaleQueryThreshold] \u003cInt64\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbRecoveryModel", "Description": "Set-DbaDbRecoveryModel sets the Recovery Model for user databases.", "Tags": [ "RecoveryModel", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "RecoveryModel", "Recovery Model to be set. Valid options are \u0027Simple\u0027, \u0027Full\u0027, \u0027BulkLogged\u0027\nDetails about the recovery models can be found here:\r\nhttps://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/recovery-models-sql-server", "", true, "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", "" ], [ "AllDatabases", "This is a parameter that was included for safety, so you don\u0027t accidentally set options on all databases without specifying", "", 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" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase)", "", true, "true (ByValue)", "" ], [ "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", "Prompts for confirmation. For example:\nAre you sure you want to perform this action?\r\nPerforming the operation \"ALTER DATABASE [model] SET RECOVERY Full\" on target \"[model] on WERES14224\".\r\n[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is \"Y\"):", "cf", false, "false", "" ] ], "Alias": "", "Author": "Viorel Ciucu (@viorelciucu), https://www.cviorel.com", "Synopsis": "Set-DbaDbRecoveryModel sets the Recovery Model.", "Name": "Set-DbaDbRecoveryModel", "Links": "https://dbatools.io/Set-DbaDbRecoveryModel", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Database model -Confirm:$true -Verbose\nSets the Recovery Model to BulkLogged for database [model] on SQL Server instance sql2014. User is requested to confirm the action.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2014 -Database TestDB | Set-DbaDbRecoveryModel -RecoveryModel Simple -Confirm:$false\nSets the Recovery Model to Simple for database [TestDB] on SQL Server instance sql2014. Confirmation is not required.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel Simple -Database TestDB -Confirm:$false\nSets the Recovery Model to Simple for database [TestDB] on SQL Server instance sql2014. Confirmation is not required.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel Simple -AllDatabases -Confirm:$false\nSets the Recovery Model to Simple for ALL uses databases MODEL database on SQL Server instance sql2014. Runs without asking for confirmation.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Database TestDB1, TestDB2 -Confirm:$false -Verbose\nSets the Recovery Model to BulkLogged for [TestDB1] and [TestDB2] databases on SQL Server instance sql2014. Runs without asking for confirmation.", "Syntax": "Set-DbaDbRecoveryModel [-SqlCredential \u003cPSCredential\u003e] -RecoveryModel \u003cString\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaDbRecoveryModel -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -RecoveryModel \u003cString\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaDbRecoveryModel [-SqlCredential \u003cPSCredential\u003e] -RecoveryModel \u003cString\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-EnableException] -InputObject \u003cDatabase[]\u003e [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaDbState", "Description": "Sets some common \"states\" on databases:\n- \"RW\" options (ReadOnly, ReadWrite)\n- \"Status\" options (Online, Offline, Emergency, plus a special \"Detached\")\n- \"Access\" options (SingleUser, RestrictedUser, MultiUser)\n\nReturns an object with SqlInstance, Database, RW, Status, Access, Notes\n\nNotes gets filled when something went wrong setting the state", "Tags": [ "Database", "State" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "ServerInstance,SqlServer", true, "true (ByPropertyName)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "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", "" ], [ "AllDatabases", "This is a parameter that was included for safety, so you don\u0027t accidentally set options on all databases without specifying", "", false, "false", "False" ], [ "ReadOnly", "RW Option : Sets the database as READ_ONLY", "", false, "false", "False" ], [ "ReadWrite", "RW Option : Sets the database as READ_WRITE", "", false, "false", "False" ], [ "Online", "Status Option : Sets the database as ONLINE", "", false, "false", "False" ], [ "Offline", "Status Option : Sets the database as OFFLINE", "", false, "false", "False" ], [ "Emergency", "Status Option : Sets the database as EMERGENCY", "", false, "false", "False" ], [ "Detached", "Status Option : Detaches the database", "", false, "false", "False" ], [ "SingleUser", "Access Option : Sets the database as SINGLE_USER", "", false, "false", "False" ], [ "RestrictedUser", "Access Option : Sets the database as RESTRICTED_USER", "", false, "false", "False" ], [ "MultiUser", "Access Option : Sets the database as MULTI_USER", "", false, "false", "False" ], [ "Force", "For most options, this translates to instantly rolling back any open transactions\r\nthat may be stopping the process.\r\nFor -Detached it is required to break mirroring and Availability Groups", "", 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" ], [ "InputObject", "Accepts piped database objects", "", true, "true (ByValue)", "" ], [ "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": "Set-DbaDatabaseState", "Author": "Simone Bizzotto (@niphold)", "Synopsis": "Sets various options for databases, hereby called \"states\"", "Name": "Set-DbaDbState", "Links": "https://dbatools.io/Set-DbaDbState", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -Database HR -Offline\nSets the HR database as OFFLINE\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -AllDatabases -Exclude HR -ReadOnly -Force\nSets all databases of the sqlserver2014a instance, except for HR, as READ_ONLY\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDbState -SqlInstance sql2016 | Where-Object Status -eq \u0027Offline\u0027 | Set-DbaDbState -Online\nFinds all offline databases and sets them to online\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -Database HR -SingleUser\nSets the HR database as SINGLE_USER\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -Database HR -SingleUser -Force\nSets the HR database as SINGLE_USER, dropping all other connections (and rolling back open transactions)\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sqlserver2014a -Database HR | Set-DbaDbState -SingleUser -Force\nGets the databases from Get-DbaDatabase, and sets them as SINGLE_USER, dropping all other connections (and rolling back open transactions)", "Syntax": "Set-DbaDbState [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-ReadOnly] [-ReadWrite] [-Online] [-Offline] [-Emergency] [-Detached] [-SingleUser] [-RestrictedUser] [-MultiUser] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaDbState -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-ReadOnly] [-ReadWrite] [-Online] [-Offline] [-Emergency] [-Detached] [-SingleUser] [-RestrictedUser] [-MultiUser] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaDbState [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-ReadOnly] [-ReadWrite] [-Online] [-Offline] [-Emergency] [-Detached] [-SingleUser] [-RestrictedUser] [-MultiUser] [-Force] [-EnableException] -InputObject \u003cPSObject[]\u003e [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaEndpoint", "Description": "Sets endpoint properties on a SQL Server instance.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "EndPoint", "Only set specific endpoint properties.", "", false, "false", "" ], [ "Owner", "Change the endpoint owner.", "", false, "false", "" ], [ "Type", "Change the endpoint type. Options: DatabaseMirroring, ServiceBroker, Soap, TSql", "", false, "false", "" ], [ "AllEndpoints", "Set all endpoint properties on an instance.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-Endpoint.", "", 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" ], [ "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": "Sets endpoint properties on a SQL Server instance.", "Name": "Set-DbaEndpoint", "Links": "https://dbatools.io/Set-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaEndpoint -SqlInstance sql2016 -AllEndpoints -Owner sa\nSets all endpoint owners to sa on sql2016\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance sql2016 -Endpoint ep1 | Set-DbaEndpoint -Type TSql\nChanges the endpoint type to tsql on endpoint ep1", "Syntax": "Set-DbaEndpoint [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-EndPoint] \u003cString[]\u003e] [[-Owner] \u003cString\u003e] [[-Type] \u003cString\u003e] [-AllEndpoints] [[-InputObject] \u003cEndpoint[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaErrorLogConfig", "Description": "Sets the number of log files configured on all versions, and size in KB in SQL Server 2012+ and above.\n\nTo set the Path to the ErrorLog, use Set-DbaStartupParameter -ErrorLog. Note that this command requires\nremote, administrative access to the Windows/WMI server, similar to SQL Configuration Manager.", "Tags": [ "Instance", "ErrorLog" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances", "", true, "true (ByPropertyName)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "LogCount", "Integer value between 6 and 99 for setting the number of error log files to keep for SQL Server instance.", "", false, "false", "0" ], [ "LogSize", "Integer value for the size in KB that you want the error log file to grow. This is feature only in SQL Server 2012 and higher. When the file reaches that limit SQL Server will roll the error log over.", "", false, "false", "0" ], [ "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" ], [ "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": "", "Author": "Shawn Melton (@wsmelton), https://wsmelton.github.com", "Synopsis": "Set the configuration for the ErrorLog on a given SQL Server instance", "Name": "Set-DbaErrorLogConfig", "Links": "https://dbatools.io/Set-DbaErrorLogConfig", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaErrorLogConfig -SqlInstance sql2017,sql2014 -LogCount 25\nSets the number of error log files to 25 on sql2017 and sql2014\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaErrorLogConfig -SqlInstance sql2014 -LogSize 102400\nSets the size of the error log file, before it rolls over, to 102400 KB (100 MB) on sql2014\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaErrorLogConfig -SqlInstance sql2012 -LogCount 25 -LogSize 500\nSets the number of error log files to 25 and size before it will roll over to 500 KB on sql2012", "Syntax": "Set-DbaErrorLogConfig [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-LogCount] \u003cInt32\u003e] [[-LogSize] \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaJobOwner", "Description": "This function alters SQL Agent Job ownership to match a specified login if their current owner does not match the target login. By default, the target login will be \u0027sa\u0027, but the the user may specify a different login for ownership. This be applied to all jobs or only to a select collection of jobs.\n\nBest practice reference: http://sqlmag.com/blog/sql-server-tip-assign-ownership-jobs-sysadmin-account", "Tags": [ "Agent", "Job" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Job", "Specifies the job(s) to process. Options for this list are auto-populated from the server. If unspecified, all jobs will be processed.", "Jobs", false, "false", "" ], [ "ExcludeJob", "Specifies the job(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Login", "Specifies the login that you wish check for ownership. This defaults to \u0027sa\u0027 or the sysadmin name if sa was renamed. This must be a valid security principal which exists on the target server.", "TargetLogin", 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", "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": "", "Author": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Sets SQL Agent job owners with a desired login if jobs do not match that owner.", "Name": "Set-DbaJobOwner", "Links": "https://dbatools.io/Set-DbaJobOwner", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaJobOwner -SqlInstance localhost\nSets SQL Agent Job owner to sa on all jobs where the owner does not match sa.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaJobOwner -SqlInstance localhost -Login DOMAIN\\account\nSets SQL Agent Job owner to sa on all jobs where the owner does not match \u0027DOMAIN\\account\u0027. Note\r\nthat Login must be a valid security principal that exists on the target server.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaJobOwner -SqlInstance localhost -Job job1, job2\nSets SQL Agent Job owner to \u0027sa\u0027 on the job1 and job2 jobs if their current owner does not match \u0027sa\u0027.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e\u0027sqlserver\u0027,\u0027sql2016\u0027 | Set-DbaJobOwner\nSets SQL Agent Job owner to sa on all jobs where the owner does not match sa on both sqlserver and sql2016.", "Syntax": "Set-DbaJobOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [[-ExcludeJob] \u003cObject[]\u003e] [[-Login] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaLogin", "Description": "Set-DbaLogin will enable you to change the password, unlock, rename, disable or enable, deny or grant login privileges to the login. It\u0027s also possible to add or remove server roles from the login.", "Tags": "Login", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Login", "The login that needs to be changed", "", false, "false", "" ], [ "Password", "The new password for the login This can be either a credential or a secure string.", "", false, "false", "" ], [ "Unlock", "Switch to unlock an account. This will only be used in conjunction with the -Password parameter.\r\nThe default is false.", "", false, "false", "False" ], [ "MustChange", "Does the user need to change his/her password. This will only be used in conjunction with the -Password parameter.\r\nThe default is false.", "", false, "false", "False" ], [ "NewName", "The new name for the login.", "", false, "false", "" ], [ "Disable", "Disable the login", "", false, "false", "False" ], [ "Enable", "Enable the login", "", false, "false", "False" ], [ "DenyLogin", "Deny access to SQL Server", "", false, "false", "False" ], [ "GrantLogin", "Grant access to SQL Server", "", false, "false", "False" ], [ "PasswordPolicyEnforced", "Should the password policy be enforced.", "", false, "false", "False" ], [ "AddRole", "Add one or more server roles to the login\r\nThe following roles can be used \"bulkadmin\", \"dbcreator\", \"diskadmin\", \"processadmin\", \"public\", \"securityadmin\", \"serveradmin\", \"setupadmin\", \"sysadmin\".", "", false, "false", "" ], [ "RemoveRole", "Remove one or more server roles to the login\r\nThe following roles can be used \"bulkadmin\", \"dbcreator\", \"diskadmin\", \"processadmin\", \"public\", \"securityadmin\", \"serveradmin\", \"setupadmin\", \"sysadmin\".", "", false, "false", "" ], [ "InputObject", "Allows logins to be piped in from Get-DbaLogin", "", 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.", "Silent", false, "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": "", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Set-DbaLogin makes it possible to make changes to one or more logins.", "Name": "Set-DbaLogin", "Links": "https://dbatools.io/Set-DbaLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$password = ConvertTo-SecureString \"PlainTextPassword\" -AsPlainText -Force\nPS C:\\\u003e $cred = New-Object System.Management.Automation.PSCredential (\"username\", $password)\r\nPS C:\\\u003e Set-DbaLogin -SqlInstance sql1 -Login login1 -Password $cred -Unlock -MustChange\nSet the new password for login1 using a credential, unlock the account and set the option\r\nthat the user must change password at next logon.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -Enable\nEnable the login\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1, login2, login3, login4 -Enable\nEnable multiple logins\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1, sql2, sql3 -Login login1, login2, login3, login4 -Enable\nEnable multiple logins on multiple instances\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -Disable\nDisable the login\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -DenyLogin\nDeny the login to connect to the instance\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -GrantLogin\nGrant the login to connect to the instance\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -PasswordPolicyEnforced\nEnforces the password policy on a login\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -PasswordPolicyEnforced:$false\nDisables enforcement of the password policy on a login\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login test -AddRole serveradmin\nAdd the server role \"serveradmin\" to the login\n-------------------------- EXAMPLE 11 --------------------------\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login test -RemoveRole bulkadmin\nRemove the server role \"bulkadmin\" to the login\n-------------------------- EXAMPLE 12 --------------------------\nPS C:\\\u003e$login = Get-DbaLogin -SqlInstance sql1 -Login test\nPS C:\\\u003e $login | Set-DbaLogin -Disable\nDisable the login from the pipeline", "Syntax": "Set-DbaLogin [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [[-Password] \u003cObject\u003e] [-Unlock] [-MustChange] [[-NewName] \u003cString\u003e] [-Disable] [-Enable] [-DenyLogin] [-GrantLogin] [-PasswordPolicyEnforced] [[-AddRole] \u003cString[]\u003e] [[-RemoveRole] \u003cString[]\u003e] [[-InputObject] \u003cLogin[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaMaxDop", "Description": "Uses the Test-DbaMaxDop command to get the recommended value if -MaxDop parameter is not specified.\n\nThese are just general recommendations for SQL Server and are a good starting point for setting the \"max degree of parallelism\" option.\n\nYou can set MaxDop database scoped configurations if the server is version 2016 or higher", "Tags": [ "MaxDop", "SpConfigure" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "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", "" ], [ "Database", "Specifies one or more databases to process. Options for this list are auto-populated from the server. If unspecified, all databases will be processed.", "Databases", false, "false", "" ], [ "ExcludeDatabase", "Specifies one or more databases to exclude from processing. Options for this list are auto-populated from the server", "", false, "false", "" ], [ "MaxDop", "Specifies the Max DOP value to set.", "", false, "false", "-1" ], [ "InputObject", "If Test-SqlMaxDop has been executed prior to this function, the results may be passed in via this parameter.", "", false, "true (ByValue)", "" ], [ "AllDatabases", "If this switch is enabled, Max DOP will be set on all databases. This switch is only useful on SQL Server 2016 and higher.", "All", 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" ], [ "WhatIf", "Shows what would happen if the cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Claudio Silva (@claudioessilva)", "Synopsis": "Sets SQL Server maximum degree of parallelism (Max DOP), then displays information relating to SQL Server Max DOP configuration settings. Works on SQL Server 2005 and higher.", "Name": "Set-DbaMaxDop", "Links": "https://dbatools.io/Set-DbaMaxDop", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2008, sql2012\nSets Max DOP to the recommended value for servers sql2008 and sql2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2014 -MaxDop 4\nSets Max DOP to 4 for server sql2014.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sql2008 | Set-DbaMaxDop\nGets the recommended Max DOP from Test-DbaMaxDop and applies it to to sql2008.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2016 -Database db1\nSet recommended Max DOP for database db1 on server sql2016.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2016 -AllDatabases\nSet recommended Max DOP for all databases on server sql2016.", "Syntax": "Set-DbaMaxDop [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-MaxDop \u003cInt32\u003e] [-InputObject \u003cPSObject\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaMaxMemory", "Description": "Sets SQL Server max memory then displays information relating to SQL Server Max Memory configuration settings.\n\nInspired by Jonathan Kehayias\u0027s post about SQL Server Max memory (http://bit.ly/sqlmemcalc), this uses a formula to\ndetermine the default optimum RAM to use, then sets the SQL max value to that number.\n\nJonathan notes that the formula used provides a *general recommendation* that doesn\u0027t account for everything that may\nbe going on in your specific environment.", "Tags": [ "MaxMemory", "Memory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Max", "Specifies the max megabytes (MB)", "", false, "false", "0" ], [ "InputObject", "A InputObject returned by Test-DbaMaxMemory", "", 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" ], [ "WhatIf", "Shows what would happen if the cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "Set-SqlMaxMemory", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Sets SQL Server \u0027Max Server Memory\u0027 configuration setting to a new value then displays information this setting.", "Name": "Set-DbaMaxMemory", "Links": "https://dbatools.io/Set-DbaMaxMemory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaMaxMemory sqlserver1\nSet max memory to the recommended on just one server named \"sqlserver1\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaMaxMemory -SqlInstance sqlserver1 -Max 2048\nExplicitly set max memory to 2048 on just one server, \"sqlserver1\"\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver | Test-DbaMaxMemory | Where-Object { $_.MaxValue -gt $_.Total } | Set-DbaMaxMemory\nFind all servers in SQL Server Central Management Server that have Max SQL memory set to higher than the total memory\r\nof the server (think 2147483647), then pipe those to Set-DbaMaxMemory and use the default recommendation.", "Syntax": "Set-DbaMaxMemory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Max] \u003cInt32\u003e] [[-InputObject] \u003cPSObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaNetworkCertificate", "Description": "Sets the network certificate for SQL Server instance. This setting is found in Configuration Manager.\n\nThis command also grants read permissions for the service account on the certificate\u0027s private key.\n\nReferences:\nhttp://sqlmag.com/sql-server/7-steps-ssl-encryption\nhttps://azurebi.jppp.org/2016/01/23/using-lets-encrypt-certificates-for-secure-sql-server-connections/\nhttps://blogs.msdn.microsoft.com/sqlserverfaq/2016/09/26/creating-and-registering-ssl-certificates/", "Tags": "Certificate", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "ServerInstance,SqlServer,ComputerName", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Allows you to login to the computer (not sql instance) using alternative credentials.", "", false, "false", "" ], [ "Certificate", "The target certificate object", "", true, "true (ByValue)", "" ], [ "Thumbprint", "The thumbprint of the target certificate", "", 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.", "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": "Sets the network certificate for SQL Server instance", "Name": "Set-DbaNetworkCertificate", "Links": "https://dbatools.io/Set-DbaNetworkCertificate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eNew-DbaComputerCertificate | Set-DbaNetworkCertificate -SqlInstance localhost\\SQL2008R2SP2\nCreates and imports a new certificate signed by an Active Directory CA on localhost then sets the network certificate for the SQL2008R2SP2 to that newly created certificate.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaNetworkCertificate -SqlInstance sql1\\SQL2008R2SP2 -Thumbprint 1223FB1ACBCA44D3EE9640F81B6BA14A92F3D6E2\nSets the network certificate for the SQL2008R2SP2 instance to the certificate with the thumbprint of 1223FB1ACBCA44D3EE9640F81B6BA14A92F3D6E2 in LocalMachine\\My on sql1", "Syntax": "Set-DbaNetworkCertificate [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaNetworkCertificate [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] -Certificate \u003cX509Certificate2\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nSet-DbaNetworkCertificate [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] -Thumbprint \u003cString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaPowerPlan", "Description": "Sets the SQL Server OS\u0027s Power Plan. Defaults to High Performance which is best practice.\n\nIf your organization uses a custom power plan that is considered best practice, specify -CustomPowerPlan.\n\nReferences:\nhttps://support.microsoft.com/en-us/kb/2207548\nhttp://www.sqlskills.com/blogs/glenn/windows-power-plan-effects-on-newer-intel-processors/", "Tags": [ "PowerPlan", "OS", "Configure" ], "Params": [ [ "ComputerName", "The server(s) to set the Power Plan on.", "", false, "true (ByValue)", "" ], [ "Credential", "Specifies a PSCredential object to use in authenticating to the server(s), instead of the current user account.", "", false, "false", "" ], [ "PowerPlan", "Specifies the Power Plan that you wish to use. Valid options for this match the Windows default Power Plans of \"Power Saver\", \"Balanced\", and \"High Performance\".", "", false, "false", "High Performance" ], [ "CustomPowerPlan", "Specifies the name of a custom Power Plan to use.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaPowerPlan", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Sets the SQL Server OS\u0027s Power Plan.", "Name": "Set-DbaPowerPlan", "Links": "https://dbatools.io/Set-DbaPowerPlan", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaPowerPlan -ComputerName sql2017\nSets the Power Plan to High Performance. Skips it if its already set.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027Server1\u0027, \u0027Server2\u0027 | Set-DbaPowerPlan -PowerPlan Balanced\nSets the Power Plan to Balanced for Server1 and Server2. Skips it if its already set.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$cred = Get-Credential \u0027Domain\\User\u0027\nPS C:\\\u003e Set-DbaPowerPlan -ComputerName sql2017 -Credential $cred\nConnects using alternative Windows credential and sets the Power Plan to High Performance. Skips it if its already set.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaPowerPlan -ComputerName sqlcluster -CustomPowerPlan \u0027Maximum Performance\u0027\nSets the Power Plan to the custom power plan called \"Maximum Performance\". Skips it if its already set.", "Syntax": "Set-DbaPowerPlan [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-PowerPlan] \u003cString\u003e] [[-CustomPowerPlan] \u003cString\u003e] [[-InputObject] \u003cPSObject\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaPrivilege", "Description": "Adds the SQL Service account to local privileges \u0027Lock Pages in Memory\u0027, \u0027Instant File Initialization\u0027, \u0027Logon as Batch\u0027 on one or more computers.\n\nRequires Local Admin rights on destination computer(s).", "Tags": "Privilege", "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", false, "false", "" ], [ "Type", "Use this to choose the privilege(s) to which you want to add the SQL Service account.\r\nAccepts \u0027IFI\u0027, \u0027LPIM\u0027 and/or \u0027BatchLogon\u0027 for local privileges \u0027Instant File Initialization\u0027, \u0027Lock Pages in Memory\u0027 and \u0027Logon as Batch\u0027.", "", 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.", "Silent", false, "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": "", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Adds the SQL Service account to local privileges on one or more computers.", "Name": "Set-DbaPrivilege", "Links": "https://dbatools.io/Set-DbaPrivilege", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaPrivilege -ComputerName sqlserver2014a -Type LPIM,IFI\nAdds the SQL Service account(s) on computer sqlserver2014a to the local privileges \u0027SeManageVolumePrivilege\u0027 and \u0027SeLockMemoryPrivilege\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Set-DbaPrivilege -Type IFI\nAdds the SQL Service account(s) on computers sql1, sql2 and sql3 to the local privilege \u0027SeManageVolumePrivilege\u0027.", "Syntax": "Set-DbaPrivilege [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Type] \u003cString[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaSpConfigure", "Description": "This function changes the configured value for sp_configure settings. If the setting is dynamic this setting will be used, otherwise the user will be warned that a restart of SQL is required.\nThis is designed to be safe and will not allow for configurations to be set outside of the defined configuration min and max values.\nWhile it is possible to set below the min, or above the max this can cause serious problems with SQL Server (including startup failures), and so is not permitted.", "Tags": "SpConfigure", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a\r\ncollection and receive pipeline input", "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", "" ], [ "Value", "The new value for the configuration", "NewValue,NewConfig", false, "false", "0" ], [ "Name", "The name of the configuration to be set -- Configs is auto-populated for tabbing convenience.", "Config,ConfigName", false, "false", "" ], [ "InputObject", "Piped objects from Get-DbaSpConfigure", "", 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.", "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": "Nic Cain, https://sirsql.net/", "Synopsis": "Changes the server level system configuration (sys.configuration/sp_configure) value for a given configuration", "Name": "Set-DbaSpConfigure", "Links": "https://dbatools.io/Set-DbaSpConfigure", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaSpConfigure -SqlInstance localhost -Name ScanForStartupProcedures -Value 1\nAdjusts the Scan for startup stored procedures configuration value to 1 and notifies the user that this requires a SQL restart to take effect\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance sql2017, sql2014 -Name XPCmdShellEnabled, IsSqlClrEnabled | Set-DbaSpConfigure -Value $false\nSets the values for XPCmdShellEnabled and IsSqlClrEnabled on sql2017 and sql2014 to False\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaSpConfigure -SqlInstance localhost -Name XPCmdShellEnabled -Value 1\nAdjusts the xp_cmdshell configuration value to 1.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaSpConfigure -SqlInstance localhost -Name XPCmdShellEnabled -Value 1 -WhatIf\nReturns information on the action that would be performed. No actual change will be made.", "Syntax": "Set-DbaSpConfigure [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Value] \u003cInt32\u003e] [[-Name] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaSpn", "Description": "This function will connect to Active Directory and search for an account. If the account is found, it will attempt to add an SPN. Once the SPN is added, the function will also set delegation to that service, unless -NoDelegation is specified. In order to run this function, the credential you provide must have write access to Active Directory.\n\nNote: This function supports -WhatIf", "Tags": "SPN", "Params": [ [ "SPN", "The SPN you want to add", "RequiredSPN", true, "true (ByPropertyName)", "" ], [ "ServiceAccount", "The account you want the SPN added to", "InstanceServiceAccount,AccountName", true, "true (ByPropertyName)", "" ], [ "Credential", "The credential you want to use to connect to Active Directory to make the changes", "", false, "true (ByPropertyName)", "" ], [ "NoDelegation", "Skips setting the delegation", "", 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 was executed", "wi", false, "false", "" ], [ "Confirm", "Turns confirmations before changes on or off", "cf", false, "false", "" ] ], "Alias": "", "Author": "Drew Furgiuele (@pittfurg), http://www.port1433.com", "Synopsis": "Sets an SPN for a given service account in active directory (and also enables delegation to the same SPN by default)", "Name": "Set-DbaSpn", "Links": "https://dbatools.io/Set-DbaSpn", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account\nPS C:\\\u003e Set-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -EnableException\nConnects to Active Directory and adds a provided SPN to the given account.\r\nConnects to Active Directory and adds a provided SPN to the given account, suppressing all error messages and throw exceptions that can be caught instead\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -Credential ad\\sqldba\nConnects to Active Directory and adds a provided SPN to the given account. Uses alternative account to connect to AD.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -NoDelegation\nConnects to Active Directory and adds a provided SPN to the given account, without the delegation.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2016 | Where { $_.isSet -eq $false } | Set-DbaSpn\nSets all missing SPNs for sql2016\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2016 | Where { $_.isSet -eq $false } | Set-DbaSpn -WhatIf\nDisplays what would happen trying to set all missing SPNs for sql2016", "Syntax": "Set-DbaSpn [-SPN] \u003cString\u003e [-ServiceAccount] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] [-NoDelegation] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaStartupParameter", "Description": "Modifies the startup parameters for a specified SQL Server Instance\n\nFor full details of what each parameter does, please refer to this MSDN article - https://msdn.microsoft.com/en-us/library/ms190737(v=sql.105).aspx", "Tags": [ "Startup", "Parameter", "Configure" ], "Params": [ [ "SqlInstance", "The SQL Server instance to be modified\nIf the Sql Instance is offline path parameters will be ignored as we cannot test the instance\u0027s access to the path. If you want to force this to work then please use the Force switch", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Windows or Sql Login Credential with permission to log into the SQL instance", "", false, "false", "" ], [ "Credential", "Windows Credential with permission to log on to the server running the SQL instance", "", false, "false", "" ], [ "MasterData", "Path to the data file for the Master database\nWill be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the Force switch. This is to ensure you understand the risk as we cannot validate the path if \r\nthe instance is offline", "", false, "false", "" ], [ "MasterLog", "Path to the log file for the Master database\nWill be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the Force switch. This is to ensure you understand the risk as we cannot validate the path if \r\nthe instance is offline", "", false, "false", "" ], [ "ErrorLog", "Path to the SQL Server error log file\nWill be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the Force switch. This is to ensure you understand the risk as we cannot validate the path if \r\nthe instance is offline", "", false, "false", "" ], [ "TraceFlags", "A comma separated list of TraceFlags to be applied at SQL Server startup\r\nBy default these will be appended to any existing trace flags set", "", false, "false", "" ], [ "CommandPromptStart", "Shortens startup time when starting SQL Server from the command prompt. Typically, the SQL Server Database Engine starts as a service by calling the Service Control Manager.\r\nBecause the SQL Server Database Engine does not start as a service when starting from the command prompt", "", false, "false", "False" ], [ "MinimalStart", "Starts an instance of SQL Server with minimal configuration. This is useful if the setting of a configuration value (for example, over-committing memory) has\r\nprevented the server from starting. Starting SQL Server in minimal configuration mode places SQL Server in single-user mode", "", false, "false", "False" ], [ "MemoryToReserve", "Specifies an integer number of megabytes (MB) of memory that SQL Server will leave available for memory allocations within the SQL Server process,\r\nbut outside the SQL Server memory pool. The memory outside of the memory pool is the area used by SQL Server for loading items such as extended procedure .dll files,\r\nthe OLE DB providers referenced by distributed queries, and automation objects referenced in Transact-SQL statements. The default is 256 MB.", "", false, "false", "0" ], [ "SingleUser", "Start Sql Server in single user mode", "", false, "false", "False" ], [ "SingleUserDetails", "The username for single user", "", false, "false", "" ], [ "NoLoggingToWinEvents", "Don\u0027t use Windows Application events log", "", false, "false", "False" ], [ "StartAsNamedInstance", "Allows you to start a named instance of SQL Server", "", false, "false", "False" ], [ "DisableMonitoring", "Disables the following monitoring features:\nSQL Server performance monitor counters\r\nKeeping CPU time and cache-hit ratio statistics\r\nCollecting information for the DBCC SQLPERF command\r\nCollecting information for some dynamic management views\r\nMany extended-events event points\n** Warning *\\* When you use the -x startup option, the information that is available for you to diagnose performance and functional problems with SQL Server is greatly reduced.", "", false, "false", "False" ], [ "IncreasedExtents", "Increases the number of extents that are allocated for each file in a filegroup.", "", false, "false", "False" ], [ "TraceFlagsOverride", "Overrides the default behaviour and replaces any existing trace flags. If not trace flags specified will just remove existing ones", "", false, "false", "False" ], [ "StartUpConfig", "Pass in a previously saved SQL Instance startup config\r\nusing this parameter will set TraceFlagsOverride to true, so existing Trace Flags will be overridden", "", false, "false", "" ], [ "Offline", "Setting this switch will try perform the requested actions without connect to the SQL Server Instance, this will speed things up if you know the Instance is offline.\nWhen working offline, path inputs (MasterData, MasterLog and ErrorLog) will be ignored, unless Force is specified", "", false, "false", "False" ], [ "Force", "By default we test the values passed in via MasterData, MasterLog, ErrorLog", "", 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": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Sets the Startup Parameters for a SQL Server instance", "Name": "Set-DbaStartupParameter", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser\nWill configure the SQL Instance server1\\instance1 to startup up in Single User mode at next startup\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents\nWill configure the SQL Instance sql2016 to IncreasedExtents = True (-E)\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents:$false -WhatIf\nShows what would happen if you attempted to configure the SQL Instance sql2016 to IncreasedExtents = False (no -E)\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -TraceFlags 8032,8048\nThis will append Trace Flags 8032 and 8048 to the startup parameters\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagsOverride\nThis will remove all trace flags and set SingleUser to false\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -TraceFlags 8032,8048 -TraceFlagsOverride\nThis will set Trace Flags 8032 and 8048 to the startup parameters, removing any existing Trace Flags\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagsOverride -Offline\nThis will remove all trace flags and set SingleUser to false from an offline instance\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline\nThis will attempt to change the ErrorLog path to c:\\sql\\. However, with the offline switch this will not happen. To force it, use the -Force switch like so:\nSet-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline -Force\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003e$StartupConfig = Get-DbaStartupParameter -SqlInstance server1\\instance1\nPS C:\\\u003e Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -NoLoggingToWinEvents\r\nPS C:\\\u003e #Restart your SQL instance with the tool of choice\r\nPS C:\\\u003e #Do Some work\r\nPS C:\\\u003e Set-DbaStartupParameter -SqlInstance server1\\instance1 -StartUpConfig $StartUpConfig\r\nPS C:\\\u003e #Restart your SQL instance with the tool of choice and you\u0027re back to normal\nIn this example we take a copy of the existing startup configuration of server1\\instance1\nWe then change the startup parameters ahead of some work\nAfter the work has been completed, we can push the original startup parameters back to server1\\instance1 and resume normal operation", "Syntax": "Set-DbaStartupParameter [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-MasterData] \u003cString\u003e] [[-MasterLog] \u003cString\u003e] [[-ErrorLog] \u003cString\u003e] [[-TraceFlags] \u003cString[]\u003e] [-CommandPromptStart] [-MinimalStart] [[-MemoryToReserve] \u003cInt32\u003e] [-SingleUser] [[-SingleUserDetails] \u003cString\u003e] [-NoLoggingToWinEvents] [-StartAsNamedInstance] [-DisableMonitoring] [-IncreasedExtents] [-TraceFlagsOverride] [[-StartUpConfig] \u003cObject\u003e] [-Offline] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaTcpPort", "Description": "This function changes the TCP port used by the specified SQL Server.", "Tags": [ "Service", "Port", "TCP", "Configure" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "Credential", "Credential object used to connect to the Windows server itself as a different user (like SQL Configuration Manager)", "", false, "false", "" ], [ "Port", "TCPPort that SQLService should listen on.", "", true, "false", "0" ], [ "IpAddress", "Which IpAddress should the portchange , if omitted allip (0.0.0.0) will be changed with the new port number.", "", 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" ], [ "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": "@H0s0n77", "Synopsis": "Changes the TCP port used by the specified SQL Server.", "Name": "Set-DbaTcpPort", "Links": "https://dbatools.io/Set-DbaTcpPort", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaTcpPort -SqlInstance sql2017 -Port 1433\nSets the port number 1433 for all IP Addresses on the default instance on sql2017. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaTcpPort -SqlInstance winserver\\sqlexpress -IpAddress 192.168.1.22 -Port 1433 -Confirm:$false\nSets the port number 1433 for IP 192.168.1.22 on the sqlexpress instance on winserver. Does not prompt for confirmation.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaTcpPort -SqlInstance sql2017, sql2019 -port 1337 -Credential ad\\dba\nSets the port number 1337 for all IP Addresses on SqlInstance sql2017 and sql2019 using the credentials for ad\\dba. Prompts for confirmation.", "Syntax": "Set-DbaTcpPort [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Port] \u003cInt32\u003e [[-IpAddress] \u003cIPAddress[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbaTempdbConfig", "Description": "Calculates tempdb size and file configurations based on passed parameters, calculated values, and Microsoft best practices. User must declare SQL Server to be configured and total data file size as mandatory values. Function then calculates the number of data files based on logical cores on the target host and create evenly sized data files based on the total data size declared by the user, with a log file 25% of the total data file size.\n\nOther parameters can adjust the settings as the user desires (such as different file paths, number of data files, and log file size). No functions that shrink or delete data files are performed. If you wish to do this, you will need to resize tempdb so that it is \"smaller\" than what the function will size it to before running the function.", "Tags": [ "Tempdb", "Space", "Configure", "Configuration" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DataFileCount", "Specifies the number of data files to create. If this number is not specified, the number of logical cores of the host will be used.", "", false, "false", "0" ], [ "DataFileSizeMB", "Specifies the total data file size in megabytes. This is distributed across the total number of data files.", "", true, "false", "0" ], [ "LogFileSizeMB", "Specifies the log file size in megabytes. If not specified, this will be set to 25% of total data file size.", "", false, "false", "0" ], [ "DataFileGrowthMB", "Specifies the growth amount for the data file(s) in megabytes. The default is 512 MB.", "", false, "false", "512" ], [ "LogFileGrowthMB", "Specifies the growth amount for the log file in megabytes. The default is 512 MB.", "", false, "false", "512" ], [ "DataPath", "Specifies the filesystem path in which to create the tempdb data files. If not specified, current tempdb location will be used.", "", false, "false", "" ], [ "LogPath", "Specifies the filesystem path in which to create the tempdb log file. If not specified, current tempdb location will be used.", "", false, "false", "" ], [ "OutFile", "Specifies the filesystem path into which the generated T-SQL script will be saved.", "", false, "false", "" ], [ "OutputScriptOnly", "If this switch is enabled, only the T-SQL script to change the tempdb configuration is created and output.", "", false, "false", "False" ], [ "DisableGrowth", "If this switch is enabled, the tempdb files will be configured to not grow. This overrides -DataFileGrowthMB and -LogFileGrowthMB.", "", 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", "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": "Set-DbaTempDbConfiguration,Set-SqlTempDbConfiguration", "Author": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Sets tempdb data and log files according to best practices.", "Name": "Set-DbaTempdbConfig", "Links": "https://dbatools.io/Set-DbaTempdbConfig", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000\nCreates tempdb with a number of data files equal to the logical cores where each file is equal to 1000MB divided by the number of logical cores, with a log file of 250MB.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -DataFileCount 8\nCreates tempdb with 8 data files, each one sized at 125MB, with a log file of 250MB.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -OutputScriptOnly\nProvides a SQL script output to configure tempdb according to the passed parameters.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -DisableGrowth\nDisables the growth for the data and log files.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -OutputScriptOnly\nReturns the T-SQL script representing tempdb configuration.", "Syntax": "Set-DbaTempdbConfig [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-DataFileCount] \u003cInt32\u003e] [-DataFileSizeMB] \u003cInt32\u003e [[-LogFileSizeMB] \u003cInt32\u003e] [[-DataFileGrowthMB] \u003cInt32\u003e] [[-LogFileGrowthMB] \u003cInt32\u003e] [[-DataPath] \u003cString\u003e] [[-LogPath] \u003cString\u003e] [[-OutFile] \u003cString\u003e] [-OutputScriptOnly] [-DisableGrowth] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Set-DbatoolsConfig", "Description": "This function creates or changes configuration values.\nThese are used in dbatools to provide dynamic configuration information outside the PowerShell variable system.", "Tags": [ "Config", "Module" ], "Params": [ [ "FullName", "The full name of a configuration element. Must be namespaced \u003cModule\u003e.\u003cName\u003e.\r\nThe name can have any number of sub-segments, in order to better group configurations thematically.", "", true, "false", "" ], [ "Name", "Name of the configuration entry. If an entry of exactly this non-casesensitive name already exists, its value will be overwritten.\r\nDuplicate names across different modules are possible and will be treated separately.\r\nIf a name contains namespace notation and no module is set, the first namespace element will be used as module instead of name. Example:\r\n-Name \"Nordwind.Server\"\r\nIs Equivalent to\r\n-Name \"Server\" -Module \"Nordwind\"", "", true, "false", "" ], [ "Module", "This allows grouping configuration elements into groups based on the module/component they server.\r\nIf this parameter is not set, the configuration element is stored under its name only, which increases the likelihood of name conflicts in large environments.", "", false, "false", "" ], [ "Value", "The value to assign to the named configuration element.", "", false, "false", "" ], [ "Description", "Using this, the configuration setting is given a description, making it easier for a user to comprehend, what a specific setting is for.", "", false, "false", "" ], [ "Validation", "The name of the validation script used for input validation.\r\nThese can be used to validate make sure that input is of the proper data type.\r\nNew validation scripts can be registered using Register-DbatoolsConfigValidation", "", false, "false", "" ], [ "Handler", "A scriptblock that is executed when a value is being set.\r\nIs only executed if the validation was successful (assuming there was a validation, of course)", "", false, "false", "" ], [ "Hidden", "Setting this parameter hides the configuration from casual discovery. Configurations with this set will only be returned by Get-Config, if the parameter \"-Force\" is used.\r\nThis should be set for all system settings a user should have no business changing (e.g. for Infrastructure related settings such as mail server).", "", false, "false", "False" ], [ "Default", "Setting this parameter causes the system to treat this configuration as a default setting. If the configuration already exists, no changes will be performed.\r\nUseful in scenarios where for some reason it is not practical to automatically set defaults before loading user profiles.", "", false, "false", "False" ], [ "Initialize", "Use this when setting configurations as part of module import.\r\nWhen initializing a configuration, it will only do a thing if the configuration hasn\u0027t already been initialized (So if you load the module multiple times or in multiple runspaces, it won\u0027t make a \r\ndifference)\r\nAlso, if there already was a non-initialized setting set for a given configuration, it will then try to set the old value again.\r\nThis value will be processed by handlers, if any are set.", "", false, "false", "False" ], [ "DisableValidation", "This parameters disables the input validation - if any - when processing a setting.\r\nNormally this shouldn\u0027t be circumvented, but just in case, it can be disabled.", "", false, "false", "False" ], [ "DisableHandler", "Internal Use Only.\r\nThis parameter disables the configuration handlers.\r\nConfiguration handlers are designed to automatically validate and process input set to a config value, in addition to writing the value.\r\nIn many cases, this is used to improve performance, by forking the value location also to a static C#-field, which is then used, rather than searching a Hashtable.\r\nSometimes it may only be used to introduce input validation.\r\nDuring module import, some handlers are registered and many values written to configuration.\r\nHowever, some of those values actually are already set as default values within the library. Processing a handler will cost a few ms.\r\nAdd up a couple dozen such events and the delay is very notable.", "", 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": "Set-DbaConfig", "Author": "Friedrich Weinmann", "Synopsis": "Sets configuration entries.", "Name": "Set-DbatoolsConfig", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSet-DbatoolsConfig -Name \u0027User\u0027 -Value \"Friedrich\" -Description \"The user under which the show must go on.\"\nCreates a configuration entry named \"User\" with the value \"Friedrich\"\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSet-DbatoolsConfig -Name \u0027mymodule.User\u0027 -Value \"Friedrich\" -Description \"The user under which the show must go on.\" -Handler $scriptBlock -Initialize -Validation String\nCreates a configuration entry ...\r\n- Named \"mymodule.user\"\r\n- With the value \"Friedrich\"\r\n- It adds a description as noted\r\n- It registers the scriptblock stored in $scriptBlock as handler\r\n- It initializes the script. This block only executes the first time a it is run like this. Subsequent calls will be ignored.\r\n- It registers the basic string input type validator\r\nThis is the default example for modules using the configuration system.\r\nNote: While the -Handler parameter is optional, it is important to add it at the initial initialize call, if you are planning to add it.\r\nOnly then will the system validate previous settings (such as what a user might have placed in his user profile)\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSet-DbatoolsConfig \u0027ConfigLink\u0027 \u0027https://www.example.com/config.xml\u0027 \u0027Company\u0027 -Hidden\nCreates a configuration entry named \"ConfigLink\" in the \"Company\" module with the value \u0027https://www.example.com/config.xml\u0027.\r\nThis entry is hidden from casual discovery using Get-Config.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eSet-DbatoolsConfig \u0027Network.Firewall\u0027 \u002710.0.0.2\u0027 -Default\nCreates a configuration entry named \"Firewall\" in the \"Network\" module with the value \u002710.0.0.2\u0027\r\nThis is only set, if the setting does not exist yet. If it does, this command will apply no changes.", "Syntax": "Set-DbatoolsConfig [-FullName] \u003cString\u003e [[-Value] \u003cObject\u003e] [-Description \u003cString\u003e] [-Validation \u003cString\u003e] [-Handler \u003cScriptBlock\u003e] [-Hidden] [-Default] [-Initialize] [-DisableValidation] [-DisableHandler] [-EnableException] [\u003cCommonParameters\u003e]\nSet-DbatoolsConfig [-Name] \u003cString\u003e [[-Module] \u003cString\u003e] [[-Value] \u003cObject\u003e] [-Description \u003cString\u003e] [-Validation \u003cString\u003e] [-Handler \u003cScriptBlock\u003e] [-Hidden] [-Default] [-Initialize] [-DisableValidation] [-DisableHandler] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Show-DbaDbList", "Description": "Shows a list of databases in a GUI. Returns a string holding the name of the selected database. Hitting cancel returns null.", "Tags": [ "Database", "FileSystem" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Title", "Title of the window being displayed. Default is \"Select Database\".", "", false, "false", "Select Database" ], [ "Header", "Header text displayed above the database listing. Default is \"Select the database:\".", "", false, "false", "Select the database:" ], [ "DefaultDb", "Specify a database to have selected when the window appears.", "", false, "false", "" ] ], "Alias": "Show-DbaDatabaseList,Show-SqlDatabaseList", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Shows a list of databases in a GUI.", "Name": "Show-DbaDbList", "Links": "https://dbatools.io/Show-DbaDbList", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eShow-DbaDbList -SqlInstance sqlserver2014a\nShows a GUI list of databases using Windows Authentication to connect to the SQL Server. Returns a string of the selected database.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eShow-DbaDbList -SqlInstance sqlserver2014a -SqlCredential $cred\nShows a GUI list of databases using SQL credentials to connect to the SQL Server. Returns a string of the selected database.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eShow-DbaDbList -SqlInstance sqlserver2014a -DefaultDb master\nShows a GUI list of databases using Windows Authentication to connect to the SQL Server. The \"master\" database will be selected when the lists shows. Returns a string of the selected database.", "Syntax": "Show-DbaDbList [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Title] \u003cString\u003e] [[-Header] \u003cString\u003e] [[-DefaultDb] \u003cString\u003e] [\u003cCommonParameters\u003e]" }, { "CommandName": "Show-DbaServerFileSystem", "Description": "Similar to the remote file system popup you see when browsing a remote SQL Server in SQL Server Management Studio, this function allows you to traverse the remote SQL Server\u0027s file structure.\n\nShow-DbaServerFileSystem uses SQL Management Objects to browse the directories and what you see is limited to the permissions of the account running the command.", "Tags": [ "Storage", "FileSystem" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Defaults to localhost.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Show-SqlServerFileSystem", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Shows file system on remote SQL Server in a local GUI and returns the selected directory name", "Name": "Show-DbaServerFileSystem", "Links": "https://dbatools.io/Show-DbaServerFileSystem", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eShow-DbaServerFileSystem -SqlInstance sql2017\nShows a list of databases using Windows Authentication to connect to the SQL Server. Returns a string of the selected path.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eShow-DbaServerFileSystem -SqlInstance sql2017 -SqlCredential $cred\nShows a list of databases using SQL credentials to connect to the SQL Server. Returns a string of the selected path.", "Syntax": "Show-DbaServerFileSystem [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaAgentJob", "Description": "This command starts a job then returns connected SMO object for SQL Agent Job information for each instance(s) of SQL Server.", "Tags": [ "Job", "Agent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Job", "The job(s) to process - this list is auto-populated from the server. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude - this list is auto-populated from the server.", "", false, "false", "" ], [ "InputObject", "Internal parameter that enables piping", "", true, "true (ByValue)", "" ], [ "AllJobs", "Retrieve all the jobs", "", false, "false", "False" ], [ "Wait", "Wait for output until the job has started", "", false, "false", "False" ], [ "WaitPeriod", "Wait period in seconds to use when -Wait is used", "", false, "false", "3" ], [ "SleepPeriod", "Period in milliseconds to wait after a job has started", "", false, "false", "300" ], [ "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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Starts a running SQL Server Agent Job.", "Name": "Start-DbaAgentJob", "Links": "https://dbatools.io/Start-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaAgentJob -SqlInstance localhost\nStarts all running SQL Agent Jobs on the local SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture | Start-DbaAgentJob\nStarts the cdc.DBWithCDC_capture SQL Agent Job on sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStart-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture\nStarts the cdc.DBWithCDC_capture SQL Agent Job on sql2016\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$servers | Find-DbaAgentJob -IsFailed | Start-DbaAgentJob\nRestarts all failed jobs on all servers in the $servers collection\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eStart-DbaAgentJob -SqlInstance sql2016 -AllJobs\nStart all the jobs", "Syntax": "Start-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] [-AllJobs] [-Wait] [-WaitPeriod \u003cInt32\u003e] [-SleepPeriod \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStart-DbaAgentJob -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] [-AllJobs] [-Wait] [-WaitPeriod \u003cInt32\u003e] [-SleepPeriod \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStart-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] -InputObject \u003cJob[]\u003e [-AllJobs] [-Wait] [-WaitPeriod \u003cInt32\u003e] [-SleepPeriod \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaEndpoint", "Description": "Starts endpoints on a SQL Server instance.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "EndPoint", "Only start specific endpoints.", "", false, "false", "" ], [ "AllEndpoints", "Start all endpoints on an instance.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-Endpoint.", "", 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" ], [ "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": "Starts endpoints on a SQL Server instance.", "Name": "Start-DbaEndpoint", "Links": "https://dbatools.io/Start-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaEndpoint -SqlInstance sqlserver2012 -AllEndpoints\nStarts all endpoints on the sqlserver2014 instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStart-DbaEndpoint -SqlInstance sqlserver2012 -Endpoint endpoint1,endpoint2 -SqlCredential sqladmin\nLogs into sqlserver2012 using alternative credentials and starts the endpoint1 and endpoint2 endpoints.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-Endpoint -SqlInstance sqlserver2012 -Endpoint endpoint1 | Start-DbaEndpoint\nStarts the endpoints returned from the Get-Endpoint function.", "Syntax": "Start-DbaEndpoint [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-EndPoint] \u003cString[]\u003e] [-AllEndpoints] [[-InputObject] \u003cEndpoint[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaMigration", "Description": "Start-DbaMigration consolidates most of the migration tools in dbatools into one command. This is useful when you\u0027re looking to migrate entire instances. It less flexible than using the underlying functions. Think of it as an easy button. It migrates:\n\nAll user databases to exclude support databases such as ReportServerTempDB (Use -IncludeSupportDbs for this). Use -Exclude Databases to skip.\nAll logins. Use -Exclude Logins to skip.\nAll database mail objects. Use -Exclude DatabaseMail\nAll credentials. Use -Exclude Credentials to skip.\nAll objects within the Job Server (SQL Agent). Use -Exclude AgentServer to skip.\nAll linked servers. Use -Exclude LinkedServers to skip.\nAll groups and servers within Central Management Server. Use -Exclude CentralManagementServer to skip.\nAll SQL Server configuration objects (everything in sp_configure). Use -Exclude SpConfigure to skip.\nAll user objects in system databases. Use -Exclude SysDbUserObjects to skip.\nAll system triggers. Use -Exclude SystemTriggers to skip.\nAll system backup devices. Use -Exclude BackupDevices to skip.\nAll Audits. Use -Exclude Audits to skip.\nAll Endpoints. Use -Exclude Endpoints to skip.\nAll Extended Events. Use -Exclude ExtendedEvents to skip.\nAll Policy Management objects. Use -Exclude PolicyManagement to skip.\nAll Resource Governor objects. Use -Exclude ResourceGovernor to skip.\nAll Server Audit Specifications. Use -Exclude ServerAuditSpecifications to skip.\nAll Custom Errors (User Defined Messages). Use -Exclude CustomErrors to skip.\nCopies All Data Collector collection sets. Does not configure the server. Use -Exclude DataCollector to skip.\n\nThis script provides the ability to migrate databases using detach/copy/attach or backup/restore. SQL Server logins, including passwords, SID and database/server roles can also be migrated. In addition, job server objects can be migrated and server configuration settings can be exported or migrated. This script works with named instances, clusters and SQL Express.\n\nBy default, databases will be migrated to the destination SQL Server\u0027s default data and log directories. You can override this by specifying -ReuseSourceFolderStructure. Filestreams and filegroups are also migrated. Safety is emphasized.", "Tags": "Migration", "Params": [ [ "Source", "Source SQL Server.", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You may specify multiple servers.\nNote that when using -BackupRestore with multiple servers, the backup will only be performed once and backups will be deleted at the end (if you didn\u0027t specify -NoBackupCleanup).\nWhen using -DetachAttach with multiple servers, -Reattach must be specified.", "", false, "false", "" ], [ "DetachAttach", "If this switch is enabled, the the detach/copy/attach method is used to perform database migrations. No files are deleted on Source. If the destination attachment fails, the source database will be \r\nreattached. File copies are performed over administrative shares (\\\\server\\x$\\mssql) using BITS. If a database is being mirrored, the mirror will be broken prior to migration.", "", false, "false", "False" ], [ "Reattach", "If this switch is enabled, all databases are reattached to Source after a DetachAttach migration is complete.", "", false, "false", "False" ], [ "BackupRestore", "If this switch is enabled, the Copy-Only backup and restore method is used to perform database migrations. You must specify -SharedPath with a valid UNC format as well (\\\\server\\share).", "", false, "false", "False" ], [ "SharedPath", "Specifies the network location for the backup files. The SQL Server service accounts on both Source and Destination must have read/write permission to access this location.", "", false, "false", "" ], [ "WithReplace", "If this switch is enabled, databases are restored from backup using WITH REPLACE. This is useful if you want to stage some complex file paths.", "", false, "false", "False" ], [ "NoRecovery", "If this switch is enabled, databases will be left in the No Recovery state to enable further backups to be added.", "", false, "false", "False" ], [ "SetSourceReadOnly", "If this switch is enabled, all migrated databases will be set to ReadOnly on the source instance prior to detach/attach \u0026 backup/restore. If -Reattach is specified, the database is set to read-only \r\nafter reattaching.", "", false, "false", "False" ], [ "ReuseSourceFolderStructure", "If this switch is enabled, the data and log directory structures on Source will be kept on Destination. Otherwise, databases will be migrated to Destination\u0027s default data and log directories.\nConsider this if you\u0027re migrating between different versions and use part of Microsoft\u0027s default SQL structure (MSSQL12.INSTANCE, etc.).", "", false, "false", "False" ], [ "IncludeSupportDbs", "If this switch is enabled, the ReportServer, ReportServerTempDb, SSIDb, and distribution databases will be migrated if they exist. A logfile named $SOURCE-$DESTINATION-$date-Sqls.csv will be written \r\nto the current directory. Requires -BackupRestore or -DetachAttach.", "", false, "false", "False" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Exclude", "Exclude one or more objects to migrate\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\nDataCollector", "", false, "false", "" ], [ "DisableJobsOnDestination", "If this switch is enabled, migrated SQL Agent jobs will be disabled on the destination instance.", "", false, "false", "False" ], [ "DisableJobsOnSource", "If this switch is enabled, SQL Agent jobs will be disabled on the source instance.", "", false, "false", "False" ], [ "ExcludeSaRename", "If this switch is enabled, the sa account will not be renamed on the destination instance to match the source.", "", false, "false", "False" ], [ "UseLastBackup", "Use the last full, diff and logs instead of performing backups. Note that the backups must exist in a location accessible by all destination servers, such a network share.", "", false, "false", "False" ], [ "Continue", "If specified, will to attempt to restore transaction log backups on top of existing database(s) in Recovering or Standby states. Only usable with -UseLastBackup", "", false, "false", "False" ], [ "Force", "If migrating users, forces drop and recreate of SQL and Windows logins.\r\nIf migrating databases, deletes existing databases with matching names.\r\nIf using -DetachAttach, -Force will break mirrors and drop dbs from Availability Groups.\nFor other migration objects, it will just drop existing items and readd, if -force is supported within the underlying function.", "", 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" ], [ "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": "Start-SqlMigration", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates 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 Exclude or use the other functions available within the dbatools module.", "Name": "Start-DbaMigration", "Links": "https://dbatools.io/Start-DbaMigration", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaMigration -Source sqlserver\\instance -Destination sqlcluster -DetachAttach\nAll databases, logins, job objects and sp_configure options will be migrated from sqlserver\\instance to sqlcluster. Databases will be migrated using the detach/copy files/attach method. Dbowner will \r\nbe updated. User passwords, SIDs, database roles and server roles will be migrated along with the login.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$params = @{\n\u003e\u003e Source = \"sqlcluster\"\r\n\u003e\u003e Destination = \"sql2016\"\r\n\u003e\u003e SourceSqlCredential = $scred\r\n\u003e\u003e DestinationSqlCredential = $cred\r\n\u003e\u003e SharedPath = \"\\\\fileserver\\share\\sqlbackups\\Migration\"\r\n\u003e\u003e BackupRestore = $true\r\n\u003e\u003e ReuseSourceFolderStructure\" = $true\r\n\u003e\u003e Force = $true\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Start-DbaMigration @params -Verbose\nUtilizes splatting technique to set all the needed parameters. This will migrate databases using the backup/restore method. It will also include migration of the logins, database mail configuration, \r\ncredentials, SQL Agent, Central Management Server, and SQL Server global configuration.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStart-DbaMigration -Verbose -Source sqlcluster -Destination sql2016 -DetachAttach -Reattach -SetSourceReadonly\nMigrates databases using detach/copy/attach. Reattach at source and set source databases read-only. Also migrates everything else.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$PSDefaultParameters = @{\n\u003e\u003e \"dbatools:Source\" = \"sqlcluster\"\r\n\u003e\u003e \"dbatools:Destination\" = \"sql2016\"\r\n\u003e\u003e }\r\n\u003e\u003e\r\nPS C:\\\u003e Start-DbaMigration -Verbose -NoDatabases -NoLogins\nUtilizes the PSDefaultParameterValues system variable, and sets the Source and Destination parameters for any function in the module that has those parameter names. This prevents the need from \r\npassing them in constantly.\r\nThe execution of the function will migrate everything but logins and databases.", "Syntax": "Start-DbaMigration [[-Source] \u003cDbaInstanceParameter\u003e] [[-Destination] \u003cDbaInstanceParameter[]\u003e] [-DetachAttach] [-Reattach] [-BackupRestore] [[-SharedPath] \u003cString\u003e] [-WithReplace] [-NoRecovery] [-SetSourceReadOnly] [-ReuseSourceFolderStructure] [-IncludeSupportDbs] [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Exclude] \u003cString[]\u003e] [-DisableJobsOnDestination] [-DisableJobsOnSource] [-ExcludeSaRename] [-UseLastBackup] [-Continue] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaPfDataCollectorSet", "Description": "Starts Performance Monitor Data Collector Set.", "Tags": "PerfMon", "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 to start.", "DataCollectorSet", false, "false", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSet via the pipeline.", "", false, "true (ByValue)", "" ], [ "NoWait", "If this switch is enabled, the collector is started and the results are returned immediately.", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Starts Performance Monitor Data Collector Set.", "Name": "Start-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Start-DbaPfDataCollectorSet", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaPfDataCollectorSet\nAttempts to start all ready Collectors on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStart-DbaPfDataCollectorSet -ComputerName sql2017\nAttempts to start all ready Collectors on localhost.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStart-DbaPfDataCollectorSet -ComputerName sql2017, sql2016 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nStarts the \u0027System Correlation\u0027 Collector on sql2017 and sql2016 using alternative credentials.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Start-DbaPfDataCollectorSet\nStarts the \u0027System Correlation\u0027 Collector.", "Syntax": "Start-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-NoWait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaService", "Description": "Starts the SQL Server related services on one or more computers. Will follow SQL Server service dependencies.\n\nRequires Local Admin rights on destination computer(s).", "Tags": [ "Service", "SqlServer", "Instance", "Connect" ], "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "false", "$env:COMPUTERNAME" ], [ "InstanceName", "Only affects services that belong to the specific instances.", "Instance", false, "false", "" ], [ "Type", "Use -Type to collect only services of the desired SqlServiceType.\r\nCan be one of the following: \"Agent\",\"Browser\",\"Engine\",\"FullText\",\"SSAS\",\"SSIS\",\"SSRS\"", "", false, "false", "" ], [ "InputObject", "A collection of services from Get-DbaService", "ServiceCollection", true, "true (ByValue)", "" ], [ "Timeout", "How long to wait for the start/stop request completion before moving on. Specify 0 to wait indefinitely.", "", false, "false", "60" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", 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 cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "Start-DbaSqlService", "Author": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Starts SQL Server services on a computer.", "Name": "Start-DbaService", "Links": "https://dbatools.io/Start-DbaService", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaService -ComputerName sqlserver2014a\nStarts the SQL Server related services on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027| Get-DbaService | Start-DbaService\nGets the SQL Server related services on computers sql1, sql2 and sql3 and starts them.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStart-DbaService -ComputerName sql1,sql2 -Instance MSSQLSERVER\nStarts the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eStart-DbaService -ComputerName $MyServers -Type SSRS\nStarts the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.", "Syntax": "Start-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-Timeout \u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStart-DbaService [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-Timeout \u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaTrace", "Description": "Starts SQL Server traces", "Tags": [ "Security", "Trace" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "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", "" ], [ "Id", "A list of trace ids", "", false, "false", "" ], [ "InputObject", "Internal parameter for piping", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Starts SQL Server traces", "Name": "Start-DbaTrace", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaTrace -SqlInstance sql2008\nStarts all traces on sql2008\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStart-DbaTrace -SqlInstance sql2008 -Id 1\nStarts all trace with ID 1 on sql2008\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2008 | Out-GridView -PassThru | Start-DbaTrace\nStarts selected traces on sql2008", "Syntax": "Start-DbaTrace [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Id] \u003cInt32[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaXESession", "Description": "This script starts Extended Events sessions on a SQL Server instance.", "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", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "Only start specific Extended Events sessions.", "Sessions", true, "false", "" ], [ "StopAt", "Specifies a datetime at which the session will be stopped. This is done via a self-deleting schedule.", "", false, "false", "" ], [ "AllSessions", "Start all Extended Events sessions on an instance, ignoring the packaged sessions: AlwaysOn_health, system_health, telemetry_xevents.", "", true, "false", "False" ], [ "InputObject", "Internal parameter to support piping from Get-DbaXESession", "", 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.", "", false, "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": "", "Author": "Doug Meyers", "Synopsis": "Starts Extended Events sessions.", "Name": "Start-DbaXESession", "Links": "https://dbatools.io/Start-DbaXESession", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStart-DbaXESession -SqlInstance sqlserver2012 -AllSessions\nStarts all Extended Event Session on the sqlserver2014 instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStart-DbaXESession -SqlInstance sqlserver2012 -Session xesession1,xesession2\nStarts the xesession1 and xesession2 Extended Event sessions.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStart-DbaXESession -SqlInstance sqlserver2012 -Session xesession1,xesession2 -StopAt (Get-Date).AddMinutes(30)\nStarts the xesession1 and xesession2 Extended Event sessions and stops them in 30 minutes.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sqlserver2012 -Session xesession1 | Start-DbaXESession\nStarts the sessions returned from the Get-DbaXESession function.", "Syntax": "Start-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Session \u003cObject[]\u003e [-StopAt \u003cDateTime\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStart-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-StopAt \u003cDateTime\u003e] -AllSessions [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStart-DbaXESession [-StopAt \u003cDateTime\u003e] -InputObject \u003cSession[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Start-DbaXESmartTarget", "Description": "XESmartTarget offers the ability to set up complex actions in response to Extended Events captured in sessions, without writing a single line of code.\n\nSee more at https://github.com/spaghettidba/XESmartTarget/wiki", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies the name of the database that contains the target table.", "", false, "false", "" ], [ "Session", "Name of the Extended Events session to attach to.\nYou can monitor a single session with an instance of XESmartTarget. In case you need to perform action on multiple sessions, run an additional instance of XESmartTarget, with its own configuration \r\nfile.", "", true, "false", "" ], [ "FailOnProcessingError", "If this switch is enabled, the a processing error will trigger a failure.", "", false, "false", "False" ], [ "Responder", "The list of responses can include zero or more Response objects, each to be configured by specifying values for their public members.", "", false, "false", "" ], [ "Template", "Path to the dbatools built-in templates", "", false, "false", "" ], [ "NotAsJob", "If this switch is enabled, output will be sent to screen indefinitely. BY default, a job will be run in the background.", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "XESmartTarget runs as a client application for an Extended Events session running on a SQL Server instance.", "Name": "Start-DbaXESmartTarget", "Links": "https://dbatools.io/Start-DbaXESmartTarget", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query \"update table set whatever = 1\"\nPS C:\\\u003eStart-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\nExecutes a T-SQL command against dbadb on sql2017 whenever a deadlock event is recorded.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query \"update table set whatever = 1\"\nPS C:\\\u003e$params = @{\r\n\u003e\u003e SmtpServer = \"smtp.ad.local\"\r\n\u003e\u003e To = \"admin@ad.local\"\r\n\u003e\u003e Sender = \"reports@ad.local\"\r\n\u003e\u003e Subject = \"Query executed\"\r\n\u003e\u003e Body = \"Query executed at {collection_time}\"\r\n\u003e\u003e Attachment = \"batch_text\"\r\n\u003e\u003e AttachmentFileName = \"query.sql\"\r\n\u003e\u003e }\r\nPS C:\\\u003e $emailresponse = New-DbaXESmartEmail @params\r\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2017 -Session querytracker -Responder $response, $emailresponse\nExecutes a T-SQL command against dbadb on sql2017 and sends an email whenever a querytracker event is recorded.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$columns = \"cpu_time\", \"duration\", \"physical_reads\", \"logical_reads\", \"writes\", \"row_count\", \"batch_text\"\nPS C:\\\u003e $response = New-DbaXESmartTableWriter -SqlInstance sql2017 -Database dbadb -Table deadlocktracker -OutputColumns $columns -Filter \"duration \u003e 10000\"\r\nPS C:\\\u003e Start-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\nWrites Extended Events to the deadlocktracker table in dbadb on sql2017.", "Syntax": "Start-DbaXESmartTarget [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [-Session] \u003cString\u003e [-FailOnProcessingError] [[-Responder] \u003cObject[]\u003e] [[-Template] \u003cString[]\u003e] [-NotAsJob] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaAgentJob", "Description": "This command stops a job then returns connected SMO object for SQL Agent Job information for each instance(s) of SQL Server.", "Tags": [ "Job", "Agent" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Job", "The job(s) to process - this list is auto-populated from the server. If unspecified, all jobs will be processed.", "", false, "false", "" ], [ "ExcludeJob", "The job(s) to exclude - this list is auto-populated from the server.", "", false, "false", "" ], [ "InputObject", "Internal parameter that enables piping", "", true, "true (ByValue)", "" ], [ "Wait", "Wait for output until the job has completely stopped", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops a running SQL Server Agent Job.", "Name": "Stop-DbaAgentJob", "Links": "https://dbatools.io/Stop-DbaAgentJob", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaAgentJob -SqlInstance localhost\nStops all running SQL Agent Jobs on the local SQL Server instance\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture | Stop-DbaAgentJob\nStops the cdc.DBWithCDC_capture SQL Agent Job on sql2016\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStop-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture\nStops the cdc.DBWithCDC_capture SQL Agent Job on sql2016", "Syntax": "Stop-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] [-Wait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaAgentJob -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] [-Wait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] -InputObject \u003cJob[]\u003e [-Wait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaEndpoint", "Description": "Stops endpoints on a SQL Server instance.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "EndPoint", "Only stop specific endpoints.", "", false, "false", "" ], [ "AllEndpoints", "Stops all endpoints on an instance.", "", false, "false", "False" ], [ "InputObject", "Enables piping from Get-Endpoint.", "", 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" ], [ "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": "Stops endpoints on a SQL Server instance.", "Name": "Stop-DbaEndpoint", "Links": "https://dbatools.io/Stop-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaEndpoint -SqlInstance sql2017a -AllEndpoints\nStops all endpoints on the sqlserver2014 instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStop-DbaEndpoint -SqlInstance sql2017a -Endpoint endpoint1,endpoint2\nStops the endpoint1 and endpoint2 endpoints.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-Endpoint -SqlInstance sql2017a -Endpoint endpoint1 | Stop-DbaEndpoint\nStops the endpoints returned from the Get-Endpoint command.", "Syntax": "Stop-DbaEndpoint [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-EndPoint] \u003cString[]\u003e] [-AllEndpoints] [[-InputObject] \u003cEndpoint[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaPfDataCollectorSet", "Description": "Stops Performance Monitor Data Collector Set.", "Tags": "PerfMon", "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 to stop.", "DataCollectorSet", false, "false", "" ], [ "InputObject", "Accepts the object output by Get-DbaPfDataCollectorSet via the pipeline.", "", false, "true (ByValue)", "" ], [ "NoWait", "If this switch is enabled, the collector is stopped and the results are returned immediately.", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops Performance Monitor Data Collector Set.", "Name": "Stop-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Stop-DbaPfDataCollectorSet", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaPfDataCollectorSet\nAttempts to stop all ready Collectors on localhost.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStop-DbaPfDataCollectorSet -ComputerName sql2017\nAttempts to stop all ready Collectors on localhost.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStop-DbaPfDataCollectorSet -ComputerName sql2017, sql2016 -Credential ad\\sqldba -CollectorSet \u0027System Correlation\u0027\nStops the \u0027System Correlation\u0027 Collector on sql2017 and sql2016 using alternative credentials.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Stop-DbaPfDataCollectorSet\nStops the \u0027System Correlation\u0027 Collector.", "Syntax": "Stop-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-NoWait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaProcess", "Description": "This command kills all spids associated with a spid, login, host, program or database.\n\nIf you are attempting to kill your own login sessions, the process performing the kills will be skipped.", "Tags": "Processes", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "Spid", "Specifies one or more spids to be killed. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "ExcludeSpid", "Specifies one or more spids which will not be killed. Options for this parameter are auto-populated from the server.\nExclude is the last filter to run, so even if a spid matches (for example) Hosts, if it\u0027s listed in Exclude it wil be excluded.", "", false, "false", "" ], [ "Database", "Specifies one or more databases whose processes will be killed. Options for this parameter are auto-populated from the server and only databases that have active processes are offered.\nThis parameter is auto-populated from -SqlInstance and allows only database names that have active processes. You can specify one or more Databases whose processes will be killed.", "", false, "false", "" ], [ "Login", "Specifies one or more login names whose processes will be killed. Options for this parameter are auto-populated from the server and only login names that have active processes are offered.", "", false, "false", "" ], [ "Hostname", "Specifies one or more client hostnames whose processes will be killed. Options for this parameter are auto-populated from the server and only hostnames that have active processes are offered.", "", false, "false", "" ], [ "Program", "Specifies one or more client programs whose processes will be killed. Options for this parameter are auto-populated from the server and only programs that have active processes are offered.", "", false, "false", "" ], [ "InputObject", "This is the process object passed by Get-DbaProcess if using a pipeline.", "", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "This command finds and kills SQL Server processes.", "Name": "Stop-DbaProcess", "Links": "https://dbatools.io/Stop-DbaProcess", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -Login base\\ctrlb, sa\nFinds all processes for base\\ctrlb and sa on sqlserver2014a, then kills them. Uses Windows Authentication to login to sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -SqlCredential $credential -Spid 56, 77\nFinds processes for spid 56 and 57, then kills them. Uses alternative (SQL or Windows) credentials to login to sqlserver2014a.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -Program \u0027Microsoft SQL Server Management Studio\u0027\nFinds processes that were created in Microsoft SQL Server Management Studio, then kills them.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -Hostname workstationx, server100\nFinds processes that were initiated (computers/clients) workstationx and server 1000, then kills them.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014 -Database tempdb -WhatIf\nShows what would happen if the command were executed.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eGet-DbaProcess -SqlInstance sql2016 -Program \u0027dbatools PowerShell module - dbatools.io\u0027 | Stop-DbaProcess\nFinds processes that were created with dbatools, then kills them.", "Syntax": "Stop-DbaProcess [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cInt32[]\u003e] [-ExcludeSpid \u003cInt32[]\u003e] [-Database \u003cString[]\u003e] [-Login \u003cString[]\u003e] [-Hostname \u003cString[]\u003e] [-Program \u003cString[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaProcess -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cInt32[]\u003e] [-ExcludeSpid \u003cInt32[]\u003e] [-Database \u003cString[]\u003e] [-Login \u003cString[]\u003e] [-Hostname \u003cString[]\u003e] [-Program \u003cString[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaProcess [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cInt32[]\u003e] [-ExcludeSpid \u003cInt32[]\u003e] [-Database \u003cString[]\u003e] [-Login \u003cString[]\u003e] [-Hostname \u003cString[]\u003e] [-Program \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaService", "Description": "Stops the SQL Server related services on one or more computers. Will follow SQL Server service dependencies.\n\nRequires Local Admin rights on destination computer(s).", "Tags": [ "Service", "Stop" ], "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "false", "$env:COMPUTERNAME" ], [ "InstanceName", "Only affects services that belong to the specific instances.", "Instance", false, "false", "" ], [ "Type", "Use -Type to collect only services of the desired SqlServiceType.\r\nCan be one of the following: \"Agent\",\"Browser\",\"Engine\",\"FullText\",\"SSAS\",\"SSIS\",\"SSRS\"", "", false, "false", "" ], [ "InputObject", "A collection of services from Get-DbaService", "ServiceCollection", true, "true (ByValue)", "" ], [ "Timeout", "How long to wait for the start/stop request completion before moving on. Specify 0 to wait indefinitely.", "", false, "false", "60" ], [ "Credential", "Credential object used to connect to the computer as a different user.", "", false, "false", "" ], [ "Force", "Use this switch to stop dependent services before proceeding with the specified service", "", 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 cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "Stop-DbaSqlService", "Author": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Stops SQL Server services on a computer.", "Name": "Stop-DbaService", "Links": "https://dbatools.io/Stop-DbaService", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaService -ComputerName sqlserver2014a\nStops the SQL Server related services on computer sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027| Get-DbaService | Stop-DbaService\nGets the SQL Server related services on computers sql1, sql2 and sql3 and stops them.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eStop-DbaService -ComputerName sql1,sql2 -Instance MSSQLSERVER\nStops the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eStop-DbaService -ComputerName $MyServers -Type SSRS\nStops the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eStop-DbaService -ComputerName sql1 -Type Engine -Force\nStops SQL Server database engine services on sql1 forcing dependent SQL Server Agent services to stop as well.", "Syntax": "Stop-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-Timeout \u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaService [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-Timeout \u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaTrace", "Description": "Stops SQL Server traces", "Tags": [ "Security", "Trace" ], "Params": [ [ "SqlInstance", "The target SQL Server instance", "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", "" ], [ "Id", "A list of trace ids", "", false, "false", "" ], [ "InputObject", "Internal parameter for piping", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops SQL Server traces", "Name": "Stop-DbaTrace", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaTrace -SqlInstance sql2008\nStops all traces on sql2008\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStop-DbaTrace -SqlInstance sql2008 -Id 1\nStops all trace with ID 1 on sql2008\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2008 | Out-GridView -PassThru | Stop-DbaTrace\nStops selected traces on sql2008", "Syntax": "Stop-DbaTrace [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Id] \u003cInt32[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaXESession", "Description": "This script stops Extended Events sessions on a SQL Server instance.", "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", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "Specifies individual Extended Events sessions to stop.", "Sessions", true, "false", "" ], [ "AllSessions", "If this switch is enabled, all Extended Events sessions will be stopped except the packaged sessions AlwaysOn_health, system_health, telemetry_xevents.", "", true, "false", "False" ], [ "InputObject", "Accepts the object output by Get-DbaXESession as the list of sessions to be stopped.", "", 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.", "", false, "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": "", "Author": "Doug Meyers", "Synopsis": "Stops Extended Events sessions.", "Name": "Stop-DbaXESession", "Links": "https://dbatools.io/Stop-DbaXESession", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eStop-DbaXESession -SqlInstance sqlserver2012 -AllSessions\nStops all Extended Event Session on the sqlserver2014 instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eStop-DbaXESession -SqlInstance sqlserver2012 -Session xesession1,xesession2\nStops the xesession1 and xesession2 Extended Event sessions.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sqlserver2012 -Session xesession1 | Stop-DbaXESession\nStops the sessions returned from the Get-DbaXESession function.", "Syntax": "Stop-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Session \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -AllSessions [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nStop-DbaXESession -InputObject \u003cSession[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Stop-DbaXESmartTarget", "Description": "Stops an XESmartTarget PowerShell job. Useful if you want to run a target, but not right now.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Params": [ [ "InputObject", "The XESmartTarget job object.", "", 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.", "", false, "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": "", "Author": "Chrissy LeMaire (@cl) | SmartTarget by Gianluca Sartori (@spaghettidba)", "Synopsis": "Stops an XESmartTarget PowerShell job. Useful if you want to run a target, but not right now.", "Name": "Stop-DbaXESmartTarget", "Links": "https://dbatools.io/Stop-DbaXESmartTarget\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaXESmartTarget | Stop-DbaXESmartTarget\nStops all XESmartTarget jobs.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaXESmartTarget | Where-Object Id -eq 2 | Stop-DbaXESmartTarget\nStops a specific XESmartTarget job.", "Syntax": "Stop-DbaXESmartTarget [-InputObject] \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Suspend-DbaAgDbDataMovement", "Description": "Suspends data movement for an availability group database on a SQL Server instance.", "Tags": [ "AvailabilityGroup", "HA", "AG" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SqlCredential", "Login to the SqlInstance instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The availability group where the database movement will be suspended.", "", false, "false", "" ], [ "Database", "The database or databases to suspend movement upon.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaAgDatabase", "", 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" ], [ "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": "Suspends data movement for an availability group database on a SQL Server instance.", "Name": "Suspend-DbaAgDbDataMovement", "Links": "https://dbatools.io/Suspend-DbaAgDbDataMovement", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSuspend-DbaAgDbDataMovement -SqlInstance sql2017a -AvailabilityGroup ag1 -Database db1, db2\nSuspends data movement on db1 and db2 to ag1 on sql2017a. Prompts for confirmation.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sql2017a, sql2019 | Out-GridView -Passthru | Suspend-DbaAgDbDataMovement -Confirm:$false\nSuspends data movement on the selected availability group databases. Does not prompt for confirmation.", "Syntax": "Suspend-DbaAgDbDataMovement [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString\u003e] [[-Database] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Sync-DbaAvailabilityGroup", "Description": "Syncs depdendent objects for availability groups. Such objects include:\n\nSpConfigure\nCustomErrors\nCredentials\nDatabaseMail\nLinkedServers\nLogins\nLoginPermissions\nSystemTriggers\nDatabaseOwner\nAgentCategory\nAgentOperator\nAgentAlert\nAgentProxy\nAgentSchedule\nAgentJob\n\nNote that any of these can be excluded. For specific object exclusions (such as a single job), using the underlying Copy-Dba* command will be required.\n\nThis command does not filter by which logins are in use by the ag databases or which linked servers are used. All objects that are not excluded will be copied like hulk smash.", "Tags": "HA", "Params": [ [ "Primary", "The primary SQL Server instance. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "PrimarySqlCredential", "Login to the primary instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Secondary", "The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.", "", false, "false", "" ], [ "SecondarySqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "AvailabilityGroup", "The name of the Availability Group.", "", false, "false", "" ], [ "Exclude", "Exclude one or more objects to export\nSpConfigure\r\nCustomErrors\r\nCredentials\r\nDatabaseMail\r\nLinkedServers\r\nLogins\r\nLoginPermissions\r\nSystemTriggers\r\nDatabaseOwner\r\nAgentCategory\r\nAgentOperator\r\nAgentAlert\r\nAgentProxy\r\nAgentSchedule\r\nAgentJob", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaAvailabilityGroup.", "", false, "true (ByValue)", "" ], [ "Force", "If this switch is enabled, the objects will dropped and recreated on Destination.", "", 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" ], [ "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": "Syncs depdendent objects such as jobs, logins and custom errors for availability groups", "Name": "Sync-DbaAvailabilityGroup", "Links": "https://dbatools.io/Sync-DbaAvailabilityGroup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSync-DbaAvailabilityGroup -Primary sql2016a -AvailabilityGroup db3\nSyncs the following on all replicas found in the db3 AG:\r\nSpConfigure, CustomErrors, Credentials, DatabaseMail, LinkedServers\r\nLogins, LoginPermissions, SystemTriggers, DatabaseOwner, AgentCategory,\r\nAgentOperator, AgentAlert, AgentProxy, AgentScheduleAgentJob\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2016a | Sync-DbaAvailabilityGroup -Exclude LoginPermissions, LinkedServers\nSyncs the following on all replicas found in the db3 AG:\r\nSpConfigure, CustomErrors, Credentials, DatabaseMail, Logins,\r\nSystemTriggers, DatabaseOwner, AgentCategory, AgentOperator\r\nAgentAlert, AgentProxy, AgentScheduleAgentJob\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sql2016a | Sync-DbaAvailabilityGroup -WhatIf\nShows what would happen if the command were to run but doesn\u0027t actually perform the action.", "Syntax": "Sync-DbaAvailabilityGroup [[-Primary] \u003cDbaInstanceParameter\u003e] [[-PrimarySqlCredential] \u003cPSCredential\u003e] [[-Secondary] \u003cDbaInstanceParameter[]\u003e] [[-SecondarySqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \u003cString\u003e] [[-Exclude] \u003cString[]\u003e] [[-InputObject] \u003cAvailabilityGroup[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Sync-DbaLoginPermission", "Description": "Syncs only SQL Server login permissions, roles, etc. Does not add or drop logins. If a matching login does not exist on the destination, the login will be skipped. Credential removal is not currently supported for this operation.", "Tags": [ "Migration", "Login" ], "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "true (ByValue)", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "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" ], [ "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": "Sync-DbaSqlLoginPermission,Sync-SqlLoginPermissions", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Copies SQL login permissions from one server to another.", "Name": "Sync-DbaLoginPermission", "Links": "https://dbatools.io/Sync-DbaLoginPermission", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eSync-DbaLoginPermission -Source sqlserver2014a -Destination sqlcluster\nSyncs only SQL Server login permissions, roles, etc. Does not add or drop logins or users. To copy logins and their permissions, use Copy-SqlLogin.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eSync-DbaLoginPermission -Source sqlserver2014a -Destination sqlcluster -Exclude realcajun -SourceSqlCredential $scred -DestinationSqlCredential $dcred\nCopies all login permissions except for realcajun using SQL Authentication to connect to each server. If a login already exists on the destination, the permissions will not be migrated.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eSync-DbaLoginPermission -Source sqlserver2014a -Destination sqlcluster -Login realcajun, netnerds\nCopies permissions ONLY for logins netnerds and realcajun.", "Syntax": "Sync-DbaLoginPermission [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [[-ExcludeLogin] \u003cString[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaBackupInformation", "Description": "Input is normally from a backup history object generated from `Format-DbaBackupInformation`. This is then parse to check that it\u0027s valid for restore. Tests performed include:\n - Checking unbroken LSN chain\n - If the target database exists and WithReplace has been provided\n - If any files already exist, but owned by other databases\n - Creates any new folders required\n - That the backup files exists at the location specified, and can be seen by the Sql Instance\n - If no errors are found then the objects for that database will me marked as Verified", "Tags": [ "Backup", "Restore", "DisasterRecovery" ], "Params": [ [ "BackupHistory", "dbatools BackupHistory object. Normally this will have been process with `Select-` and then `Format-DbaBackupInformation`", "", true, "true (ByValue)", "" ], [ "SqlInstance", "The Sql Server instance that wil be performing the restore", "ServerInstance,SqlServer", false, "false", "" ], [ "SqlCredential", "A Sql Credential to connect to $SqlInstance", "", false, "false", "" ], [ "WithReplace", "By default we won\u0027t overwrite an existing database, this switch tells us you want to", "", false, "false", "False" ], [ "Continue", "Switch to indicate a continuing restore", "", false, "false", "False" ], [ "VerifyOnly", "This switch indicates that you only wish to verify a restore, so runs a smaller number of tests as you won\u0027t be writing anything to the restore server", "", false, "false", "False" ], [ "OutputScriptOnly", "Switch to disable path creation. Will write a warning that a path does not exist", "", 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" ], [ "WhatIf", "Shows what would happen if the cmdlet runs. The cmdlet is not run.", "wi", false, "false", "" ], [ "Confirm", "Prompts you for confirmation before running the cmdlet.", "cf", false, "false", "" ] ], "Alias": "", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Tests a dbatools backup history object is correct for restoring", "Name": "Test-DbaBackupInformation", "Links": "https://dbatools.io/Test-DbaBackupInformation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$BackupHistory | Test-DbaBackupInformation -SqlInstance MyInstance\nPS C:\\\u003e $PassedDbs = $BackupHistory | Where-Object {$_.IsVerified -eq $True}\r\nPS C:\\\u003e $FailedDbs = $BackupHistory | Where-Object {$_.IsVerified -ne $True}\nPass in a BackupHistory object to be tested against MyInstance.\r\nThose records that pass are marked as verified. We can then use the IsVerified property to divide the failures and successes", "Syntax": "Test-DbaBackupInformation [-BackupHistory] \u003cObject[]\u003e [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-WithReplace] [-Continue] [-VerifyOnly] [-OutputScriptOnly] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaBuild", "Description": "Returns info about the specific build of a SQL instance, including the SP, the CU and the reference KB, End Of Support, wherever possible. It adds a Compliance property as true/false, and adds details about the \"targeted compliance\"", "Tags": [ "SqlBuild", "Version" ], "Params": [ [ "Build", "Instead of connecting to a real instance, pass a string identifying the build to get the info back.", "", false, "false", "" ], [ "MinimumBuild", "This is the build version to test \"compliance\" against. Anything below this is flagged as not compliant", "", false, "false", "" ], [ "MaxBehind", "Instead of using a specific MinimumBuild here you can pass \"how many service packs and cu back\" is the targeted compliance level. You can use xxSP or xxCU or both, where xx is a number. See the \r\nExamples for more information.", "", false, "false", "" ], [ "Latest", "Shortcut for specifying the very most up-to-date build available.", "", false, "false", "False" ], [ "SqlInstance", "Target any number of instances, in order to return their compliance state.", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "SqlCredential", "When connecting to an instance, use the credentials specified.", "Credential", false, "false", "" ], [ "Update", "Looks online for the most up to date reference, replacing the local one.", "", false, "false", "False" ], [ "Quiet", "Makes the function just return $true/$false. It\u0027s useful if you use Test-DbaBuild in your own scripts.", "", 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": "Test-DbaSqlBuild", "Author": "Simone Bizzotto (@niphold) | Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Returns SQL Server Build \"compliance\" level on a build", "Name": "Test-DbaBuild", "Links": "https://dbatools.io/Test-DbaBuild", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MinimumBuild \"12.0.5557\"\nReturns information about a build identified by \"12.0.5540\" (which is SQL 2014 with SP2 and CU4), which is not compliant as the minimum required\r\nbuild is \"12.0.5557\" (which is SQL 2014 with SP2 and CU8)\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MaxBehind \"1SP\"\nReturns information about a build identified by \"12.0.5540\", making sure it is AT MOST 1 Service Pack \"behind\". For that version,\r\nthat identifies an SP2, means accepting as the lowest compliance version as \"12.0.4110\", that identifies 2014 with SP1\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MaxBehind \"1SP 1CU\"\nReturns information about a build identified by \"12.0.5540\", making sure it is AT MOST 1 Service Pack \"behind\", plus 1 CU \"behind\". For that version,\r\nthat identifies an SP2 and CU, rolling back 1 SP brings you to \"12.0.4110\", but given the latest CU for SP1 is CU13, the target \"compliant\" build\r\nwill be \"12.0.4511\", which is 2014 with SP1 and CU12\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MaxBehind \"0CU\"\nReturns information about a build identified by \"12.0.5540\", making sure it is the latest CU release.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -Latest\nSame as previous, returns information about a build identified by \"12.0.5540\", making sure it is the latest build available.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.00.4502\" -MinimumBuild \"12.0.4511\" -Update\nSame as before, but tries to fetch the most up to date index online. When the online version is newer, the local one gets overwritten\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.4502\",\"10.50.4260\" -MinimumBuild \"12.0.4511\"\nReturns information builds identified by these versions strings\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a | Test-DbaBuild -MinimumBuild \"12.0.4511\"\nIntegrate with other cmdlets to have builds checked for all your registered servers on sqlserver2014a", "Syntax": "Test-DbaBuild [[-Build] \u003cVersion[]\u003e] [[-MinimumBuild] \u003cVersion\u003e] [[-MaxBehind] \u003cString\u003e] [-Latest] [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Update] [-Quiet] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaCmConnection", "Description": "Tests over which paths a computer can be managed.\n\nThis function tries out the connectivity for:\n- Cim over WinRM\n- Cim over DCOM\n- Wmi\n- PowerShellRemoting\nResults will be written to the connectivity cache and will cause Get-DbaCmObject and Invoke-DbaCmMethod to connect using the way most likely to succeed. This way, it is likely the other commands will take less time to execute. These others too cache their results, in order to dynamically update connection statistics.\n\nThis function ignores global configuration settings limiting which protocols may be used.", "Tags": [ "ComputerManagement", "CIM" ], "Params": [ [ "ComputerName", "The computer to test against.", "", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "The credentials to use when running the test. Bad credentials are automatically cached as non-working. This behavior can be disabled by the \u0027Cache.Management.Disable.BadCredentialList\u0027 configuration.", "", false, "false", "" ], [ "Type", "The connection protocol types to test.\r\nBy default, all types are tested.\nNote that this function will ignore global configurations limiting the types of connections available and test all connections specified here instead.\nAvailable connection protocol types: \"CimRM\", \"CimDCOM\", \"Wmi\", \"PowerShellRemoting\"", "", false, "false", "@(\"CimRM\", \"CimDCOM\", \"Wmi\", \"PowerShellRemoting\")" ], [ "Force", "If this switch is enabled, the Alert will be dropped and recreated on Destination.", "", 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": "Friedrich Weinmann (@FredWeinmann)", "Synopsis": "Tests over which paths a computer can be managed.", "Name": "Test-DbaCmConnection", "Links": "https://dbatools.io/Test-DbaCmConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaCmConnection -ComputerName sql2014\nPerforms a full-spectrum connection test against the computer sql2014. The results will be reported and registered. Future calls from Get-DbaCmObject will recognize the results and optimize the query.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaCmConnection -ComputerName sql2014 -Credential $null -Type CimDCOM, CimRM\nThis test will run a connectivity test of CIM over DCOM and CIM over WinRM against the computer sql2014 using Windows Authentication.\nThe results will be reported and registered. Future calls from Get-DbaCmObject will recognize the results and optimize the query.", "Syntax": "Test-DbaCmConnection [[-ComputerName] \u003cDbaCmConnectionParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Type] {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-Force] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaConnection", "Description": "Tests the ability to connect to an SQL Server instance outputting information about the server and instance.", "Tags": [ "CIM", "Test", "Connection" ], "Params": [ [ "SqlInstance", "The SQL Server Instance to test connection", "ServerInstance,SqlServer", false, "true (ByValue)", "" ], [ "Credential", "Credential object used to connect to the Computer as a different user", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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": "Test-SqlConnection", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tests the connection to a single instance.", "Name": "Test-DbaConnection", "Links": "https://dbatools.io/Test-DbaConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaConnection SQL2016\n```\r\nComputerName : SQL2016\r\nInstanceName : MSSQLSERVER\r\nSqlInstance : sql2016\r\nSqlVersion : 13.0.4001\r\nConnectingAsUser : BASE\\ctrlb\r\nConnectSuccess : True\r\nAuthType : Windows Authentication\r\nAuthScheme : KERBEROS\r\nTcpPort : 1433\r\nIPAddress : 10.2.1.5\r\nNetBiosName : sql2016.base.local\r\nIsPingable : True\r\nPSRemotingAccessible : True\r\nDomainName : base.local\r\nLocalWindows : 10.0.15063.0\r\nLocalPowerShell : 5.1.15063.502\r\nLocalCLR : 4.0.30319.42000\r\nLocalSMOVersion : 13.0.0.0\r\nLocalDomainUser : True\r\nLocalRunAsAdmin : False\r\n```\nTest connection to SQL2016 and outputs information collected", "Syntax": "Test-DbaConnection [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaConnectionAuthScheme", "Description": "By default, this command will return the ConnectName, ServerName, Transport and AuthScheme of the current connection.\n\nConnectName is the name you used to connect. ServerName is the name that the SQL Server reports as its @@SERVERNAME which is used to register its SPN. If you were expecting a Kerberos connection and got NTLM instead, ensure ConnectName and ServerName match.\n\nIf -Kerberos or -Ntlm is specified, the $true/$false results of the test will be returned. Returns $true or $false by default for one server. Returns Server name and Results for more than one server.", "Tags": [ "SPN", "Kerberos" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Server(s) must be SQL Server 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)", "Credential,Cred", false, "false", "" ], [ "Kerberos", "If this switch is enabled, checks will be made for Kerberos authentication.", "", false, "false", "False" ], [ "Ntlm", "If this switch is enabled, checks will be made for NTLM authentication.", "", false, "false", "False" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns the transport protocol and authentication scheme of the connection. This is useful to determine if your connection is using Kerberos.", "Name": "Test-DbaConnectionAuthScheme", "Links": "https://dbatools.io/Test-DbaConnectionAuthScheme", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaConnectionAuthScheme -SqlInstance sqlserver2014a, sql2016\nReturns ConnectName, ServerName, Transport and AuthScheme for sqlserver2014a and sql2016.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaConnectionAuthScheme -SqlInstance sqlserver2014a -Kerberos\nReturns $true or $false depending on if the connection is Kerberos or not.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaConnectionAuthScheme -SqlInstance sqlserver2014a | Select-Object *\nReturns the results of \"SELECT * from sys.dm_exec_connections WHERE session_id = @@SPID\"", "Syntax": "Test-DbaConnectionAuthScheme [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Kerberos] [-Ntlm] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbCollation", "Description": "Compares Database Collations to Server Collation", "Tags": [ "Database", "Collation" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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)", "Credential", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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": "Test-DbaDatabaseCollation", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Compares Database Collations to Server Collation", "Name": "Test-DbaDbCollation", "Links": "https://dbatools.io/Test-DbaDbCollation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbCollation -SqlInstance sqlserver2014a\nReturns server name, database name and true/false if the collations match for all databases on sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbCollation -SqlInstance sqlserver2014a -Database db1, db2\nReturns information for the db1 and db2 databases on sqlserver2014a.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDbCollation -SqlInstance sqlserver2014a, sql2016 -Exclude db1\nReturns information for database and server collations for all databases except db1 on sqlserver2014a and sql2016.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2016 | Test-DbaDbCollation\nReturns db/server collation information for every database on every server listed in the Central Management Server on sql2016.", "Syntax": "Test-DbaDbCollation [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbCompatibility", "Description": "Compares Database Compatibility level to Server Compatibility", "Tags": [ "Database", "Compatibility" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Credential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Detailed", "Will be deprecated in 1.0.0 release.", "", 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": "Test-DbaDatabaseCompatibility", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Compares Database Compatibility level to Server Compatibility", "Name": "Test-DbaDbCompatibility", "Links": "https://dbatools.io/Test-DbaDbCompatibility", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbCompatibility -SqlInstance sqlserver2014a\nReturns server name, database name and true/false if the compatibility level match for all databases on sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbCompatibility -SqlInstance sqlserver2014a -Database db1, db2\nReturns detailed information for database and server compatibility level for the db1 and db2 databases on sqlserver2014a.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDbCompatibility -SqlInstance sqlserver2014a, sql2016 -Exclude db1\nReturns detailed information for database and server compatibility level for all databases except db1 on sqlserver2014a and sql2016.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sql2014 | Test-DbaDbCompatibility\nReturns db/server compatibility information for every database on every server listed in the Central Management Server on sql2016.", "Syntax": "Test-DbaDbCompatibility [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbCompression", "Description": "This function returns the results of a full table/index compression analysis and the estimated, best option to date for either NONE, Page, or Row Compression.\n\nRemember Uptime is critical, the longer uptime, the more accurate the analysis is, and it would be best if you utilized Get-DbaUptime first, before running this command.\n\nTest-DbaDbCompression script derived from GitHub and the tigertoolbox\n(https://github.com/Microsoft/tigertoolbox/tree/master/Evaluate-Compression-Gains)\nIn the output, you will find the following information:\n- Column Percent_Update shows the percentage of update operations on a specific table, index, or partition, relative to total operations on that object. The lower the percentage of Updates (that is, the table, index, or partition is infrequently updated), the better candidate it is for page compression.\n- Column Percent_Scan shows the percentage of scan operations on a table, index, or partition, relative to total operations on that object. The higher the value of Scan (that is, the table, index, or partition is mostly scanned), the better candidate it is for page compression.\n- Column Compression_Type_Recommendation can have four possible outputs indicating where there is most gain, if any: \u0027PAGE\u0027, \u0027ROW\u0027, \u0027NO_GAIN\u0027 or \u0027?\u0027. When the output is \u0027?\u0027 this approach could not give a recommendation, so as a rule of thumb I would lean to ROW if the object suffers mainly UPDATES, or PAGE if mainly INSERTS, but this is where knowing your workload is essential. When the output is \u0027NO_GAIN\u0027 well, that means that according to sp_estimate_data_compression_savings no space gains will be attained when compressing, as in the above output example, where compressing would grow the affected object.\n\nThis script will execute on the context of the current database.\nAlso be aware that this may take a while to execute on large objects, because if the IS locks taken by the\nsp_estimate_data_compression_savings cannot be honored, the SP will be blocked.\nIt only considers Row or Page Compression (not column compression)\nIt only evaluates User Tables", "Tags": [ "Compression", "Table", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple 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", "" ], [ "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", "" ], [ "Schema", "Filter to only get specific schemas If unspecified, all schemas will be processed.", "", false, "false", "" ], [ "Table", "Filter to only get specific tables If unspecified, all User tables will be processed.", "", false, "false", "" ], [ "ResultSize", "Allows you to limit the number of results returned, as some systems can have very large number of tables. Default value is no restriction.", "", false, "false", "0" ], [ "Rank", "Allows you to specify the field used for ranking when determining the ResultSize\r\nCan be either TotalPages, UsedPages or TotalRows with default of TotalPages. Only applies when ResultSize is used.", "", false, "false", "TotalPages" ], [ "FilterBy", "Allows you to specify level of filtering when determining the ResultSize\r\nCan be at either Table, Index or Partition level with default of Partition. Only applies when ResultSize is used.", "", false, "false", "Partition" ], [ "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": "Jason Squires (@js_0505), jstexasdba@gmail.com", "Synopsis": "Returns tables and indexes with preferred compression setting.", "Name": "Test-DbaDbCompression", "Links": "https://dbatools.io/Test-DbaDbCompression", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance localhost\nReturns results of all potential compression options for all databases for the default instance on the local host. Returns a recommendation of either Page, Row or NO_GAIN\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA\nReturns results of all potential compression options for all databases on the instance ServerA\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA -Database DBName | Out-GridView\nReturns results of all potential compression options for a single database DBName with the recommendation of either Page or Row or NO_GAIN in a nicely formatted GridView\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Test-DbaDbCompression -SqlInstance ServerA -ExcludeDatabase MyDatabase -SqlCredential $cred\nReturns results of all potential compression options for all databases except MyDatabase on instance ServerA using SQL credentials to authentication to ServerA.\r\nReturns the recommendation of either Page, Row or NO_GAIN\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA -Schema Test -Table MyTable\nReturns results of all potential compression options for the Table Test.MyTable in instance ServerA on ServerA and ServerB.\r\nReturns the recommendation of either Page, Row or NO_GAIN.\r\nReturns a result for each partition of any Heap, Clustered or NonClustered index.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA, ServerB -ResultSize 10\nReturns results of all potential compression options for all databases on ServerA and ServerB.\r\nReturns the recommendation of either Page, Row or NO_GAIN.\r\nReturns results for the top 10 partitions by TotalPages used per database.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eServerA | Test-DbaDbCompression -Schema Test -ResultSize 10 -Rank UsedPages -FilterBy Table\nReturns results of all potential compression options for all databases on ServerA containing a schema Test\r\nReturns results for the top 10 Tables by Used Pages per database.\r\nResults are split by Table, Index and Partition so more than 10 results may be returned.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003e$servers = \u0027Server1\u0027,\u0027Server2\u0027\nPS C:\\\u003e $servers | Test-DbaDbCompression -Database DBName | Out-GridView\nReturns results of all potential compression options for a single database DBName on Server1 or Server2\r\nReturns the recommendation of either Page, Row or NO_GAIN in a nicely formatted GridView\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003e$cred = Get-Credential sqladmin\nPS C:\\\u003e Test-DbaDbCompression -SqlInstance ServerA -Database MyDB -SqlCredential $cred -Schema Test -Table Test1, Test2\nReturns results of all potential compression options for objects in Database MyDb on instance ServerA using SQL credentials to authentication to ServerA.\r\nReturns the recommendation of either Page, Row or NO_GAIN for tables with SchemA Test and name in Test1 or Test2\n-------------------------- EXAMPLE 10 --------------------------\nPS C:\\\u003e$servers = \u0027Server1\u0027,\u0027Server2\u0027\nPS C:\\\u003e foreach ($svr in $servers) {\r\n\u003e\u003e Test-DbaDbCompression -SqlInstance $svr | Export-Csv -Path C:\\temp\\CompressionAnalysisPAC.csv -Append\r\n\u003e\u003e }\nThis produces a full analysis of all your servers listed and is pushed to a csv for you to analyze.", "Syntax": "Test-DbaDbCompression [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Schema] \u003cString[]\u003e] [[-Table] \u003cString[]\u003e] [[-ResultSize] \u003cInt32\u003e] [[-Rank] \u003cString\u003e] [[-FilterBy] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbLogShipStatus", "Description": "Most of the time your log shipping \"just works\".\nChecking your log shipping status can be done really easy with this function.\n\nMake sure you\u0027re connecting to the monitoring instance of your log shipping infrastructure.\n\nThe function will return the status for a database. This can be one or more messages in a comma separated list.\nIf everything is OK with the database than you should only see the message \"All OK\".", "Tags": "LogShipping", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.", "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", "" ], [ "Database", "Allows you to filter the results to only return the databases you\u0027re interested in. This can be one or more values separated by commas.\r\nThis is not a wildcard and should be the exact database name. See examples for more info.", "", false, "false", "" ], [ "ExcludeDatabase", "Allows you to filter the results to only return the databases you\u0027re not interested in. This can be one or more values separated by commas.\r\nThis is not a wildcard and should be the exact database name.", "", false, "false", "" ], [ "Simple", "By default all the information will be returned.\r\nIf this parameter is used you get an overview with the SQL Instance, Database, Instance Type and the status", "", false, "false", "False" ], [ "Primary", "Allows to filter the results to only return values that apply to the primary instance.", "", false, "false", "False" ], [ "Secondary", "Allows to filter the results to only return values that apply to the secondary instance.", "", 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": "Test-DbaLogShippingStatus", "Author": "Sander Stad (@sqlstad), sqlstad.nl", "Synopsis": "Test-DbaDbLogShipStatus returns the status of your log shipping databases", "Name": "Test-DbaDbLogShipStatus", "Links": "https://dbatools.io/Test-DbaDbLogShipStatus", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbLogShipStatus -SqlInstance sql1\nRetrieves the log ship information from sql1 and displays all the information present including the status.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbLogShipStatus -SqlInstance sql1 -Database AdventureWorks2014\nRetrieves the log ship information for just the database AdventureWorks.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDbLogShipStatus -SqlInstance sql1 -Primary\nRetrieves the log ship information and only returns the information for the databases on the primary instance.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaDbLogShipStatus -SqlInstance sql1 -Secondary\nRetrieves the log ship information and only returns the information for the databases on the secondary instance.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eTest-DbaDbLogShipStatus -SqlInstance sql1 -Simple\nRetrieves the log ship information and only returns the columns SQL Instance, Database, Instance Type and Status", "Syntax": "Test-DbaDbLogShipStatus [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [-Simple] [-Primary] [-Secondary] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbOwner", "Description": "This function will check all databases on an instance against a SQL login to validate if that\nlogin owns those databases or not. By default, the function will check against \u0027sa\u0027 for\nownership, but the user can pass a specific login if they use something else.\n\nBest Practice reference: http://weblogs.sqlteam.com/dang/archive/2008/01/13/Database-Owner-Troubles.aspx", "Tags": [ "Database", "Owner", "DbOwner" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "TargetLogin", "Specifies the login that you wish check for ownership. This defaults to \u0027sa\u0027 or the sysadmin name if sa was renamed. This must be a valid security principal which exists on the target server.", "", false, "false", "" ], [ "Detailed", "Will be deprecated in 1.0.0 release.", "", 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": "Test-DbaDatabaseOwner", "Author": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Checks database owners against a login to validate which databases do not match that owner.", "Name": "Test-DbaDbOwner", "Links": "https://dbatools.io/Test-DbaDbOwner", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbOwner -SqlInstance localhost\nReturns all databases where the owner does not match \u0027sa\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbOwner -SqlInstance localhost -TargetLogin \u0027DOMAIN\\account\u0027\nReturns all databases where the owner does not match \u0027DOMAIN\\account\u0027.", "Syntax": "Test-DbaDbOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-TargetLogin] \u003cString\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbRecoveryModel", "Description": "When you switch a database into FULL recovery model, it will behave like a SIMPLE recovery model until a full backup is taken in order to begin a log backup chain.\n\nHowever, you may also desire to validate if a database is SIMPLE or BULK LOGGED on an instance.\n\nInspired by Paul Randal\u0027s post (http://www.sqlskills.com/blogs/paul/new-script-is-that-database-really-in-the-full-recovery-mode/)", "Tags": [ "DisasterRecovery", "Backup" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "RecoveryModel", "Specifies the type of recovery model you wish to test. By default it will test for FULL Recovery Model.", "", false, "false", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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": "Test-DbaFullRecoveryModel,Test-DbaRecoveryModel", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Find if database is really a specific recovery model or not.", "Name": "Test-DbaDbRecoveryModel", "Links": "https://dbatools.io/Test-DbaDbRecoveryModel", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbRecoveryModel -SqlInstance sql2005\nShows all databases where the configured recovery model is FULL and indicates whether or not they are really in FULL recovery model.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbRecoveryModel -SqlInstance . | Where-Object {$_.ActualRecoveryModel -ne \"FULL\"}\nOnly shows the databases that are functionally in \u0027simple\u0027 mode.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDbRecoveryModel -SqlInstance sql2008 -RecoveryModel Bulk_Logged | Sort-Object Server -Descending\nShows all databases where the configured recovery model is BULK_LOGGED and sort them by server name descending\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaDbRecoveryModel -SqlInstance localhost | Select-Object -Property *\nShows all of the properties for the databases that have Full Recovery Model", "Syntax": "Test-DbaDbRecoveryModel [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-RecoveryModel] \u003cObject\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDbVirtualLogFile", "Description": "Having a transaction log file with too many virtual log files (VLFs) can hurt database performance.\n\nToo many VLFs can cause transaction log backups to slow down and can also slow down database recovery and, in extreme cases, even affect insert/update/delete performance.\n\nReferences:\nhttp://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\nhttp://blogs.msdn.com/b/saponsqlserver/archive/2012/02/22/too-many-virtual-log-files-vlfs-can-cause-slow-database-recovery.aspx\n\nIf you\u0027ve got a high number of VLFs, you can use Expand-SqlTLogResponsibly to reduce the number.", "Tags": [ "VLF", "Database" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Database", "Specifies 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", "" ], [ "ExcludeDatabase", "Specifies the database(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "IncludeSystemDBs", "If this switch is enabled, system database information will be displayed.", "", 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": "Test-DbaVirtualLogFile", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns calculations on the database virtual log files for database on a SQL instance.", "Name": "Test-DbaDbVirtualLogFile", "Links": "https://dbatools.io/Test-DbaDbVirtualLogFile", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDbVirtualLogFile -SqlInstance sqlcluster\nReturns all user database virtual log file counts for the sqlcluster instance.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDbVirtualLogFile -SqlInstance sqlserver | Where-Object {$_.Count -ge 50}\nReturns user databases that have 50 or more VLFs.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e@(\u0027sqlserver\u0027,\u0027sqlcluster\u0027) | Test-DbaDbVirtualLogFile\nReturns all VLF information for the sqlserver and sqlcluster SQL Server instances. Processes data via the pipeline.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaDbVirtualLogFile -SqlInstance sqlcluster -Database db1, db2\nReturns VLF counts for the db1 and db2 databases on sqlcluster.", "Syntax": "Test-DbaDbVirtualLogFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDeprecatedFeature", "Description": "Displays information relating to deprecated features for SQL Server 2005 and above.", "Tags": "Deprecated", "Params": [ [ "SqlInstance", "The target SQL Server instance", "ServerInstance,SqlServer,SqlServers", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternate Windows or SQL Login Authentication. Accepts credential objects (Get-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", "" ], [ "InputObject", "A collection of databases (such as returned by Get-DbaDatabase), to be tested.", "", 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": "Displays information relating to deprecated features for SQL Server 2005 and above.", "Name": "Test-DbaDeprecatedFeature", "Links": "https://dbatools.io/Test-DbaDeprecatedFeature", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2008 -Database testdb, db2 | Test-DbaDeprecatedFeature\nCheck deprecated features on server sql2008 for only the testdb and db2 databases\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2008 -Database testdb, db2 | Test-DbaDeprecatedFeature | Select *\nSee the object definition in the output as well\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDeprecatedFeature -SqlInstance sql2008, sqlserver2012\nCheck deprecated features for all databases on the servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaDeprecatedFeature -SqlInstance sql2008 -Database TestDB\nCheck deprecated features on server sql2008 for only the TestDB database", "Syntax": "Test-DbaDeprecatedFeature [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDiskAlignment", "Description": "Returns $true or $false by default for one server. Returns Server name and IsBestPractice for more than one server.\n\nPlease refer to your storage vendor best practices before following any advice below.\n\nBy default issues with disk alignment should be resolved by a new installation of Windows Server 2008, Windows Vista, or later operating systems, but verifying disk alignment continues to be recommended as a best practice.\nWhile some versions of Windows use different starting alignments, if you are starting anew 1MB is generally the best practice offset for current operating systems (because it ensures that the partition offset % common stripe unit sizes == 0 )\n\nCaveats:\n* Dynamic drives (or those provisioned via third party software) may or may not have accurate results when polled by any of the built in tools, see your vendor for details.\n* Windows does not have a reliable way to determine stripe unit Sizes. These values are obtained from vendor disk management software or from your SAN administrator.\n* System drives in versions previous to Windows Server 2008 cannot be aligned, but it is generally not recommended to place SQL Server databases on system drives.", "Tags": "Storage", "Params": [ [ "ComputerName", "The server(s) to check disk configuration on.", "ServerInstance,SqlServer,SqlInstance", true, "true (ByValue)", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", false, "false", "False" ], [ "Credential", "Specifies an alternate Windows account to use when enumerating drives on the server. May require Administrator privileges. To use:\n$cred = Get-Credential, then pass $cred object to the -Credential parameter.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "NoSqlCheck", "If this switch is enabled, the disk(s) will not be checked for SQL Server data or log 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": "Constantine Kokkinos (@mobileck), https://constantinekokkinos.com", "Synopsis": "Verifies that your non-dynamic disks are aligned according to physical constraints.", "Name": "Test-DbaDiskAlignment", "Links": "https://dbatools.io/Test-DbaDiskAlignment", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDiskAlignment -ComputerName sqlserver2014a\nTests the disk alignment of a single server named sqlserver2014a\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDiskAlignment -ComputerName sqlserver2014a, sqlserver2014b, sqlserver2014c\nTests the disk alignment of multiple servers", "Syntax": "Test-DbaDiskAlignment [-ComputerName] \u003cObject[]\u003e [-Detailed] [[-Credential] \u003cPSCredential\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-NoSqlCheck] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDiskAllocation", "Description": "Checks all disks on a computer for disk allocation units that match best practice recommendations. If one server is checked, only $true or $false is returned. If multiple servers are checked, each server\u0027s name and an IsBestPractice field are returned.\n\nReferences:\nhttps://technet.microsoft.com/en-us/library/dd758814(v=sql.100).aspx - \"The performance question here is usually not one of correlation per the formula, but whether the cluster size has been explicitly defined at 64 KB, which is a best practice for SQL Server.\"", "Tags": [ "CIM", "Storage" ], "Params": [ [ "ComputerName", "The server(s) to check disk configuration on.", "ServerInstance,SqlServer,SqlInstance", true, "true (ByValue)", "" ], [ "NoSqlCheck", "If this switch is enabled, the disk(s) will not be checked for SQL Server data or log files.", "", false, "false", "False" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Credential", "Specifies an alternate Windows account to use when enumerating drives on the server. May require Administrator privileges. To use:\n$cred = Get-Credential, then pass $cred object to the -Credential parameter.", "", false, "false", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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", "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": "Test-SqlDiskAllocation", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Checks all disks on a computer to see if they are formatted with allocation units of 64KB.", "Name": "Test-DbaDiskAllocation", "Links": "https://dbatools.io/Test-DbaDiskAllocation", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDiskAllocation -ComputerName sqlserver2014a\nScans all disks on server sqlserver2014a for best practice allocation unit size.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDiskAllocation -ComputerName sqlserver2014 | Select-Output *\nScans all disks on server sqlserver2014a for allocation unit size and returns detailed results for each.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaDiskAllocation -ComputerName sqlserver2014a -NoSqlCheck\nScans all disks not hosting SQL Server data or log files on server sqlserver2014a for best practice allocation unit size.", "Syntax": "Test-DbaDiskAllocation [-ComputerName] \u003cObject[]\u003e [-NoSqlCheck] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-Detailed] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaDiskSpeed", "Description": "Tests how disks are performing.\n\nThis command uses a query from Rich Benner which was adapted from David Pless\u0027s article:\nhttps://blogs.msdn.microsoft.com/dpless/2010/12/01/leveraging-sys-dm_io_virtual_file_stats/\nhttps://github.com/RichBenner/PersonalCode/blob/master/Disk_Speed_Check.sql", "Tags": "Performance", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Allows you to login to the SQL Server using alternative credentials.", "", 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", "" ], [ "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": "Tests how disks are performing.", "Name": "Test-DbaDiskSpeed", "Links": "https://dbatools.io/Test-DbaDiskSpeed", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaDiskSpeed -SqlInstance sql2008, sqlserver2012\nTests how disks are performing on sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaDiskSpeed -SqlInstance sql2008 -Database tempdb\nTests how disks storing tempdb files on sql2008 are performing.", "Syntax": "Test-DbaDiskSpeed [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaEndpoint", "Description": "Performs a simple connectivity test for TCP and SSL enabled endpoints. Tests if port is accessible, not if endpoint is working.\n\nNote that if an endpoint does not have a tcp listener port, it will be skipped.", "Tags": "Endpoint", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Endpoint", "Test only specific endpoint or endpoints.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaEndpoint.", "", 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": "Performs a simple connectivity test for TCP and SSL enabled endpoints.", "Name": "Test-DbaEndpoint", "Links": "https://dbatools.io/Test-DbaEndpoint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaEndpoint -SqlInstance localhost\nTests all endpoints on the local default SQL Server instance.\nNote that if an endpoint does not have a tcp listener port, it will be skipped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance localhost, sql2016 -Endpoint Mirror | Test-DbaEndpoint\nTests all endpoints named Mirroring on sql2016 and localhost.\nNote that if an endpoint does not have a tcp listener port, it will be skipped.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaEndpoint -SqlInstance localhost, sql2016 -Endpoint Mirror\nTests all endpoints named Mirroring on sql2016 and localhost.\nNote that if an endpoint does not have a tcp listener port, it will be skipped.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaEndpoint -SqlInstance localhost -Verbose\nTests all endpoints on the local default SQL Server instance.\nSee all endpoints that were skipped due to not having a tcp listener port.", "Syntax": "Test-DbaEndpoint [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Endpoint] \u003cString[]\u003e] [[-InputObject] \u003cEndpoint[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaIdentityUsage", "Description": "IDENTITY seeds have max values based off of their data type. This module will locate identity columns and report the seed usage.", "Tags": [ "Identity", "Table", "Column" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-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", "" ], [ "Threshold", "Allows you to specify a minimum % of the seed range being utilized. This can be used to ignore seeds that have only utilized a small fraction of the range.", "", false, "false", "0" ], [ "ExcludeSystemDb", "Allows you to suppress output on system databases", "NoSystemDb", 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": "Brandon Abshire, netnerds.net", "Synopsis": "Displays information relating to IDENTITY seed usage. Works on SQL Server 2008 and above.", "Name": "Test-DbaIdentityUsage", "Links": "https://dbatools.io/Test-DbaIdentityUsage", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaIdentityUsage -SqlInstance sql2008, sqlserver2012\nCheck identity seeds for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaIdentityUsage -SqlInstance sql2008 -Database TestDB\nCheck identity seeds on server sql2008 for only the TestDB database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaIdentityUsage -SqlInstance sql2008 -Database TestDB -Threshold 20\nCheck identity seeds on server sql2008 for only the TestDB database, limiting results to 20% utilization of seed range or higher", "Syntax": "Test-DbaIdentityUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [[-Threshold] \u003cInt32\u003e] [[-ExcludeSystemDb]] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaJobOwner", "Description": "This function checks all SQL Agent Jobs on an instance against a SQL login to validate if that login owns those SQL Agent Jobs or not. By default, the function checks against \u0027sa\u0027 for ownership, but the user can pass a specific login if they use something else.\n\nOnly SQL Agent Jobs that do not match this ownership will be displayed.\nBest practice reference: http://sqlmag.com/blog/sql-server-tip-assign-ownership-jobs-sysadmin-account", "Tags": [ "Agent", "Job", "Owner" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Job", "Specifies the job(s) to process. Options for this list are auto-populated from the server. If unspecified, all jobs will be processed.", "Jobs", false, "false", "" ], [ "ExcludeJob", "Specifies the job(s) to exclude from processing. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "Login", "Specifies the login that you wish check for ownership. This defaults to \u0027sa\u0027 or the sysadmin name if sa was renamed. This must be a valid security principal which exists on the target server.", "TargetLogin", false, "false", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Checks SQL Agent Job owners against a login to validate which jobs do not match that owner.", "Name": "Test-DbaJobOwner", "Links": "https://dbatools.io/Test-DbaJobOwner", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaJobOwner -SqlInstance localhost\nReturns all SQL Agent Jobs where the owner does not match \u0027sa\u0027.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaJobOwner -SqlInstance localhost -ExcludeJob \u0027syspolicy_purge_history\u0027\nReturns SQL Agent Jobs except for the syspolicy_purge_history job\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaJobOwner -SqlInstance localhost -Login DOMAIN\\account\nReturns all SQL Agent Jobs where the owner does not match DOMAIN\\account. Note\r\nthat Login must be a valid security principal that exists on the target server.", "Syntax": "Test-DbaJobOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [[-ExcludeJob] \u003cObject[]\u003e] [[-Login] \u003cString\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaLastBackup", "Description": "Restores all or some of the latest backups and performs a DBCC CHECKDB.\n\n1. Gathers information about the last full backups\n2. Restores the backups to the Destination with a new name. If no Destination is specified, the originating SQL Server instance wil be used.\n3. The database is restored as \"dbatools-testrestore-$databaseName\" by default, but you can change dbatools-testrestore to whatever you would like using -Prefix\n4. The internal file names are also renamed to prevent conflicts with original database\n5. A DBCC CHECKDB is then performed\n6. And the test database is finally dropped", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. Unlike many of the other commands, you cannot specify more than one server.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "The database backups to test. If -Database is not provided, all database backups will be tested.", "", false, "false", "" ], [ "ExcludeDatabase", "Exclude specific Database backups to test.", "", false, "false", "" ], [ "Destination", "The destination server to use to test the restore. By default, the Destination will be set to the source server\nIf a different Destination server is specified, you must ensure that the database backups are on a shared location", "", false, "false", "" ], [ "DestinationCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "DataDirectory", "Specifies an alternative directory for mdfs, ndfs and so on. The command uses the SQL Server\u0027s default data directory for all restores.", "", false, "false", "" ], [ "LogDirectory", "Specifies an alternative directory for ldfs. The command uses the SQL Server\u0027s default log directory for all restores.", "", false, "false", "" ], [ "Prefix", "The database is restored as \"dbatools-testrestore-$databaseName\" by default. You can change dbatools-testrestore to whatever you would like using this parameter.", "", false, "false", "dbatools-testrestore-" ], [ "VerifyOnly", "If this switch is enabled, VERIFYONLY will be performed. An actual restore will not be executed.", "", false, "false", "False" ], [ "NoCheck", "If this switch is enabled, DBCC CHECKDB will be skipped", "", false, "false", "False" ], [ "NoDrop", "If this switch is enabled, the newly-created test database will not be dropped.", "", false, "false", "False" ], [ "CopyFile", "If this switch is enabled, the backup file will be copied to the destination default backup location unless CopyPath is specified.", "", false, "false", "False" ], [ "CopyPath", "Specifies a path relative to the SQL Server to copy backups when CopyFile is specified. If not specified will use destination default backup location. If destination SQL Server is not local, admin \r\nUNC paths will be utilized for the copy.", "", false, "false", "" ], [ "MaxSize", "Max size in MB. Databases larger than this value will not be restored.", "MaxMB", false, "false", "0" ], [ "IncludeCopyOnly", "If this switch is enabled, copy only backups will not be counted as a last backup.", "", false, "false", "False" ], [ "IgnoreLogBackup", "If this switch is enabled, transaction log backups will be ignored. The restore will stop at the latest full or differential backup point.", "", false, "false", "False" ], [ "AzureCredential", "The name of the SQL Server credential on the destination instance that holds the key to the azure storage account.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaDatabase", "", 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" ], [ "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Quickly and easily tests the last set of full backups for a server.", "Name": "Test-DbaLastBackup", "Links": "https://dbatools.io/Test-DbaLastBackup", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016\nDetermines the last full backup for ALL databases, attempts to restore all databases (with a different name and file structure), then performs a DBCC CHECKDB. Once the test is complete, the test \r\nrestore will be dropped.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -Database SharePoint_Config\nDetermines the last full backup for SharePoint_Config, attempts to restore it, then performs a DBCC CHECKDB.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016, sql2017 | Test-DbaLastBackup\nTests every database backup on sql2016 and sql2017\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016, sql2017 -Database SharePoint_Config | Test-DbaLastBackup\nTests the database backup for the SharePoint_Config database on sql2016 and sql2017\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -Database model, master -VerifyOnly\nSkips performing an action restore of the database and simply verifies the backup using VERIFYONLY option of the restore.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -NoCheck -NoDrop\nSkips the DBCC CHECKDB check. This can help speed up the tests but makes it less tested. The test restores will remain on the server.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -DataDirectory E:\\bigdrive -LogDirectory L:\\bigdrive -MaxSize 10240\nRestores data and log files to alternative locations and only restores databases that are smaller than 10 GB.\n-------------------------- EXAMPLE 8 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2014 -Destination sql2016 -CopyFile\nCopies the backup files for sql2014 databases to sql2016 default backup locations and then attempts restore from there.\n-------------------------- EXAMPLE 9 --------------------------\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2014 -Destination sql2016 -CopyFile -CopyPath \"\\\\BackupShare\\TestRestore\\\"\nCopies the backup files for sql2014 databases to sql2016 default backup locations and then attempts restore from there.", "Syntax": "Test-DbaLastBackup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Destination] \u003cDbaInstanceParameter\u003e] [[-DestinationCredential] \u003cObject\u003e] [[-DataDirectory] \u003cString\u003e] [[-LogDirectory] \u003cString\u003e] [[-Prefix] \u003cString\u003e] [-VerifyOnly] [-NoCheck] [-NoDrop] [-CopyFile] [[-CopyPath] \u003cString\u003e] [[-MaxSize] \u003cInt32\u003e] [-IncludeCopyOnly] [-IgnoreLogBackup] [[-AzureCredential] \u003cString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaLinkedServerConnection", "Description": "Test each linked server on the instance", "Tags": "LinkedServer", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "true (ByValue)", "" ], [ "SqlCredential", "Credential object used to connect to the SQL Server as a different user", "", false, "false", "" ], [ "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.\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": "Thomas LaRock ( https://thomaslarock.com )", "Synopsis": "Test all linked servers from the sql servers passed", "Name": "Test-DbaLinkedServerConnection", "Links": "https://dbatools.io/Test-DbaLinkedServerConnection", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaLinkedServerConnection -SqlInstance DEV01\nTest all Linked Servers for the SQL Server instance DEV01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaLinkedServerConnection -SqlInstance sql2016 | Out-File C:\\temp\\results.txt\nTest all Linked Servers for the SQL Server instance sql2016 and output results to file\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaLinkedServerConnection -SqlInstance sql2016, sql2014, sql2012\nTest all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$servers = \"sql2016\",\"sql2014\",\"sql2012\"\nPS C:\\\u003e $servers | Test-DbaLinkedServerConnection -SqlCredential sqladmin\nTest all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012 using SQL login credentials\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers | Get-DbaLinkedServer | Test-DbaLinkedServerConnection\nTest all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012", "Syntax": "Test-DbaLinkedServerConnection [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaLoginPassword", "Description": "The purpose of this function is to find SQL Server logins that have no password or the same password as login. You can add your own password to check for or add them to a csv file.\nBy default it will test for empty password and the same password as username.", "Tags": [ "Login", "Security" ], "Params": [ [ "SqlInstance", "The SQL Server instance you\u0027re checking logins on. You must have sysadmin access and server version must be SQL Server version 2008 or higher.", "ServerInstance,SqlServer,SqlServers", false, "false", "" ], [ "SqlCredential", "Allows you to login to servers using SQL Logins instead of Windows Authentication (AKA Integrated or Trusted). To use:\n$scred = Get-Credential, then pass $scred object to the -SqlCredential parameter.\nWindows Authentication will be used if SqlCredential is not specified. SQL Server does not accept Windows credentials being passed as credentials.\nTo connect as a different Windows user, run PowerShell as that user.", "", false, "false", "" ], [ "Login", "The login(s) to process.", "", false, "false", "" ], [ "Dictionary", "Specifies a list of passwords to include in the test for weak passwords.", "", false, "false", "" ], [ "InputObject", "Allows piping from Get-DbaLogin.", "", 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": "Peter Samuelsson", "Synopsis": "Test-DbaLoginPassword finds any logins on SQL instance that are SQL Logins and have a password that is either null or same as the login", "Name": "Test-DbaLoginPassword", "Links": "https://dbatools.io/Test-DbaLoginPassword", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaLoginPassword -SqlInstance Dev01\nTest all SQL logins that the password is null or same as username on SQL server instance Dev01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaLoginPassword -SqlInstance Dev01 -Login sqladmin\nTest the \u0027sqladmin\u0027 SQL login that the password is null or same as username on SQL server instance Dev01\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaLoginPassword -SqlInstance Dev01 -Dictionary Test1,test2\nTest all SQL logins that the password is null, same as username or Test1,Test2 on SQL server instance Dev0\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaLogin -SqlInstance \"sql2017\",\"sql2016\" | Test-DbaLoginPassword\nTest all logins on sql2017 and sql2016\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$servers | Get-DbaLogin | Out-GridView -PassThru | Test-DbaLoginPassword\nTest selected logins on all servers in the $servers variable", "Syntax": "Test-DbaLoginPassword [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] [[-Dictionary] \u003cString[]\u003e] [[-InputObject] \u003cLogin[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaManagementObject", "Description": "The Test-DbaManagementObject returns True if the Version is on the computer, and False if it does not exist.", "Tags": "SMO", "Params": [ [ "ComputerName", "The name of the target you would like to check", "ServerInstance,SqlServer,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "This command uses Windows credentials. This parameter allows you to connect remotely as a different user.", "", false, "false", "" ], [ "VersionNumber", "This is the specific version number you are looking for and the return will be True.", "", 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.", "Silent", false, "false", "False" ] ], "Alias": "Test-DbaSqlManagementObject", "Author": "Ben Miller (@DBAduck), http://dbaduck.com", "Synopsis": "Tests to see if the SMO version specified exists on the computer.", "Name": "Test-DbaManagementObject", "Links": "https://dbatools.io/Test-DbaManagementObject", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaManagementObject -VersionNumber 13\nReturns True if the version exists, if it does not exist it will return False", "Syntax": "Test-DbaManagementObject [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-VersionNumber] \u003cInt32[]\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaMaxDop", "Description": "Inspired by Sakthivel Chidambaram\u0027s post about SQL Server MAXDOP Calculator (https://blogs.msdn.microsoft.com/sqlsakthi/p/maxdop-calculator-SqlInstance/),\nthis script displays a SQL Server\u0027s: max dop configured, and the calculated recommendation.\n\nFor SQL Server 2016 shows:\n- Instance max dop configured and the calculated recommendation\n- max dop configured per database (new feature)\n\nMore info:\nhttps://support.microsoft.com/en-us/kb/2806535\nhttps://blogs.msdn.microsoft.com/sqlsakthi/2012/05/23/wow-we-have-maxdop-calculator-for-sql-server-it-makes-my-job-easier/\n\nThese are just general recommendations for SQL Server and are a good starting point for setting the \"max degree of parallelism\" option.", "Tags": [ "MaxDop", "SpConfigure" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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": "Claudio Silva (@claudioessilva)", "Synopsis": "Displays information relating to SQL Server Max Degree of Parallelism setting. Works on SQL Server 2005-2016.", "Name": "Test-DbaMaxDop", "Links": "https://dbatools.io/Test-DbaMaxDop", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sql2008, sqlserver2012\nGet Max DOP setting for servers sql2008 and sqlserver2012 and also the recommended one.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sql2014 | Select-Object *\nShows Max DOP setting for server sql2014 with the recommended value. Piping the output to Select-Object * will also show the \u0027NumaNodes\u0027 and \u0027NumberOfCores\u0027 of each instance\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sqlserver2016 | Select-Object *\nGet Max DOP setting for servers sql2016 with the recommended value. Piping the output to Select-Object * will also show the \u0027NumaNodes\u0027 and \u0027NumberOfCores\u0027 of each instance. Because it is an 2016 \r\ninstance will be shown \u0027InstanceVersion\u0027, \u0027Database\u0027 and \u0027DatabaseMaxDop\u0027 columns.", "Syntax": "Test-DbaMaxDop [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaMaxMemory", "Description": "Inspired by Jonathan Kehayias\u0027s post about SQL Server Max memory (http://bit.ly/sqlmemcalc), this script displays a SQL Server\u0027s: total memory, currently configured SQL max memory, and the calculated recommendation.\n\nJonathan notes that the formula used provides a *general recommendation* that doesn\u0027t account for everything that may be going on in your specific environment.", "Tags": [ "MaxMemory", "Memory" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Windows or Sql Login Credential with permission to log into the SQL instance", "", false, "false", "" ], [ "Credential", "Windows Credential with permission to log on to the server running the SQL instance", "", 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": "Calculates the recommended value for SQL Server \u0027Max Server Memory\u0027 configuration setting. Works on SQL Server 2000-2014.", "Name": "Test-DbaMaxMemory", "Links": "https://dbatools.io/Test-DbaMaxMemory", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaMaxMemory -SqlInstance sqlcluster,sqlserver2012\nCalculate the \u0027Max Server Memory\u0027 for SQL Server instances sqlcluster and sqlserver2012\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlcluster | Test-DbaMaxMemory\nCalculate the \u0027Max Server Memory\u0027 settings for all servers within the SQL Server Central Management Server \"sqlcluster\"\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlcluster | Test-DbaMaxMemory | Where-Object { $_.MaxValue -gt $_.Total } | Set-DbaMaxMemory\nFind all servers in CMS that have Max SQL memory set to higher than the total memory of the server (think 2147483647) and set it to recommended value.", "Syntax": "Test-DbaMaxMemory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaMigrationConstraint", "Description": "When you want to migrate from a higher edition to a lower one there are some features that can\u0027t be used.\nThis function will validate if you have any of this features in use and will report to you.\nThe validation will be made ONLY on on SQL Server 2008 or higher using the \u0027sys.dm_db_persisted_sku_features\u0027 dmv.\n\nThis function only validate SQL Server 2008 versions or higher.\nThe editions supported by this function are:\n- Enterprise\n- Developer\n- Evaluation\n- Standard\n- Express\n\nTake into account the new features introduced on SQL Server 2016 SP1 for all versions. More information at https://blogs.msdn.microsoft.com/sqlreleaseservices/sql-server-2016-service-pack-1-sp1-released/\n\nThe -Database parameter is auto-populated for command-line completion.", "Tags": "Migration", "Params": [ [ "Source", "Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "", true, "true (ByValue)", "" ], [ "SourceSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Destination", "Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2000 or higher.", "", true, "false", "" ], [ "DestinationSqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", 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", "" ], [ "ExcludeDatabase", "The database(s) to exclude. Options for this list are auto-populated from the server.", "", 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": "Test-SqlMigrationConstraint", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Show if you can migrate the database(s) between the servers.", "Name": "Test-DbaMigrationConstraint", "Links": "https://dbatools.io/Test-DbaMigrationConstraint", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaMigrationConstraint -Source sqlserver2014a -Destination sqlcluster\nAll databases on sqlserver2014a will be verified for features in use that can\u0027t be supported on sqlcluster.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaMigrationConstraint -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\nAll databases will be verified for features in use that can\u0027t be supported on the destination server. SQL credentials are used to authenticate against sqlserver2014a and Windows Authentication is \r\nused for sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaMigrationConstraint -Source sqlserver2014a -Destination sqlcluster -Database db1\nOnly db1 database will be verified for features in use that can\u0027t be supported on the destination server.", "Syntax": "Test-DbaMigrationConstraint [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaNetworkLatency", "Description": "This function is intended to help measure SQL Server network latency by establishing a connection and executing a simple query. This is a better than a simple ping because it actually creates the connection to the SQL Server and measures the time required for only the entire routine, but the duration of the query as well how long it takes for the results to be returned.\n\nBy default, this command will execute \"SELECT TOP 100 * FROM INFORMATION_SCHEMA.TABLES\" three times. It will then output how long the entire connection and command took, as well as how long *only* the execution of the command took.\n\nThis allows you to see if the issue is with the connection or the SQL Server itself.", "Tags": [ "Performance", "Network" ], "Params": [ [ "SqlInstance", "The SQL Server you want to run the test on.", "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", "" ], [ "Query", "Specifies the query to be executed. By default, \"SELECT TOP 100 * FROM INFORMATION_SCHEMA.TABLES\" will be executed on master. To execute in other databases, use fully qualified object names.", "", false, "false", "select top 100 * from INFORMATION_SCHEMA.TABLES" ], [ "Count", "Specifies how many times the query should be executed. By default, the query is executed three times.", "", false, "false", "3" ], [ "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": "Test-SqlNetworkLatency", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tests how long a query takes to return from SQL Server", "Name": "Test-DbaNetworkLatency", "Links": "https://dbatools.io/Test-DbaNetworkLatency", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaNetworkLatency -SqlInstance sqlserver2014a, sqlcluster\nTests the round trip return of \"SELECT TOP 100 * FROM INFORMATION_SCHEMA.TABLES\" on sqlserver2014a and sqlcluster using Windows credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaNetworkLatency -SqlInstance sqlserver2014a -SqlCredential $cred\nTests the execution results return of \"SELECT TOP 100 * FROM INFORMATION_SCHEMA.TABLES\" on sqlserver2014a using SQL credentials.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaNetworkLatency -SqlInstance sqlserver2014a, sqlcluster, sqlserver -Query \"select top 10 * from otherdb.dbo.table\" -Count 10\nTests the execution results return of \"select top 10 * from otherdb.dbo.table\" 10 times on sqlserver2014a, sqlcluster, and sqlserver using Windows credentials.", "Syntax": "Test-DbaNetworkLatency [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Query] \u003cString\u003e] [[-Count] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaOptimizeForAdHoc", "Description": "When this option is set, plan cache size is further reduced for single-use ad hoc OLTP workload.\n\nMore info: https://msdn.microsoft.com/en-us/library/cc645587.aspx\nhttp://www.sqlservercentral.com/blogs/glennberry/2011/02/25/some-suggested-sql-server-2008-r2-instance-configuration-settings/\n\nThese are just general recommendations for SQL Server and are a good starting point for setting the \"optimize for ad-hoc workloads\" option.", "Tags": [ "Configure", "SPConfigure" ], "Params": [ [ "SqlInstance", "A collection of one or more SQL Server instance names to query.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "EnableException", "By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with \"sea of red\" exceptions, but is inconvenient because \r\nit basically disables advanced scripting. Using 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": "Brandon Abshire, netnerds.net", "Synopsis": "Displays information relating to SQL Server Optimize for AdHoc Workloads setting. Works on SQL Server 2008-2016.", "Name": "Test-DbaOptimizeForAdHoc", "Links": "https://dbatools.io/Test-DbaOptimizeForAdHoc", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaOptimizeForAdHoc -SqlInstance sql2008, sqlserver2012\nValidates whether Optimize for AdHoc Workloads setting is enabled for servers sql2008 and sqlserver2012.", "Syntax": "Test-DbaOptimizeForAdHoc [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaPath", "Description": "Uses master.dbo.xp_fileexist to determine if a file or directory exists.", "Tags": [ "Path", "ServiceAccount" ], "Params": [ [ "SqlInstance", "The SQL Server you want to run the test on.", "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", "The Path to test. This can be a file or directory", "", 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.", "Silent", false, "false", "False" ] ], "Alias": "Test-DbaSqlPath,Test-SqlPath", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tests if file or directory exists from the perspective of the SQL Server service account.", "Name": "Test-DbaPath", "Links": "https://dbatools.io/Test-DbaPath", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaPath -SqlInstance sqlcluster -Path L:\\MSAS12.MSSQLSERVER\\OLAP\nTests whether the service account running the \"sqlcluster\" SQL Server instance can access L:\\MSAS12.MSSQLSERVER\\OLAP. Logs into sqlcluster using Windows credentials.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$credential = Get-Credential\nPS C:\\\u003e Test-DbaPath -SqlInstance sqlcluster -SqlCredential $credential -Path L:\\MSAS12.MSSQLSERVER\\OLAP\nTests whether the service account running the \"sqlcluster\" SQL Server instance can access L:\\MSAS12.MSSQLSERVER\\OLAP. Logs into sqlcluster using SQL authentication.", "Syntax": "Test-DbaPath [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cObject\u003e [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaPowerPlan", "Description": "Checks the Power Plan settings on a computer against best practices recommendations. If one server is checked, only $true or $false is returned. If multiple servers are checked, each server\u0027s name and an isBestPractice field are returned.\n\nReferences:\nhttps://support.microsoft.com/en-us/kb/2207548\nhttp://www.sqlskills.com/blogs/glenn/windows-power-plan-effects-on-newer-intel-processors/", "Tags": "PowerPlan", "Params": [ [ "ComputerName", "The server(s) to check Power Plan settings on.", "ServerInstance,SqlServer,SqlInstance", false, "true (ByValue)", "$env:COMPUTERNAME" ], [ "Credential", "Specifies a PSCredential object to use in authenticating to the server(s), instead of the current user account.", "", false, "false", "" ], [ "CustomPowerPlan", "If your organization uses a custom power plan that\u0027s considered best practice, specify it here.", "", false, "false", "" ], [ "InputObject", "Enables piping from Get-DbaPowerPlan", "", false, "true (ByValue)", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", 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": "Checks the Power Plan settings for compliance with best practices, which recommend High Performance for SQL Server.", "Name": "Test-DbaPowerPlan", "Links": "https://dbatools.io/Test-DbaPowerPlan", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaPowerPlan -ComputerName sqlserver2014a\nChecks the Power Plan settings for sqlserver2014a and indicates whether or not it complies with best practices.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaPowerPlan -ComputerName sqlserver2014a -CustomPowerPlan \u0027Maximum Performance\u0027\nChecks the Power Plan settings for sqlserver2014a and indicates whether or not it is set to the custom plan \"Maximum Performance\".", "Syntax": "Test-DbaPowerPlan [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CustomPowerPlan] \u003cString\u003e] [[-InputObject] \u003cPSObject\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaRepLatency", "Description": "Creates tracer tokens to determine latency between the publisher/distributor and the distributor/subscriber\nfor all transactional publications for a server, database, or publication.", "Tags": "Replication", "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "", true, "true (ByValue)", "" ], [ "Database", "The database(s) to process. If unspecified, all databases will be processed.", "", false, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "PublicationName", "The publication(s) to process. If unspecified, all publications will be processed.", "", false, "false", "" ], [ "TimeToLive", "How long, in seconds, to wait for a tracer token to complete its journey from the publisher to the subscriber.\r\nIf unspecified, all tracer tokens will take as long as they need to process results.", "", false, "false", "0" ], [ "RetainToken", "Retains the tracer tokens created for each publication. If unspecified, all tracer tokens created will be discarded.", "", false, "false", "False" ], [ "DisplayTokenHistory", "Displays all tracer tokens in each publication. If unspecified, the current tracer token created will be only token displayed.", "", 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": "Colin Douglas", "Synopsis": "Displays replication latency for all transactional publications for a server or database.", "Name": "Test-DbaRepLatency", "Links": "https://dbatools.io/Test-DbaRepLatency", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaRepLatency -SqlInstance sql2008, sqlserver2012\nReturn replication latency for all transactional publications for servers sql2008 and sqlserver2012.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaRepLatency -SqlInstance sql2008 -Database TestDB\nReturn replication latency for all transactional publications on server sql2008 for only the TestDB database\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaRepLatency -SqlInstance sql2008 -Database TestDB -PublicationName TestDB_Pub\nReturn replication latency for the TestDB_Pub publication for the TestDB database located on the server sql2008.", "Syntax": "Test-DbaRepLatency [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Database] \u003cObject[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-PublicationName] \u003cObject[]\u003e] [[-TimeToLive] \u003cInt32\u003e] [-RetainToken] [-DisplayTokenHistory] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaServerName", "Description": "When a SQL Server\u0027s host OS is renamed, the SQL Server should be as well. This helps with Availability Groups and Kerberos.\n\nThis command helps determine if your OS and SQL Server names match, and whether a rename is required.\n\nIt then checks conditions that would prevent a rename, such as database mirroring and replication.\n\nhttps://www.mssqltips.com/sqlservertip/2525/steps-to-change-the-server-name-for-a-sql-server-machine/", "Tags": [ "SPN", "ServerName" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or 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", "" ], [ "Detailed", "Output all properties, will be deprecated in 1.0.0 release.", "", false, "false", "False" ], [ "ExcludeSsrs", "If this switch is enabled, checking for SQL Server Reporting Services will be skipped.", "NoWarning", 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": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tests to see if it\u0027s possible to easily rename the server at the SQL Server instance level, or if it even needs to be changed.", "Name": "Test-DbaServerName", "Links": "https://dbatools.io/Test-DbaServerName", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a, sql2016\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a, sql2016 -ExcludeSsrs\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016, but skips validating if SSRS is installed on both instances.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a, sql2016 | Select-Object *\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.\r\nIf a Rename is required, it will also show Updatable, and Reasons if the server name is not updatable.", "Syntax": "Test-DbaServerName [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Detailed] [-ExcludeSsrs] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaSpn", "Description": "This function is designed to take in a server name(s) and attempt to determine required SPNs. It was initially written to mimic the (previously) broken functionality of the Microsoft Kerberos Configuration manager and SQL Server 2016.\n\n- For any instances with TCP/IP enabled, the script will determine which port(s) the instances are listening on and generate the required SPNs.\n- For named instances NOT using dynamic ports, the script will generate a port-based SPN for those instances as well.\n- At a minimum, the script will test a base, port-less SPN for each instance discovered.\n\nOnce the required SPNs are generated, the script will connect to Active Directory and search for any of the SPNs (if any) that are already set. The function will return a custom object(s) that contains the server name checked, the instance name discovered, the account the service is running under, and what the \"required\" SPN should be. It will also return a boolean property indicating if the SPN is set in Active Directory or not.", "Tags": "SPN", "Params": [ [ "ComputerName", "The computer you want to discover any SQL Server instances on. This parameter is required.", "", true, "true (ByValue)", "" ], [ "Credential", "The credential you want to use to connect to the remote server and active directory.", "", 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": "Drew Furgiuele (@pittfurg), http://www.port1433.com | niphlod", "Synopsis": "Test-DbaSpn will determine what SPNs *should* be set for a given server (and any instances of SQL running on it) and return\nwhether the SPNs are set or not.", "Name": "Test-DbaSpn", "Links": "https://dbatools.io/Test-DbaSpn", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName SQLSERVERA -Credential ad\\sqldba\nConnects to a computer (SQLSERVERA) and queries WMI for all SQL instances and return \"required\" SPNs. It will then take each SPN it generates\r\nand query Active Directory to make sure the SPNs are set.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName SQLSERVERA,SQLSERVERB -Credential ad\\sqldba\nConnects to multiple computers (SQLSERVERA, SQLSERVERB) and queries WMI for all SQL instances and return \"required\" SPNs.\r\nIt will then take each SPN it generates and query Active Directory to make sure the SPNs are set.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaSpn -ComputerName SQLSERVERC -Credential ad\\sqldba\nConnects to a computer (SQLSERVERC) on a specified and queries WMI for all SQL instances and return \"required\" SPNs.\r\nIt will then take each SPN it generates and query Active Directory to make sure the SPNs are set. Note that the credential you pass must have be a valid login with appropriate rights on the domain", "Syntax": "Test-DbaSpn [-ComputerName] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaTempdbConfig", "Description": "Evaluates tempdb against a set of rules to match best practices. The rules are:\n\n* TF 1118 enabled - Is Trace Flag 1118 enabled (See KB328551).\n* File Count - Does the count of data files in tempdb match the number of logical cores, up to 8?\n* File Growth - Are any files set to have percentage growth? Best practice is all files have an explicit growth value.\n* File Location - Is tempdb located on the C:\\? Best practice says to locate it elsewhere.\n* File MaxSize Set (optional) - Do any files have a max size value? Max size could cause tempdb problems if it isn\u0027t allowed to grow.\n* Data File Size Equal - Are the sizes of all the tempdb data files the same?\n\nOther rules can be added at a future date.", "Tags": [ "tempdb", "configuration" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances. SQL Server 2005 and higher are 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", "" ], [ "Detailed", "Output all properties, will be depreciated in 1.0.0 release.", "", 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": "Test-DbaTempDbConfiguration,Test-SqlTempDbConfiguration", "Author": "Michael Fal (@Mike_Fal), http://mikefal.net", "Synopsis": "Evaluates tempdb against several rules to match best practices.", "Name": "Test-DbaTempdbConfig", "Links": "https://dbatools.io/Test-DbaTempdbConfig", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaTempdbConfig -SqlInstance localhost\nChecks tempdb on the localhost machine.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaTempdbConfig -SqlInstance localhost | Select-Object *\nChecks tempdb on the localhost machine. All rest results are shown.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaCmsRegServer -SqlInstance sqlserver2014a | Test-DbaTempdbConfig | Select-Object * | Out-GridView\nChecks tempdb configuration for a group of servers from SQL Server Central Management Server (CMS). Output includes all columns. Send output to GridView.", "Syntax": "Test-DbaTempdbConfig [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Test-DbaWindowsLogin", "Description": "The purpose of this function is to find SQL Server logins that are used by active directory users that are either disabled or removed from the domain. It allows you to keep your logins accurate and up to date by removing accounts that are no longer needed.", "Tags": [ "Login", "Security" ], "Params": [ [ "SqlInstance", "The SQL Server instance you\u0027re checking logins on. You must have sysadmin access and server version must be SQL Server version 2000 or higher.", "ServerInstance,SqlServer,SqlServers", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Login", "Specifies a list of logins to include in the results. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "ExcludeLogin", "Specifies a list of logins to exclude from the results. Options for this list are auto-populated from the server.", "", false, "false", "" ], [ "FilterBy", "Specifies the object types to return. By default, both Logins and Groups are returned. Valid options for this parameter are \u0027GroupsOnly\u0027 and \u0027LoginsOnly\u0027.", "", false, "false", "None" ], [ "IgnoreDomains", "Specifies a list of Active Directory domains to ignore. By default, all domains in the forest as well as all trusted domains are traversed.", "", false, "false", "" ], [ "Detailed", "Output all properties, will be depreciated in 1.0.0 release.", "", 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": "Test-DbaValidLogin", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/ | Chrissy LeMaire (@cl)", "Synopsis": "Test-DbaWindowsLogin finds any logins on SQL instance that are AD logins with either disabled AD user accounts or ones that no longer exist", "Name": "Test-DbaWindowsLogin", "Links": "https://dbatools.io/Test-DbaWindowsLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eTest-DbaWindowsLogin -SqlInstance Dev01\nTests all logins in the current Active Directory domain that are either disabled or do not exist on the SQL Server instance Dev01\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eTest-DbaWindowsLogin -SqlInstance Dev01 -FilterBy GroupsOnly | Select-Object -Property *\nTests all Active Directory groups that have logins on Dev01, and shows all information for those logins\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eTest-DbaWindowsLogin -SqlInstance Dev01 -IgnoreDomains testdomain\nTests all Domain logins excluding any that are from the testdomain", "Syntax": "Test-DbaWindowsLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-FilterBy \u003cString\u003e] [-IgnoreDomains \u003cString[]\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Uninstall-DbaSqlWatch", "Description": "Deletes all user objects, agent jobs, and historical data associated with SqlWatch.", "Tags": "SqlWatch", "Params": [ [ "SqlInstance", "SQL Server name or SMO object representing the SQL Server to connect to.", "", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Database", "Specifies the database to install SqlWatch into. Defaults to master.", "", false, "false", "master" ], [ "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" ], [ "WhatIf", "Shows what would happen if the command were to run. No actions are actually performed.", "wi", false, "false", "" ], [ "Confirm", "Prompts to confirm actions", "cf", false, "false", "" ] ], "Alias": "", "Author": "Ken K (github.com/koglerk)", "Synopsis": "Uninstalls SqlWatch.", "Name": "Uninstall-DbaSqlWatch", "Links": "https://dbatools.io/Uninstall-DbaSqlWatch", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eUninstall-DbaSqlWatch -SqlInstance server1\nDeletes all user objects, agent jobs, and historical data associated with SqlWatch from the master database.", "Syntax": "Uninstall-DbaSqlWatch [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Uninstall-DbaWatchUpdate", "Description": "Removes the scheduled task created for Watch-DbaUpdate by Install-DbaWatchUpdate so that notifications no longer pop up.", "Tags": [ "JustForFun", "Module" ], "Params": [ ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes the scheduled task created for Watch-DbaUpdate by Install-DbaWatchUpdate so that notifications no longer pop up.", "Name": "Uninstall-DbaWatchUpdate", "Links": "https://dbatools.io/Uninstall-DbaWatchUpdate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eUninstall-DbaWatchUpdate\nRemoves the scheduled task created by Install-DbaWatchUpdate.", "Syntax": "Uninstall-DbaWatchUpdate [\u003cCommonParameters\u003e]" }, { "CommandName": "Update-DbaServiceAccount", "Description": "Reconfigure the service account or update the password of the specified SQL Server service. The service will be restarted in the event of changing the account.", "Tags": [ "Service", "SqlServer", "Instance", "Connect" ], "Params": [ [ "ComputerName", "The target SQL Server instance or instances.", "cn,host,Server", false, "false", "$env:COMPUTERNAME" ], [ "Credential", "Windows Credential with permission to log on to the server running the SQL instance", "", false, "false", "" ], [ "InputObject", "A collection of services. Basically, any object that has ComputerName and ServiceName properties. Can be piped from Get-DbaService.", "ServiceCollection", true, "true (ByValue)", "" ], [ "ServiceName", "A name of the service on which the action is performed. E.g. MSSQLSERVER or SqlAgent$INSTANCENAME", "Name,Service", true, "false", "" ], [ "Username", "Username of the service account. Cannot be used with -ServiceCredential. For local service accounts use one of the following usernames omitting the -Password parameter:\r\nLOCALSERVICE\r\nNETWORKSERVICE\r\nLOCALSYSTEM", "User", false, "false", "" ], [ "ServiceCredential", "Windows Credential object under which the service will be setup to run. Cannot be used with -Username. For local service accounts use one of the following usernames with empty password:\r\nLOCALSERVICE\r\nNETWORKSERVICE\r\nLOCALSYSTEM", "", false, "false", "" ], [ "PreviousPassword", "An old password of the service account. Optional when run under local admin privileges.", "", false, "false", "(New-Object System.Security.SecureString)" ], [ "NewPassword", "New password of the service account. The function will ask for a password if not specified. MSAs and local system accounts will ignore the password.", "Password", false, "false", "(New-Object System.Security.SecureString)" ], [ "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": "Update-DbaSqlServiceAccount", "Author": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Changes service account (or just its password) of the SQL Server service.", "Name": "Update-DbaServiceAccount", "Links": null, "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$NewPassword = ConvertTo-SecureString \u0027Qwerty1234\u0027 -AsPlainText -Force\nUpdate-DbaServiceAccount -ComputerName sql1 -ServiceName \u0027MSSQL$MYINSTANCE\u0027 -Password $NewPassword\nChanges the current service account\u0027s password of the service MSSQL$MYINSTANCE to \u0027Qwerty1234\u0027\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$cred = Get-Credential\nPS C:\\\u003e Get-DbaService sql1 -Type Engine,Agent -Instance MYINSTANCE | Update-DbaServiceAccount -ServiceCredential $cred\nRequests credentials from the user and configures them as a service account for the SQL Server engine and agent services of the instance sql1\\MYINSTANCE\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eUpdate-DbaServiceAccount -ComputerName sql1,sql2 -ServiceName \u0027MSSQLSERVER\u0027,\u0027SQLSERVERAGENT\u0027 -Username NETWORKSERVICE\nConfigures SQL Server engine and agent services on the machines sql1 and sql2 to run under Network Service system user.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003eGet-DbaService sql1 -Type Engine -Instance MSSQLSERVER | Update-DbaServiceAccount -Username \u0027MyDomain\\sqluser1\u0027\nConfigures SQL Server engine service on the machine sql1 to run under MyDomain\\sqluser1. Will request user to input the account password.", "Syntax": "Update-DbaServiceAccount [-ComputerName \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-ServiceName] \u003cString[]\u003e [-Username \u003cString\u003e] [-ServiceCredential \u003cPSCredential\u003e] [-PreviousPassword \u003cSecureString\u003e] [-NewPassword \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\nUpdate-DbaServiceAccount [-Credential \u003cPSCredential\u003e] -InputObject \u003cObject[]\u003e [-Username \u003cString\u003e] [-ServiceCredential \u003cPSCredential\u003e] [-PreviousPassword \u003cSecureString\u003e] [-NewPassword \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Update-Dbatools", "Description": "Exported function. Updates dbatools. Deletes current copy and replaces it with freshest copy.", "Tags": "Module", "Params": [ [ "Development", "If this switch is enabled, the current development branch will be installed. By default, the latest official release is installed.", "dev,devbranch", 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", "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exported function. Updates dbatools. Deletes current copy and replaces it with freshest copy.", "Name": "Update-Dbatools", "Links": "https://dbatools.io/Update-DbaTools", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eUpdate-Dbatools\nUpdates dbatools. Deletes current copy and replaces it with freshest copy.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eUpdate-Dbatools -dev\nUpdates dbatools to the current development branch. Deletes current copy and replaces it with latest from github.", "Syntax": "Update-Dbatools [-Development] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" }, { "CommandName": "Watch-DbaDbLogin", "Description": "Watch-DbaDbLogin uses SQL Server DMV\u0027s to track logins into a SQL Server table. This is helpful when you need to migrate a SQL Server and update connection strings, but have inadequate documentation on which servers/applications are logging into your SQL instance.\n\nRunning this script every 5 minutes for a week should give you a sufficient idea about database and login usage.", "Tags": "Login", "Params": [ [ "SqlInstance", "The SQL Server that stores the Watch database.", "ServerInstance,SqlServer", true, "false", "" ], [ "Database", "The name of the Watch database.", "", false, "false", "" ], [ "Table", "The name of the Watch table. By default, this is DbaTools-WatchDbLogins.", "", false, "false", "DbaTools-WatchDbLogins" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "SqlCms", "Specifies a Central Management Server to query for a list of servers to watch.", "", false, "false", "" ], [ "ServersFromFile", "Specifies a file containing a list of servers to watch. This file must contain one server name per line.", "", 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": "Watch-SqlDbLogin", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tracks SQL Server logins: which host they came from, what database they\u0027re using, and what program is being used to log in.", "Name": "Watch-DbaDbLogin", "Links": "https://dbatools.io/Watch-DbaDbLogin", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eWatch-DbaDbLogin -SqlInstance sqlserver -SqlCms SqlCms1\nA list of all database instances within the Central Management Server SqlCms1 is generated. Using this list, the script enumerates all the processes and gathers login information and saves it to the \r\ntable Dblogins in the DatabaseLogins database on SQL Server sqlserver.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eWatch-DbaDbLogin -SqlInstance sqlcluster -Database CentralAudit -ServersFromFile .\\sqlservers.txt\nA list of servers is gathered from the file sqlservers.txt in the current directory. Using this list, the script enumerates all the processes and gathers login information and saves it to the table \r\nDblogins in the CentralAudit database on SQL Server sqlcluster.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eWatch-DbaDbLogin -SqlInstance sqlserver -SqlCms SqlCms1 -SqlCredential $cred\nA list of servers is generated using database instance names within the SQL2014Clusters group on the Central Management Server SqlCms1. Using this list, the script enumerates all the processes and \r\ngathers login information and saves it to the table Dblogins in the DatabaseLogins database on sqlserver.", "Syntax": "Watch-DbaDbLogin [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-Database] \u003cObject\u003e] [[-Table] \u003cString\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-SqlCms] \u003cString\u003e] [[-ServersFromFile] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Watch-DbaUpdate", "Description": "Just for fun - checks the PowerShell Gallery every 1 hour for updates to dbatools. Notifies once max per release.\n\nAnyone know how to make it clickable so that it opens an URL?", "Tags": [ "JustForFun", "Module" ], "Params": [ ], "Alias": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Just for fun - checks the PowerShell Gallery every 1 hour for updates to dbatools. Notifies once per release.", "Name": "Watch-DbaUpdate", "Links": "https://dbatools.io/Watch-DbaUpdate", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eWatch-DbaUpdate\nWatches the gallery for updates to dbatools.", "Syntax": "Watch-DbaUpdate [\u003cCommonParameters\u003e]" }, { "CommandName": "Watch-DbaXESession", "Description": "Watch live XEvent Data as it happens. This command runs until you stop the session, kill the PowerShell session, or Ctrl-C.\n\nThanks to Dave Mason (@BeginTry) for some straightforward code samples https://itsalljustelectrons.blogspot.be/2017/01/SQL-Server-Extended-Event-Handling-Via-Powershell.html", "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", true, "true (ByValue)", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "", false, "false", "" ], [ "Session", "Only return a specific session. Options for this parameter are auto-populated from the server.", "", false, "false", "" ], [ "InputObject", "Accepts an XESession object returned by Get-DbaXESession.", "", true, "true (ByValue)", "" ], [ "Raw", "If this switch is enabled, the Microsoft.SqlServer.XEvent.Linq.QueryableXEventData enumeration object is returned.", "", 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": "Watch-DbaXEventSession", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Watch live XEvent Data as it happens", "Name": "Watch-DbaXESession", "Links": "https://dbatools.io/Watch-DbaXESession", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003eWatch-DbaXESession -SqlInstance sql2017 -Session system_health\nShows events for the system_health session as it happens.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003eWatch-DbaXESession -SqlInstance sql2017 -Session system_health | Export-Csv -NoTypeInformation -Path C:\\temp\\system_health.csv\nExports live events to CSV. Ctrl-C may not not cancel out of it - fastest way is to stop the session.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 -Session system_health | Start-DbaXESession | Watch-DbaXESession | Export-Csv -NoTypeInformation -Path C:\\temp\\system_health.csv\nExports live events to CSV. Ctrl-C may not not cancel out of this. The fastest way to do so is to stop the session.", "Syntax": "Watch-DbaXESession [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString\u003e] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]\nWatch-DbaXESession -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString\u003e] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]\nWatch-DbaXESession [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString\u003e] -InputObject \u003cSession\u003e [-Raw] [-EnableException] [\u003cCommonParameters\u003e]" }, { "CommandName": "Write-DbaDataTable", "Description": "Writes a .NET DataTable to a SQL Server table using SQL Bulk Copy.", "Tags": [ "DataTable", "Insert" ], "Params": [ [ "SqlInstance", "The target SQL Server instance or instances.", "ServerInstance,SqlServer", true, "false", "" ], [ "SqlCredential", "Login to the target instance using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)", "Credential", false, "false", "" ], [ "Database", "The database to import the table into.", "", false, "false", "" ], [ "InputObject", "This is the DataTable (or data row) to import to SQL Server.", "DataTable", true, "true (ByValue)", "" ], [ "Table", "The table name to import data into. You can specify a one, two, or three part table name. If you specify a one or two part name, you must also use -Database.\nIf the table does not exist, you can use -AutoCreateTable to automatically create the table with inefficient data types.\nIf the object has special characters please wrap them in square brackets [ ].\r\nUsing dbo.First.Table will try to import to a table named \u0027Table\u0027 on schema \u0027First\u0027 and database \u0027dbo\u0027.\r\nThe correct way to import to a table named \u0027First.Table\u0027 on schema \u0027dbo\u0027 is by passing dbo.[First.Table]\r\nAny actual usage of the ] must be escaped by duplicating the ] character.\r\nThe correct way to import to a table Name] in schema Schema.Name is by passing [Schema.Name].[Name]]]", "", true, "false", "" ], [ "Schema", "Defaults to dbo if no schema is specified.", "", false, "false", "dbo" ], [ "BatchSize", "The BatchSize for the import defaults to 5000.", "", false, "false", "50000" ], [ "NotifyAfter", "Sets the option to show the notification after so many rows of import", "", false, "false", "5000" ], [ "AutoCreateTable", "If this switch is enabled, the table will be created if it does not already exist. The table will be created with sub-optimal data types such as nvarchar(max)", "", false, "false", "False" ], [ "NoTableLock", "If this switch is enabled, a table lock (TABLOCK) will not be placed on the destination table. By default, this operation will lock the destination table while running.", "", false, "false", "False" ], [ "CheckConstraints", "If this switch is enabled, the SqlBulkCopy option to process check constraints will be enabled.\nPer Microsoft \"Check constraints while data is being inserted. By default, constraints are not checked.\"", "", false, "false", "False" ], [ "FireTriggers", "If this switch is enabled, the SqlBulkCopy option to fire insert triggers will be enabled.\nPer Microsoft \"When specified, cause the server to fire the insert triggers for the rows being inserted into the Database.\"", "", false, "false", "False" ], [ "KeepIdentity", "If this switch is enabled, the SqlBulkCopy option to preserve source identity values will be enabled.\nPer Microsoft \"Preserve source identity values. When not specified, identity values are assigned by the destination.\"", "", false, "false", "False" ], [ "KeepNulls", "If this switch is enabled, the SqlBulkCopy option to preserve NULL values will be enabled.\nPer Microsoft \"Preserve null values in the destination table regardless of the settings for default values. When not specified, null values are replaced by default values where applicable.\"", "", false, "false", "False" ], [ "Truncate", "If this switch is enabled, the destination table will be truncated after prompting for confirmation.", "", false, "false", "False" ], [ "bulkCopyTimeOut", "Value in seconds for the BulkCopy operations timeout. The default is 30 seconds.", "", false, "false", "5000" ], [ "RegularUser", "Deprecated - now all connections are regular user (don\u0027t require admin)", "", 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" ], [ "UseDynamicStringLength", "By default, all string columns will be NVARCHAR(MAX).\r\nIf this switch is enabled, all columns will get the length specified by the column\u0027s MaxLength property (if specified)", "", false, "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": "", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Writes data to a SQL Server Table.", "Name": "Write-DbaDataTable", "Links": "https://dbatools.io/Write-DbaDataTable", "Examples": "-------------------------- EXAMPLE 1 --------------------------\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv\nPS C:\\\u003e Write-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Table mydb.dbo.customers\nPerforms a bulk insert of all the data in customers.csv into database mydb, schema dbo, table customers. A progress bar will be shown as rows are inserted. If the destination table does not exist, \r\nthe import will be halted.\n-------------------------- EXAMPLE 2 --------------------------\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv\nPS C:\\\u003e $DataTable | Write-DbaDataTable -SqlInstance sql2014 -Table mydb.dbo.customers\nPerforms a row by row insert of the data in customers.csv. This is significantly slower than a bulk insert and will not show a progress bar.\r\nThis method is not recommended. Use -InputObject instead.\n-------------------------- EXAMPLE 3 --------------------------\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv\nPS C:\\\u003e Write-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Table mydb.dbo.customers -AutoCreateTable -Confirm\nPerforms a bulk insert of all the data in customers.csv. If mydb.dbo.customers does not exist, it will be created with inefficient but forgiving DataTypes.\nPrompts for confirmation before a variety of steps.\n-------------------------- EXAMPLE 4 --------------------------\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv\nPS C:\\\u003e Write-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Table mydb.dbo.customers -Truncate\nPerforms a bulk insert of all the data in customers.csv. Prior to importing into mydb.dbo.customers, the user is informed that the table will be truncated and asks for confirmation. The user is \r\nprompted again to perform the import.\n-------------------------- EXAMPLE 5 --------------------------\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv\nPS C:\\\u003e Write-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Database mydb -Table customers -KeepNulls\nPerforms a bulk insert of all the data in customers.csv into mydb.dbo.customers. Because Schema was not specified, dbo was used. NULL values in the destination table will be preserved.\n-------------------------- EXAMPLE 6 --------------------------\nPS C:\\\u003e$passwd = ConvertTo-SecureString \"P@ssw0rd\" -AsPlainText -Force\nPS C:\\\u003e $AzureCredential = New-Object System.Management.Automation.PSCredential(\"AzureAccount\"),$passwd)\r\nPS C:\\\u003e $DataTable = Import-Csv C:\\temp\\customers.csv\r\nPS C:\\\u003e Write-DbaDataTable -SqlInstance AzureDB.database.windows.net -InputObject $DataTable -Database mydb -Table customers -KeepNulls -Credential $AzureCredential -BulkCopyTimeOut 300\nThis performs the same operation as the previous example, but against a SQL Azure Database instance using the required credentials.\n-------------------------- EXAMPLE 7 --------------------------\nPS C:\\\u003e$process = Get-Process\nPS C:\\\u003e Write-DbaDataTable -InputObject $process -SqlInstance sql2014 -Table \"[[DbName]]].[Schema.With.Dots].[`\"[Process]]`\"]\" -AutoCreateTable\nCreates a table based on the Process object with over 60 columns, converted from PowerShell data types to SQL Server data types. After the table is created a bulk insert is performed to add process \r\ninformation into the table\r\nWrites the results of Get-Process to a table named: \"[Process]\" in schema named: Schema.With.Dots in database named: [DbName]\r\nThe Table name, Schema name and Database name must be wrapped in square brackets [ ]\r\nSpecial charcters like \" must be escaped by a ` charcter.\r\nIn addition any actual instance of the ] character must be escaped by being duplicated.\nThis is an example of the type conversion in action. All process properties are converted, including special types like TimeSpan. Script properties are resolved before the type conversion starts \r\nthanks to ConvertTo-DbaDataTable.", "Syntax": "Write-DbaDataTable [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject\u003e] -InputObject \u003cObject\u003e [-Table] \u003cString\u003e [[-Schema] \u003cString\u003e] [-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-AutoCreateTable] [-NoTableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] [-Truncate] [-bulkCopyTimeOut \u003cInt32\u003e] [-RegularUser] [-EnableException] [-UseDynamicStringLength] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]" } ] |