bin/dbatools-index.json
[
{ "CommandName": "Add-DbaComputerCertificate", "Description": "Adds a computer certificate from a local or remote computer.", "Tags": "Certificate", "Syntax": "\r\nAdd-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Password] \r\n\u003cSecureString\u003e] [[-Certificate] \u003cX509Certificate2[]\u003e] [[-Path] \u003cString\u003e] [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds a computer certificate - useful for older systems.", "Name": "Add-DbaComputerCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaComputerCertificate -ComputerName Server1 -Path C:\\temp\\cert.cer\r\n\r\nAdds the local C:\\temp\\cert.cer to the remote server Server1 in LocalMachine\\My (Personal).\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaComputerCertificate -Path C:\\temp\\cert.cer\r\n\r\nAdds the local C:\\temp\\cert.cer to the local computer\u0027s LocalMachine\\My (Personal) certificate store.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Add-DbaPfDataCollectorCounter", "Description": "Adds a Performance Data Collector Counter.", "Tags": "PerfMon", "Syntax": "\r\nAdd-DbaPfDataCollectorCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [-Counter] \u003cObject[]\u003e [[-InputObject] \u003cObject[]\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds a Performance Data Collector Counter.", "Name": "Add-DbaPfDataCollectorCounter", "Links": "https://dbatools.io/Add-DbaPfDataCollectorCounter", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaPfDataCollectorCounter -ComputerName sql2017 -CollectorSet \u0027System Correlation\u0027 -Collector \r\nDataCollector01 -Counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027\r\n\r\nAdds the \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 counter within the DataCollector01 collector within the System \r\nCorrelation collector set on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollector | Out-GridView -PassThru | Add-DbaPfDataCollectorCounter -Counter \u0027\\LogicalDisk(*)\\Avg. \r\nDisk Queue Length\u0027 -Confirm\r\n\r\nAllows you to select which Data Collector you\u0027d like to add the counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 on \r\nlocalhost and prompts for confirmation.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Add-DbaRegisteredServer", "Description": "Adds registered servers to SQL Server Central Management Server (CMS). If you need more flexiblity, look into Import-DbaRegisteredServer which\naccepts multiple kinds of input and allows you to add reg servers from different CMSes.", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nAdd-DbaRegisteredServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-ServerName] \r\n\u003cString\u003e [[-Name] \u003cString\u003e] [[-Description] \u003cString\u003e] [[-Group] \u003cObject\u003e] [[-InputObject] \u003cServerGroup[]\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds registered servers to SQL Server Central Management Server (CMS)", "Name": "Add-DbaRegisteredServer", "Links": "https://dbatools.io/Add-DbaRegisteredServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaRegisteredServer -SqlInstance sql2008 -ServerName sql01\r\n\r\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, the name \r\n\"sql01\" will be visible.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaRegisteredServer -SqlInstance sql2008 -ServerName sql01 -Name \"The 2008 Clustered Instance\" -Description \r\n\"HR\u0027s Dedicated SharePoint instance\"\r\n\r\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, \"The 2008 \r\nClustered Instance\" will be visible.\r\nClearly this is hard to explain ;)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaRegisteredServer -SqlInstance sql2008 -ServerName sql01 -Group hr\\Seattle\r\n\r\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, the name \r\n\"sql01\" will be visible within the Seattle group which is in the hr group.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sql2008 -Group hr\\Seattle | Add-DbaRegisteredServer -ServerName \r\nsql01111\r\n\r\nCreates a registered server on sql2008\u0027s CMS which points to the SQL Server, sql01. When scrolling in CMS, the name \r\n\"sql01\" will be visible within the Seattle group which is in the hr group.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Add-DbaRegisteredServerGroup", "Description": "Adds registered server groups to SQL Server Central Management Server (CMS). If you need more flexiblity, look into Import-DbaRegisteredServer which\naccepts multiple kinds of input and allows you to add reg servers and groups from different CMSes.", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nAdd-DbaRegisteredServerGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \r\n\u003cString\u003e [[-Description] \u003cString\u003e] [[-Group] \u003cString\u003e] [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Adds registered server groups to SQL Server Central Management Server (CMS)", "Name": "Add-DbaRegisteredServerGroup", "Links": "https://dbatools.io/Add-DbaRegisteredServerGroup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaRegisteredServerGroup -SqlInstance sql2012 -Name HR\r\n\r\nCreates a registered server group called HR, in the root of sql2012\u0027s CMS\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eAdd-DbaRegisteredServerGroup -SqlInstance sql2012, sql2014 -Name subfolder -Group HR\r\n\r\nCreates a registered server group on sql2012 and sql2014 called subfolder within the HR group\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sql2012, sql2014 -Group HR | Add-DbaRegisteredServerGroup -Name \r\nsubfolder\r\n\r\nCreates a registered server group on sql2012 and sql2014 called subfolder within the HR group of each server\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nBackup-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] \r\n[-BackupDirectory \u003cString[]\u003e] [-BackupFileName \u003cString\u003e] [-CopyOnly] [-Type \u003cString\u003e] [-CreateFolder] [-FileCount \r\n\u003cInt32\u003e] [-CompressBackup] [-Checksum] [-Verify] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] \r\n[-AzureBaseUrl \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-NoRecovery] [-BuildPath] [-WithFormat] [-Initialize] \r\n[-SkipTapeHeader] [-IgnoreFileChecks] [-OutputScriptOnly] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nBackup-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-BackupDirectory \u003cString[]\u003e] [-BackupFileName \u003cString\u003e] [-CopyOnly] [-Type \u003cString\u003e] \r\n[-CreateFolder] [-FileCount \u003cInt32\u003e] [-CompressBackup] [-Checksum] [-Verify] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \r\n\u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-AzureBaseUrl \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-NoRecovery] [-BuildPath] \r\n[-WithFormat] [-Initialize] [-SkipTapeHeader] [-IgnoreFileChecks] [-OutputScriptOnly] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nBackup-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] \r\n[-BackupDirectory \u003cString[]\u003e] [-BackupFileName \u003cString\u003e] [-CopyOnly] [-Type \u003cString\u003e] -InputObject \u003cObject[]\u003e \r\n[-CreateFolder] [-FileCount \u003cInt32\u003e] [-CompressBackup] [-Checksum] [-Verify] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \r\n\u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-AzureBaseUrl \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-NoRecovery] [-BuildPath] \r\n[-WithFormat] [-Initialize] [-SkipTapeHeader] [-IgnoreFileChecks] [-OutputScriptOnly] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance Server1 -Database HR, Finance\r\n\r\nThis will perform a full database backup on the databases HR and Finance on SQL Server Instance Server1 to Server1\u0027s \r\ndefault backup directory.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance sql2016 -BackupDirectory C:\\temp -Database AdventureWorks2014 -Type Full\r\n\r\nBacks up AdventureWorks2014 to sql2016\u0027s C:\\temp folder.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDatabase -SqlInstance sql2016 -AzureBaseUrl https://dbatoolsaz.blob.core.windows.net/azbackups/ \r\n-AzureCredential dbatoolscred -Type Full -CreateFolder\r\n\r\nPerforms a full backup of all databases on the sql2016 instance to their own containers under the \r\nhttps://dbatoolsaz.blob.core.windows.net/azbackups/ container on Azure blog storage using the sql credential \r\n\"dbatoolscred\" registered on the sql2016 instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Backup-DbaDbCertificate", "Description": "Exports database certificates from SQL Server using SMO and outputs the .cer and .pvk files.", "Tags": [ "Migration", "Certificate" ], "Syntax": "\r\nBackup-DbaDbCertificate [-SqlCredential \u003cPSCredential\u003e] [-EncryptionPassword \u003cSecureString\u003e] [-DecryptionPassword \r\n\u003cSecureString\u003e] [-Path \u003cFileInfo\u003e] [-Suffix \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nBackup-DbaDbCertificate -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Certificate \u003cObject[]\u003e] \r\n[-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-EncryptionPassword \u003cSecureString\u003e] [-DecryptionPassword \r\n\u003cSecureString\u003e] [-Path \u003cFileInfo\u003e] [-Suffix \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nBackup-DbaDbCertificate [-SqlCredential \u003cPSCredential\u003e] [-EncryptionPassword \u003cSecureString\u003e] [-DecryptionPassword \r\n\u003cSecureString\u003e] [-Path \u003cFileInfo\u003e] [-Suffix \u003cString\u003e] [-InputObject \u003cCertificate[]\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Jess Pomfret (@jpomfret)", "Synopsis": "Exports database certificates from SQL Server using SMO.", "Name": "Backup-DbaDbCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1\r\n\r\nExports all the certificates on the specified SQL Server to the default data path for the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nBackup-DbaDbCertificate -SqlInstance Server1 -SqlCredential $cred\r\n\r\nConnects using sqladmin credential and exports all the certificates on the specified SQL Server to the default data \r\npath for the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Certificate Certificate1\r\n\r\nExports only the certificate named Certificate1 on the specified SQL Server to the default data path for the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Database AdventureWorks\r\n\r\nExports only the certificates for AdventureWorks on the specified SQL Server to the default data path for the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -ExcludeDatabase AdventureWorks\r\n\r\nExports all certificates except those for AdventureWorks on the specified SQL Server to the default data path for the \r\ninstance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates -EncryptionPassword \r\n(ConvertTo-SecureString -force -AsPlainText GoodPass1234!!)\r\n\r\nExports all the certificates and private keys on the specified SQL Server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e$EncryptionPassword = ConvertTo-SecureString -AsPlainText \"GoodPass1234!!\" -force\r\n\r\n$DecryptionPassword = ConvertTo-SecureString -AsPlainText \"Password4567!!\" -force\r\nBackup-DbaDbCertificate -SqlInstance Server1 -EncryptionPassword $EncryptionPassword -DecryptionPassword \r\n$DecryptionPassword\r\nExports all the certificates on the specified SQL Server using the supplied DecryptionPassword, since an \r\nEncryptionPassword is specified private keys are also exported.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates\r\n\r\nExports all certificates on the specified SQL Server to the specified path.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbCertificate -SqlInstance Server1 -Suffix DbaTools\r\n\r\nExports all certificates on the specified SQL Server to the specified path, appends DbaTools to the end of the \r\nfilenames.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance sql2016 | Backup-DbaDbCertificate\r\n\r\nExports all certificates found on sql2016 to the default data directory.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Backup-DbaDbMasterKey", "Description": "Backs up specified database master key.", "Tags": [ "Certificate", "Database" ], "Syntax": "\r\nBackup-DbaDbMasterKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Password] \u003cSecureString\u003e] [[-Path] \r\n\u003cString\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Backs up specified database master key.", "Name": "Backup-DbaDbMasterKey", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbMasterKey -SqlInstance server1\\sql2016\r\n\r\nPrompts for export password, then logs into server1\\sql2016 with Windows credentials then backs up all database keys to \r\nthe default backup directory.\r\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\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eBackup-DbaDbMasterKey -SqlInstance Server1 -Database db1 -Path \\\\nas\\sqlbackups\\keys\r\n\r\nLogs into sql2016 with Windows credentials then backs up db1\u0027s keys to the \\\\nas\\sqlbackups\\keys directory.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nClear-DbaConnectionPool [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Resets (or empties) the connection pool.", "Name": "Clear-DbaConnectionPool", "Links": "https://dbatools.io/Clear-DbaConnectionPool", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eClear-DbaConnectionPool\r\n\r\nClears all local connection pools.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eClear-DbaConnectionPool -ComputerName workstation27\r\n\r\nClears all connection pools on workstation27.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Clear-DbaPlanCache", "Description": "Checks ahoc 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", "Syntax": "\r\nClear-DbaPlanCache [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Threshold] \u003cInt32\u003e] \r\n[[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Tracy Boggiano, databasesuperhero.com", "Synopsis": "Removes adhoc and prepared plan caches is single use plans are over defined threshold.", "Name": "Clear-DbaPlanCache", "Links": "https://dbatools.io/Clear-DbaPlanCache", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eClear-DbaPlanCache -SqlInstance sql2017 -Threshold 200\r\n\r\nLogs into the SQL Server instance \"sql2017\" and removes plan caches if over 200 MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eClear-DbaPlanCache -SqlInstance sql2017 -SqlCredential (Get-Credential sqladmin)\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Clear-DbaWaitStatistics", "Description": "Reset the aggregated statistics - basically just executes DBCC SQLPERF (N\u0027sys.dm_os_wait_stats\u0027, CLEAR)", "Tags": "WaitStatistic", "Syntax": "\r\nClear-DbaWaitStatistics [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl)", "Synopsis": "Clears wait statistics", "Name": "Clear-DbaWaitStatistics", "Links": "https://dbatools.io/Clear-DbaWaitStatistics", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eClear-DbaWaitStatistics -SqlInstance sql2008, sqlserver2012\r\n\r\nAfter confirmation, clears wait stats on servers sql2008 and sqlserver2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eClear-DbaWaitStatistics -SqlInstance sql2008, sqlserver2012 -Confirm:$false\r\n\r\nClears wait stats on servers sql2008 and sqlserver2012, without prompting\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nConnect-DbaInstance [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-AccessToken] \u003cString\u003e] [[-ApplicationIntent] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [[-ClientName] \u003cString\u003e] \r\n[[-ConnectTimeout] \u003cInt32\u003e] [-EncryptConnection] [[-FailoverPartner] \u003cString\u003e] [-IsActiveDirectoryUniversalAuth] \r\n[[-LockTimeout] \u003cInt32\u003e] [[-MaxPoolSize] \u003cInt32\u003e] [[-MinPoolSize] \u003cInt32\u003e] [-MultipleActiveResultSets] \r\n[-MultiSubnetFailover] [[-NetworkProtocol] \u003cString\u003e] [-NonPooledConnection] [[-PacketSize] \u003cInt32\u003e] \r\n[[-PooledConnectionLifetime] \u003cInt32\u003e] [[-SqlExecutionModes] \u003cString\u003e] [[-StatementTimeout] \u003cInt32\u003e] \r\n[-TrustServerCertificate] [[-WorkstationId] \u003cString\u003e] [[-AppendConnectionString] \u003cString\u003e] [-SqlConnectionOnly] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a robust SMO SQL Server object.", "Name": "Connect-DbaInstance", "Links": "https://dbatools.io/Connect-DbaInstance", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eConnect-DbaInstance -SqlInstance sql2014\r\n\r\nCreates an SMO Server object that connects using Windows Authentication\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\r\n\r\nConnect-DbaInstance -SqlInstance sql2014 -Credential $wincred\r\n\r\nCreates an SMO Server object that connects using alternative Windows credentials\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$sqlcred = Get-Credential sqladmin\r\n\r\n$server = Connect-DbaInstance -SqlInstance sql2014 -Credential $sqlcred\r\n\r\nLogin to sql2014 as SQL login sqladmin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$server = Connect-DbaInstance -SqlInstance sql2014 -ClientName \"my connection\"\r\n\r\nCreates an SMO Server object that connects using Windows Authentication and uses the client name \"my connection\". So \r\nwhen you open up profiler or use extended events, you can search for \"my connection\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$server = Connect-DbaInstance -SqlInstance sql2014 -AppendConnectionString \"Packet \r\nSize=4096;AttachDbFilename=C:\\MyFolder\\MyDataFile.mdf;User Instance=true;\"\r\n\r\nCreates an SMO Server object that connects to sql2014 using Windows Authentication, then it sets the packet size (this \r\ncan also be done via -PacketSize) and other connection attributes.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$server = Connect-DbaInstance -SqlInstance sql2014 -NetworkProtocol TcpIp -MultiSubnetFailover\r\n\r\nCreates an SMO Server object that connects using Windows Authentication that uses TCP/IP and has MultiSubnetFailover \r\nenabled.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e$server = Connect-DbaInstance sql2016 -ApplicationIntent ReadOnly\r\n\r\nConnects with ReadOnly ApplicationIntent.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 datatable fails, try the -Raw parameter for less accurate datatype detection.", "Tags": [ "DataTable", "Table", "Data" ], "Syntax": "\r\nConvertTo-DbaDataTable [-InputObject] \u003cPSObject[]\u003e [[-TimeSpanType] \u003cString\u003e] [-SizeType \u003cString\u003e] [-IgnoreNull] [-Raw] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Creates a DataTable for an object.", "Name": "ConvertTo-DbaDataTable", "Links": "https://dbatools.io/ConvertTo-DbaDataTable", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-Service | ConvertTo-DbaDataTable\r\n\r\nCreates a DataTable from the output of Get-Service.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eConvertTo-DbaDataTable -InputObject $csv.cheesetypes\r\n\r\nCreates a DataTable from the CSV object $csv.cheesetypes.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$dblist | ConvertTo-DbaDataTable\r\n\r\nCreates a DataTable from the $dblist object passed in via pipeline.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-Process | ConvertTo-DbaDataTable -TimeSpanType TotalSeconds\r\n\r\nCreates a DataTable with the running processes and converts any TimeSpan property to TotalSeconds.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "ConvertTo-DbaTimeline", "Description": "This function accepts input as pipeline from the following psdbatools functions:\n Get-DbaAgentJobHistory\n Get-DbaBackupHistory\n (more to come...)\nAnd generates Bootstrap based, HTML file with Google Chart Timeline", "Tags": "Chart", "Syntax": "\r\nConvertTo-DbaTimeline [-InputObject] \u003cObject[]\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Marcin Gminski (@marcingminski)", "Synopsis": "Converts InputObject to a html timeline using Google Chart", "Name": "ConvertTo-DbaTimeline", "Links": "https://dbatools.io/ConvertTo-DbaTimeline", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql-1 -StartDate \u00272018-08-13 00:00\u0027 -EndDate \u00272018-08-13 23:59\u0027 -NoJobSteps \r\n| ConvertTo-DbaTimeline | Out-File C:\\temp\\DbaAgentJobHistory.html -Encoding ASCII\r\n\r\nCreates an output file containing a pretty timeline for all of the agent job history results for sql-1 the whole day of \r\n2018-08-13\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlcm | Get-DbaBackupHistory -Since \u00272018-08-13 00:00\u0027 | \r\nConvertTo-DbaTimeline | Out-File C:\\temp\\DbaBackupHistory.html -Encoding ASCII\r\n\r\nCreates an output file containing a pretty timeline for the agent job history since 2018-08-13 for all of the \r\nregistered servers on sqlcm\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$messageParameters = @{\r\n\r\nSubject = \"Backup history for sql2017 and sql2016\"\r\n Body = Get-DbaBackupHistory -SqlInstance sql2017, sql2016 -Since \u00272018-08-13 00:00\u0027 | ConvertTo-DbaTimeline\r\n From = \"dba@ad.local\"\r\n To = \"dba@ad.local\"\r\n SmtpServer = \"smtp.ad.local\"\r\n}\r\nSend-MailMessage @messageParameters -BodyAsHtml\r\n\r\nSends an email to dba@ad.local with the results of Get-DbaBackupHistory. Note that viewing these reports may not be \r\nsupported in all email clients.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nConvertTo-DbaXESession [-InputObject] \u003cObject[]\u003e [-Name] \u003cString\u003e [-OutputScriptOnly] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2017, sql2012 | Where Id -eq 2 | ConvertTo-DbaXESession -Name \u0027Test\u0027\r\n\r\nConverts Trace with ID 2 to a Session named Test on SQL Server instances named sql2017 and sql2012\r\nand creates the Session on each respective server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2014 | Out-GridView -PassThru | ConvertTo-DbaXESession -Name \u0027Test\u0027 | \r\nStart-DbaXESession\r\n\r\nConverts selected traces on sql2014 to sessions, creates the session, and starts it.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2014 | Where Id -eq 1 | ConvertTo-DbaXESession -Name \u0027Test\u0027 -OutputScriptOnly\r\n\r\nConverts trace ID 1 on sql2014 to an Extended Event and outputs the resulting T-SQL.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentAlert [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Alert] \u003cObject[]\u003e] [[-ExcludeAlert] \r\n\u003cObject[]\u003e] [-IncludeDefaults] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all alerts from sqlserver2014a to sqlcluster using Windows credentials. If alerts with the same name exist on \r\nsqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster -Alert PSAlert -SourceSqlCredential $cred \r\n-Force\r\n\r\nCopies a only the alert named PSAlert from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster. If a alert with the same name exists on sqlcluster, it will be dropped and \r\nrecreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentAlert -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentCategory -Source \u003cDbaInstanceParameter\u003e [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \r\n\u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-JobCategory \u003cString[]\u003e] [-AgentCategory \r\n\u003cString[]\u003e] [-OperatorCategory \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaAgentCategory -Source \u003cDbaInstanceParameter\u003e [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \r\n\u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-CategoryType \u003cString[]\u003e] [-JobCategory \r\n\u003cString[]\u003e] [-AgentCategory \u003cString[]\u003e] [-OperatorCategory \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentCategory -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all operator categories from sqlserver2014a to sqlcluster using Windows authentication. If operator categories \r\nwith the same name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentCategory -Source sqlserver2014a -Destination sqlcluster -OperatorCategory PSOperator \r\n-SourceSqlCredential $cred -Force\r\n\r\nCopies a single operator category, the PSOperator operator category from sqlserver2014a to sqlcluster using SQL \r\ncredentials to authenticate to sqlserver2014a and Windows credentials for sqlcluster. If a operator category with the \r\nsame name exists on sqlcluster, it will be dropped and recreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentCategory -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentJob [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] [[-ExcludeJob] \u003cObject[]\u003e] \r\n[-DisableOnSource] [-DisableOnDestination] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentJob -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all jobs from sqlserver2014a to sqlcluster, using Windows credentials. If jobs with the same name exist on \r\nsqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentJob -Source sqlserver2014a -Destination sqlcluster -Job PSJob -SourceSqlCredential $cred -Force\r\n\r\nCopies a single job, the PSJob job from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster. If a job with the same name exists on sqlcluster, it will be dropped and recreated \r\nbecause -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentJob -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentOperator [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Operator] \u003cObject[]\u003e] [[-ExcludeOperator] \r\n\u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentOperator -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all operators from sqlserver2014a to sqlcluster using Windows credentials. If operators with the same name exist \r\non sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentOperator -Source sqlserver2014a -Destination sqlcluster -Operator PSOperator -SourceSqlCredential \r\n$cred -Force\r\n\r\nCopies only the PSOperator operator from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster. If an operator with the same name exists on sqlcluster, it will be dropped and \r\nrecreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentOperator -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentProxyAccount [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ProxyAccount] \u003cString[]\u003e] \r\n[[-ExcludeProxyAccount] \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentProxyAccount -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all proxy accounts from sqlserver2014a to sqlcluster using Windows credentials. If proxy accounts with the same \r\nname exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentProxyAccount -Source sqlserver2014a -Destination sqlcluster -ProxyAccount PSProxy \r\n-SourceSqlCredential $cred -Force\r\n\r\nCopies only the PSProxy proxy account from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster. If a proxy account with the same name exists on sqlcluster, it will be dropped and \r\nrecreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentProxyAccount -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentServer [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-DisableJobsOnDestination] \r\n[-DisableJobsOnSource] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentServer -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all job server objects from sqlserver2014a to sqlcluster using Windows credentials for authentication. If job \r\nobjects with the same name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentServer -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\r\n\r\nCopies all job objects from sqlserver2014a to sqlcluster using SQL credentials to authentication to sqlserver2014a and \r\nWindows credentials to authenticate to sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentServer -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaAgentSharedSchedule [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentSharedSchedule -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all shared job schedules from sqlserver2014a to sqlcluster using Windows credentials. If shared job schedules \r\nwith the same name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaAgentSharedSchedule -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaBackupDevice [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-BackupDevice] \u003cObject[]\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaBackupDevice -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all server backup devices from sqlserver2014a to sqlcluster using Windows credentials. If backup devices with \r\nthe same name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaBackupDevice -Source sqlserver2014a -Destination sqlcluster -BackupDevice backup01 -SourceSqlCredential \r\n$cred -Force\r\n\r\nCopies only the backup device named backup01 from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a \r\n and Windows credentials for sqlcluster. If a backup device with the same name exists on sqlcluster, it will be \r\ndropped and recreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaBackupDevice -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Copy-DbaCentralManagementServer", "Description": "Copy-DbaCentralManagementServer copies all groups, subgroups, and server instances from one SQL Server to another.", "Tags": "Migration", "Syntax": "\r\nCopy-DbaCentralManagementServer [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-CMSGroup] \u003cObject[]\u003e] [-SwitchServerName] \r\n[-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCentralManagementServer -Source sqlserver2014a -Destination sqlcluster\r\n\r\nAll groups, subgroups, and server instances are copied from sqlserver\u0027s Central Management Server to sqlcluster\u0027s \r\nCentral Management Server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCentralManagementServer -Source sqlserver2014a -Destination sqlcluster -ServerGroup Group1,Group3\r\n\r\nTop-level groups Group1 and Group3 along with their subgroups and server instances are copied from sqlserver to \r\nsqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCentralManagementServer -Source sqlserver2014a -Destination sqlcluster -ServerGroup Group1,Group3 \r\n-SwitchServerName -SourceSqlCredential $SourceSqlCredential -DestinationSqlCredential $DestinationSqlCredential\r\n\r\nTop-level groups Group1 and Group3 along with their subgroups and server instances are copied from sqlserver to \r\nsqlcluster. When adding sql instances to sqlcluster, if the server name of the migrating instance is \"sqlcluster\", it \r\nwill be switched to \"sqlserver\".\r\n\r\nIf SwitchServerName is not specified, \"sqlcluster\" will be skipped.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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/\n\nWebsite: https://dbatools.io\nCopyright: (C) Chrissy LeMaire, clemaire@gmail.com\nLicense: MIT https://opensource.org/licenses/MIT", "Tags": [ "WSMan", "Migration" ], "Syntax": "\r\nCopy-DbaCredential [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Name] \r\n\u003cString[]\u003e] [[-ExcludeName] \u003cString[]\u003e] [[-Identity] \u003cString[]\u003e] [[-ExcludeIdentity] \u003cString[]\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCredential -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all SQL Server Credentials on sqlserver2014a to sqlcluster. If Credentials exist on destination, they will be \r\nskipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCredential -Source sqlserver2014a -Destination sqlcluster -Name \"PowerShell Proxy Account\" -Force\r\n\r\nCopies over one SQL Server Credential (PowerShell Proxy Account) from sqlserver to sqlcluster. If the Credential \r\nalready exists on the destination, it will be dropped and recreated.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaCustomError [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-CustomError] \u003cObject[]\u003e] \r\n[[-ExcludeCustomError] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all server custom errors from sqlserver2014a to sqlcluster using Windows credentials. If custom errors with the \r\nsame name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -SourceSqlCredential $scred -Destination sqlcluster \r\n-DestinationSqlCredential $dcred -CustomError 60000 -Force\r\n\r\nCopies only the custom error with ID number 60000 from sqlserver2014a to sqlcluster using SQL credentials for \r\nsqlserver2014a and Windows credentials for sqlcluster. If a custom error with the same name exists on sqlcluster, it \r\nwill be updated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -Destination sqlcluster -ExcludeCustomError 60000 -Force\r\n\r\nCopies all the custom errors found on sqlserver2014a except the custom error with ID number 60000 to sqlcluster. If a \r\ncustom error with the same name exists on sqlcluster, it will be updated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaCustomError -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaDatabase [-Source \u003cDbaInstanceParameter\u003e] [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \r\n\u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \r\n\u003cObject[]\u003e] [-AllDatabases] -BackupRestore [-NetworkShare \u003cString\u003e] [-WithReplace] [-NoRecovery] [-NoBackupCleanup] \r\n[-NumberFiles \u003cInt32\u003e] [-SetSourceReadOnly] [-ReuseSourceFolderStructure] [-IncludeSupportDbs] [-UseLastBackups] \r\n[-Continue] [-InputObject \u003cDatabase[]\u003e] [-NoCopyOnly] [-SetSourceOffline] [-NewName \u003cString\u003e] [-Prefix \u003cString\u003e] \r\n[-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaDatabase [-Source \u003cDbaInstanceParameter\u003e] [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \r\n\u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \r\n\u003cObject[]\u003e] [-AllDatabases] -DetachAttach [-Reattach] [-SetSourceReadOnly] [-ReuseSourceFolderStructure] \r\n[-IncludeSupportDbs] [-InputObject \u003cDatabase[]\u003e] [-NoCopyOnly] [-SetSourceOffline] [-NewName \u003cString\u003e] [-Prefix \r\n\u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDatabase -Source sql2014a -Destination sql2014b -Database TestDB -BackupRestore -NetworkShare \r\n\\\\fileshare\\sql\\migration\r\n\r\nMigrates a single user database TestDB using Backup and restore from instance sql2014a to sql2014b. Backup files are \r\nstored in \\\\fileshare\\sql\\migration.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDatabase -Source sql2012 -Destination sql2014, sql2016 -DetachAttach -Reattach\r\n\r\nDatabases will be migrated from sql2012 to both sql2014 and sql2016 using the detach/copy files/attach method.The \r\nfollowing will be performed: kick all users out of the database, detach all data/log files, move files across the \r\nnetwork over an admin share (\\\\SqlSERVER\\M$\\MSSql...), attach file on destination server, reattach at source. If the \r\ndatabase files (*.mdf, *.ndf, *.ldf) on *destination* exist and aren\u0027t in use, they will be overwritten.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDatabase -Source sql2014a -Destination sqlcluster, sql2016 -BackupRestore -UseLastBackups -Force\r\n\r\nMigrates all user databases to sqlcluster and sql2016 using the last Full, Diff and Log backups from sql204a. If the \r\ndatabases exists on the destinations, they will be dropped prior to attach.\r\n\r\nNote that the backups must exist in a location accessible by all destination servers, such a network share.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDatabase -Source sql2014a -Destination sqlcluster -ExcludeDatabase Northwind, pubs -IncludeSupportDbs \r\n-Force -BackupRestore -NetworkShare \\\\fileshare\\sql\\migration\r\n\r\nMigrates all user databases except for Northwind and pubs by using backup/restore (copy-only). Backup files are stored \r\nin \\\\fileshare\\sql\\migration. If the database exists on the destination, it will be dropped prior to attach.\r\n\r\nIt also includes the support databases (ReportServer, ReportServerTempDb, distribution).\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaDataCollector [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-CollectionSet] \u003cObject[]\u003e] \r\n[[-ExcludeCollectionSet] \u003cObject[]\u003e] [-NoServerReconfig] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all Data Collector Objects and Configurations from sqlserver2014a to sqlcluster, using Windows credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\r\n\r\nCopies all Data Collector Objects and Configurations from sqlserver2014a to sqlcluster, using SQL credentials for \r\nsqlserver2014a and Windows credentials for sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDataCollector -Source sqlserver2014a -Destination sqlcluster -CollectionSet \u0027Server Activity\u0027, \u0027Table \r\nUsage Analysis\u0027\r\n\r\nCopies two Collection Sets, Server Activity and Table Usage Analysis, from sqlserver2014a to sqlcluster.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaDbAssembly [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Assembly] \u003cObject[]\u003e] [[-ExcludeAssembly] \r\n\u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbAssembly -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all assemblies from sqlserver2014a to sqlcluster using Windows credentials. If assemblies with the same name \r\nexist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbAssembly -Source sqlserver2014a -Destination sqlcluster -Assembly dbname.assemblyname, \r\ndbname3.anotherassembly -SourceSqlCredential $cred -Force\r\n\r\nCopies two assemblies, the dbname.assemblyname and dbname3.anotherassembly from sqlserver2014a to sqlcluster using SQL \r\ncredentials for sqlserver2014a and Windows credentials for sqlcluster. If an assembly with the same name exists on \r\nsqlcluster, it will be dropped and recreated because -Force was used.\r\n\r\nIn this example, anotherassembly will be copied to the dbname3 database on the server sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbAssembly -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Copy-DbaDbMail", "Description": "By default, all mail configurations for Profiles, Accounts, Mail Servers and Configs are copied.", "Tags": [ "Migration", "Mail" ], "Syntax": "\r\nCopy-DbaDbMail -Source \u003cDbaInstanceParameter\u003e -Destination \u003cDbaInstanceParameter[]\u003e [-SourceSqlCredential \r\n\u003cPSCredential\u003e] [-DestinationSqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaDbMail -Source \u003cDbaInstanceParameter\u003e -Destination \u003cDbaInstanceParameter[]\u003e [-Type \u003cString[]\u003e] \r\n[-SourceSqlCredential \u003cPSCredential\u003e] [-DestinationSqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all database mail objects from sqlserver2014a to sqlcluster using Windows credentials. If database mail objects \r\nwith the same name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\r\n\r\nCopies all database mail objects from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and Windows \r\ncredentials for sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbMail -Source sqlserver2014a -Destination sqlcluster -EnableException\r\n\r\nPerforms execution of function, and will throw a terminating exception if something breaks\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Copy-DbaDbTableData", "Description": "Copies data between SQL Server tables using SQL Bulk Copy.\nThe same can be achieved also doing\n $sourcetable = Invoke-SqlCmd2 -ServerInstance instance1 ... -As DataTable\n Write-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", "Syntax": "\r\nCopy-DbaDbTableData [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Destination] \r\n\u003cDbaInstanceParameter\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] [[-DestinationDatabase] \r\n\u003cString\u003e] [[-Table] \u003cString[]\u003e] [[-Query] \u003cString\u003e] [[-BatchSize] \u003cInt32\u003e] [[-NotifyAfter] \u003cInt32\u003e] \r\n[[-DestinationTable] \u003cString\u003e] [-NoTableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] \r\n[-Truncate] [[-bulkCopyTimeOut] \u003cInt32\u003e] [[-InputObject] \u003cTable[]\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod (Simone Bizzotto)", "Synopsis": "Copies data between SQL Server tables.", "Name": "Copy-DbaDbTableData", "Links": "https://dbatools.io/Copy-DbaDbTableData", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -Table test_table\r\n\r\nCopies all the data from sql1 to sql2, using the database dbatools_from.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -DestinationDatabase \r\ndbatools_dest -Table test_table\r\n\r\nCopies all the data from sql1 to sql2, using the database dbatools_from as source and dbatools_dest as destination\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql1 -Database tempdb -Table tb1, tb2 | Copy-DbaDbTableData -DestinationTable tb3\r\n\r\nCopies all data from tables tb1 and tb2 in tempdb on sql1 to tb3 in tempdb on sql1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql1 -Database tempdb -Table tb1, tb2 | Copy-DbaDbTableData -Destination sql2\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -Table test_table\r\n\r\nCopies all the data from sql1 to sql2, using the database dbatools_from.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -Table test_table -KeepIdentity \r\n-Truncate\r\n\r\nCopies all the data from sql1 to sql2, using the database dbatools_from, keeping identity columns and truncating the \r\ndestination\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaDbTableData -SqlInstance sql1 -Destination sql2 -Database dbatools_from -Table test_table -KeepIdentity \r\n-Truncate\r\n\r\nCopies all the data from sql1 to sql2, using the database dbatools_from, keeping identity columns and truncating the \r\ndestination\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaEndpoint [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Endpoint] \u003cObject[]\u003e] [[-ExcludeEndpoint] \r\n\u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaEndpoint -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all server endpoints from sqlserver2014a to sqlcluster, using Windows credentials. If endpoints with the same \r\nname exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaEndpoint -Source sqlserver2014a -SourceSqlCredential $cred -Destination sqlcluster -Endpoint tg_noDbDrop \r\n-Force\r\n\r\nCopies only the tg_noDbDrop endpoint from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster. If an endpoint with the same name exists on sqlcluster, it will be dropped and \r\nrecreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaEndpoint -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaExtendedEvent [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-SourceSqlCredential] \r\n\u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-XeSession] \u003cObject[]\u003e] [[-ExcludeXeSession] \u003cObject[]\u003e] \r\n[-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all Extended Event sessions from sqlserver2014a to sqlcluster using Windows credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\r\n\r\nCopies all Extended Event sessions from sqlserver2014a to sqlcluster using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaExtendedEvent -Source sqlserver2014a -Destination sqlcluster -XeSession CheckQueries, \r\nMonitorUserDefinedException\r\n\r\nCopies only the Extended Events named CheckQueries and MonitorUserDefinedException from sqlserver2014a to sqlcluster.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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/\n\nWebsite: https://dbatools.io\nCopyright: (C) Chrissy LeMaire, clemaire@gmail.com\nLicense: MIT https://opensource.org/licenses/MIT", "Tags": [ "WSMan", "Migration", "LinkedServer" ], "Syntax": "\r\nCopy-DbaLinkedServer [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-LinkedServer] \u003cObject[]\u003e] \r\n[[-ExcludeLinkedServer] \u003cObject[]\u003e] [-UpgradeSqlClient] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLinkedServer -Source sqlserver2014a -Destination sqlcluster\r\n\r\nDescription\r\nCopies all SQL Server Linked Servers on sqlserver2014a to sqlcluster. If Linked Server exists on destination, it will \r\nbe skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLinkedServer -Source sqlserver2014a -Destination sqlcluster -LinkedServer SQL2K5,SQL2k -Force\r\n\r\nDescription\r\nCopies over two SQL Server Linked Servers (SQL2K and SQL2K2) from sqlserver to sqlcluster. If the credential already \r\nexists on the destination, it will be dropped.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \r\n\u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-LoginRenameHashtable \r\n\u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaLogin -Source \u003cDbaInstanceParameter\u003e [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \r\n\u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] \r\n[-ExcludeSystemLogin] [-SyncOnly] [-SyncSaName] [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \r\n\u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-SyncSaName] \r\n[-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \r\n\u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] -OutFile \u003cString\u003e \r\n[-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nCopy-DbaLogin [-SourceSqlCredential \u003cPSCredential\u003e] -Destination \u003cDbaInstanceParameter[]\u003e [-DestinationSqlCredential \r\n\u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeSystemLogin] [-SyncOnly] [-InputObject \r\n\u003cObject\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-KillActiveConnection] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Force\r\n\r\nCopies all logins from Source Destination. If a SQL Login on Source exists on the Destination, the Login on Destination \r\nwill be dropped and recreated.\r\n\r\nIf active connections are found for a login, the copy of that Login will fail as it cannot be dropped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Force -KillActiveConnection\r\n\r\nCopies all logins from Source Destination. If a SQL Login on Source exists on the Destination, the Login on Destination \r\nwill be dropped and recreated.\r\n\r\nIf any active connections are found they will be killed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Exclude realcajun -SourceSqlCredential $scred \r\n-DestinationSqlCredential $dcred\r\n\r\nCopies all Logins from Source to Destination except for realcajun using SQL Authentication to connect to both instances.\r\n\r\nIf a Login already exists on the destination, it will not be migrated.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Login realcajun, netnerds -force\r\n\r\nCopies ONLY Logins netnerds and realcajun. If Login realcajun or netnerds exists on Destination, the existing Login(s) \r\nwill be dropped and recreated.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -SyncOnly\r\n\r\nSyncs only SQL Server login permissions, roles, etc. Does not add or drop logins or users.\r\n\r\nIf a matching Login does not exist on Destination, the Login will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaLogin -LoginRenameHashtable @{ \"OldUser\" =\"newlogin\" } -Source $Sql01 -Destination Localhost \r\n-SourceSqlCredential $sqlcred\r\n\r\nCopies OldUser and then renames it to newlogin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 | Out-GridView -Passthru | Copy-DbaLogin -Destination sql2017\r\n\r\nDisplays all available logins on sql2016 in a grid view, then copies all selected logins to sql2017.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nCopy-DbaPolicyManagement [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Policy] \u003cObject[]\u003e] [[-ExcludePolicy] \r\n\u003cObject[]\u003e] [[-Condition] \u003cObject[]\u003e] [[-ExcludeCondition] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all policies and conditions from sqlserver2014a to sqlcluster, using Windows credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\r\n\r\nCopies all policies and conditions from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and \r\nWindows credentials for sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -Policy \u0027xp_cmdshell must be disabled\u0027\r\n\r\nCopies only one policy, \u0027xp_cmdshell must be disabled\u0027 from sqlserver2014a to sqlcluster. No conditions are migrated.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Copy-DbaQueryStoreConfig", "Description": "Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.", "Tags": "QueryStore", "Syntax": "\r\nCopy-DbaQueryStoreConfig [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-SourceDatabase] \r\n\u003cObject\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-DestinationDatabase] \r\n\u003cObject[]\u003e] [[-Exclude] \u003cObject[]\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaQueryStoreConfig -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL \r\n-AllDatabases\r\n\r\nCopy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it on all user \r\ndatabases in the ServerB\\SQL Instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaQueryStoreConfig -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL \r\n-DestinationDatabase WorldWideTraders\r\n\r\nCopy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it to the \r\nWorldWideTraders database in the ServerB\\SQL Instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaResourceGovernor [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ResourcePool] \u003cObject[]\u003e] \r\n[[-ExcludeResourcePool] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Migrates Resource Pools", "Name": "Copy-DbaResourceGovernor", "Links": "https://dbatools.io/Copy-DbaResourceGovernor", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaResourceGovernor -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all all non-system resource pools from sqlserver2014a to sqlcluster using Windows credentials to connect to the \r\nSQL Server instances..\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaResourceGovernor -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred\r\n\r\nCopies all all non-system resource pools from sqlserver2014a to sqlcluster using SQL credentials to connect to \r\nsqlserver2014a and Windows credentials to connect to sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaResourceGovernor -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nCopy-DbaServerAudit [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Audit] \u003cObject[]\u003e] [[-ExcludeAudit] \r\n\u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerAudit -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all server audits from sqlserver2014a to sqlcluster, using Windows credentials. If audits with the same name \r\nexist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerAudit -Source sqlserver2014a -Destination sqlcluster -Audit tg_noDbDrop -SourceSqlCredential $cred \r\n-Force\r\n\r\nCopies a single audit, the tg_noDbDrop audit from sqlserver2014a to sqlcluster, using SQL credentials for \r\nsqlserver2014a and Windows credentials for sqlcluster. If an audit with the same name exists on sqlcluster, it will be \r\ndropped and recreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerAudit -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaServerAuditSpecification [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] \r\n[-Destination] \u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-AuditSpecification] \u003cObject[]\u003e] \r\n[[-ExcludeAuditSpecification] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all server audits from sqlserver2014a to sqlcluster using Windows credentials to connect. If audits with the \r\nsame name exist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster -ServerAuditSpecification \r\ntg_noDbDrop -SourceSqlCredential $cred -Force\r\n\r\nCopies a single audit, the tg_noDbDrop audit from sqlserver2014a to sqlcluster using SQL credentials to connect to \r\nsqlserver2014a and Windows credentials to connect to sqlcluster. If an audit specification with the same name exists on \r\nsqlcluster, it will be dropped and recreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nCopy-DbaServerTrigger [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ServerTrigger] \u003cObject[]\u003e] \r\n[[-ExcludeServerTrigger] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerTrigger -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all server triggers from sqlserver2014a to sqlcluster, using Windows credentials. If triggers with the same name \r\nexist on sqlcluster, they will be skipped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerTrigger -Source sqlserver2014a -Destination sqlcluster -ServerTrigger tg_noDbDrop \r\n-SourceSqlCredential $cred -Force\r\n\r\nCopies a single trigger, the tg_noDbDrop trigger from sqlserver2014a to sqlcluster, using SQL credentials for \r\nsqlserver2014a and Windows credentials for sqlcluster. If a trigger with the same name exists on sqlcluster, it will be \r\ndropped and recreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaServerTrigger -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaSpConfigure [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-ConfigName] \u003cObject[]\u003e] [[-ExcludeConfigName] \r\n\u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all sp_configure settings from sqlserver2014a to sqlcluster\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster -ConfigName DefaultBackupCompression, \r\nIsSqlClrEnabled -SourceSqlCredential $cred -Force\r\n\r\nCopies the values for IsSqlClrEnabled and DefaultBackupCompression from sqlserver2014a to sqlcluster using SQL \r\ncredentials to authenticate to sqlserver2014a and Windows credentials to authenticate to sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster -ExcludeConfigName DefaultBackupCompression, \r\nIsSqlClrEnabled\r\n\r\nCopies all configs except for IsSqlClrEnabled and DefaultBackupCompression, from sqlserver2014a to sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSpConfigure -Source sqlserver2014a -Destination sqlcluster -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaSsisCatalog [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-SourceSqlCredential] \r\n\u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Project] \u003cString\u003e] [[-Folder] \u003cString\u003e] [[-Environment] \r\n\u003cString\u003e] [[-CreateCatalogPassword] \u003cSecureString\u003e] [-EnableSqlClr] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster\r\n\r\nCopies all folders, environments and SSIS Projects from sqlserver2014a to sqlcluster, using Windows credentials to \r\nauthenticate to both instances. If folders with the same name exist on the destination they will be skipped, but \r\nprojects will be redeployed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster -Project Archive_Tables -SourceSqlCredential \r\n$cred -Force\r\n\r\nCopies a single Project, the Archive_Tables Project, from sqlserver2014a to sqlcluster using SQL credentials to \r\nauthenticate to sqlserver2014a and Windows credentials to authenticate to sqlcluster. If a Project with the same name \r\nexists on sqlcluster, it will be deleted and recreated because -Force was used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force\r\n\r\nShows what would happen if the command were executed using force.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$SecurePW = Read-Host \"Enter password\" -AsSecureString\r\n\r\nCopy-DbaSsisCatalog -Source sqlserver2014a -Destination sqlcluster -CreateCatalogPassword $SecurePW\r\n\r\nDeploy entire SSIS catalog to an instance without a destination catalog. User prompts for creating the catalog on \r\nDestination will be bypassed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaSysDbUserObject [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter[]\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-Force] [-Classic] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaSysDbUserObject $sourceServer $destserver\r\n\r\nCopies user objects from source to destination\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nCopy-DbaXESessionTemplate [[-Path] \u003cString[]\u003e] [[-Destination] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaXESessionTemplate\r\n\r\nCopies non-Microsoft templates from the dbatools template repository (\\bin\\xetemplates\\) to $home\\Documents\\SQL Server \r\nManagement Studio\\Templates\\XEventTemplates.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eCopy-DbaXESessionTemplate -Path C:\\temp\\xetemplates\r\n\r\nCopies your templates from C:\\temp\\xetemplates to $home\\Documents\\SQL Server Management \r\nStudio\\Templates\\XEventTemplates.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nDisable-DbaAgHadr [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Force] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton | http://blog.wsmelton.info)", "Synopsis": "Disables the Hadr service setting on the specified SQL Server.", "Name": "Disable-DbaAgHadr", "Links": "https://dbatools.io/Disable-DbaAgHadr", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eDisable-DbaAgHadr -SqlInstance sql2016 -Force\r\n\r\nSets Hadr service to disabled for the instance sql2016, and restart the service to apply the change.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eDisable-DbaAgHadr -SqlInstance sql2012\\dev1 -Force\r\n\r\nSets Hadr service to disabled for the instance dev1 on sq2012, and restart the service to apply the change.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nDisable-DbaForceNetworkEncryption [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Disables Force Encryption for a SQL Server instance", "Name": "Disable-DbaForceNetworkEncryption", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eDisable-DbaForceNetworkEncryption\r\n\r\nDisables Force Encryption on the default (MSSQLSERVER) instance on localhost - requires (and checks for) RunAs admin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eDisable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2\r\n\r\nDisables Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both login and modify the \r\nregistry.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eDisable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2 -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nDisable-DbaTraceFlag [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -TraceFlag \u003cInt32[]\u003e \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eDisable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 3226\r\n\r\nDisable the globally running trace flag 3226 on SQL Server instance sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nDismount-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-UpdateStatistics] [-Force] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nDismount-DbaDatabase -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cString\u003e \r\n[-UpdateStatistics] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nDismount-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cDatabase[]\u003e [-UpdateStatistics] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Detach a SQL Server Database.", "Name": "Dismount-DbaDatabase", "Links": "https://dbatools.io/Dismount-DbaDatabase", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eDetach-DbaDatabase -SqlInstance sql2016b -Database SharePoint_Config, WSS_Logging\r\n\r\nDetaches SharePoint_Config and WSS_Logging from sql2016b\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016b -Database \u0027PerformancePoint Service \r\nApplication_10032db0fa0041df8f913f558a5dc0d4\u0027 | Detach-DbaDatabase -Force\r\n\r\nDetaches \u0027PerformancePoint Service Application_10032db0fa0041df8f913f558a5dc0d4\u0027 from sql2016b. Since Force was \r\nspecified, if the database is part of mirror, the mirror will be broken prior to detaching.\r\n\r\nIf the database is part of an Availability Group, it will first be dropped prior to detachment.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016b -Database WSS_Logging | Detach-DbaDatabase -Force -WhatIf\r\n\r\nShows what would happen if the command were to execute (without actually executing the detach/break/remove commands).\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "AG", "AvailabilityGroup" ], "Syntax": "\r\nEnable-DbaAgHadr [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Force] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton | http://blog.wsmelton.info)", "Synopsis": "Enables the Hadr service setting on the specified SQL Server.", "Name": "Enable-DbaAgHadr", "Links": "https://dbatools.io/Enable-DbaAgHadr", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaAgHadr -SqlInstance sql2016 -Force\r\n\r\nSets Hadr service to enabled for the instance sql2016, and restart the service to apply the change.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaAgHadr -SqlInstance sql2012\\dev1 -Force\r\n\r\nSets Hadr service to disabled for the instance dev1 on sq2012, and restart the service to apply the change.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nEnable-DbaForceNetworkEncryption [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Enables Force Encryption for a SQL Server instance.", "Name": "Enable-DbaForceNetworkEncryption", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaForceNetworkEncryption\r\n\r\nEnables Force Encryption on the default (MSSQLSERVER) instance on localhost. Requires (and checks for) RunAs admin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2\r\n\r\nEnables Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both connect and modify the \r\nregistry.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2 -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Enable-DbaTraceFlag", "Description": "The function will set one or multiple trace flags on the SQL Server instance(s) listed", "Tags": "TraceFlag", "Syntax": "\r\nEnable-DbaTraceFlag [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -TraceFlag \u003cInt32[]\u003e \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Enable Global Trace Flag(s)", "Name": "Enable-DbaTraceFlag", "Links": "https://dbatools.io/Enable-DbaTraceFlag", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 3226\r\n\r\nEnable the trace flag 3226 on SQL Server instance sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eEnable-DbaTraceFlag -SqlInstance sql2016 -TraceFlag 1117, 1118\r\n\r\nEnable multiple trace flags on SQL Server instance sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Expand-DbaTLogResponsibly", "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:\n Too 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\n References:\n http://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\n http://blogs.msdn.com/b/saponsqlserver/archive/2012/02/22/too-many-virtual-log-files-vlfs-can-cause-slow-database-recovery.aspx\n http://www.brentozar.com/blitz/high-virtual-log-file-vlf-count/\n\n In 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\n Note: In SQL Server 2014 this algorithm has changed (http://www.sqlskills.com/blogs/paul/important-change-vlf-creation-algorithm-sql-server-2014/)\n\nAttention:\n We are growing in MB instead of GB because of known issue prior to SQL 2012:\n More detail here:\n http://www.sqlskills.com/BLOGS/PAUL/post/Bug-log-file-growth-broken-for-multiples-of-4GB.aspx\n and\n http://connect.microsoft.com/SqlInstance/feedback/details/481594/log-growth-not-working-properly-with-specific-growth-sizes-vlfs-also-not-created-appropriately\n or\n https://connect.microsoft.com/SqlInstance/feedback/details/357502/transaction-log-file-size-will-not-grow-exactly-4gb-when-filegrowth-4gb\n\nUnderstanding related problems:\n http://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\n http://blogs.msdn.com/b/saponsqlserver/archive/2012/02/22/too-many-virtual-log-files-vlfs-can-cause-slow-database-recovery.aspx\n http://www.brentozar.com/blitz/high-virtual-log-file-vlf-count/\n\nKnown bug before SQL Server 2012\n http://www.sqlskills.com/BLOGS/PAUL/post/Bug-log-file-growth-broken-for-multiples-of-4GB.aspx\n http://connect.microsoft.com/SqlInstance/feedback/details/481594/log-growth-not-working-properly-with-specific-growth-sizes-vlfs-also-not-created-appropriately\n https://connect.microsoft.com/SqlInstance/feedback/details/357502/transaction-log-file-size-will-not-grow-exactly-4gb-when-filegrowth-4gb\n\nHow it works?\n The transaction log will grow in chunks until it reaches the desired size.\n Example: 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" ], "Syntax": "\r\nExpand-DbaTLogResponsibly [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-TargetLogSizeMB] \u003cInt32\u003e [[-IncrementSizeMB] \u003cInt32\u003e] [[-LogFileId] \r\n\u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nExpand-DbaTLogResponsibly [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-TargetLogSizeMB] \u003cInt32\u003e [[-IncrementSizeMB] \u003cInt32\u003e] [[-LogFileId] \r\n\u003cInt32\u003e] [-ShrinkLogFile] [-ShrinkSizeMB] \u003cInt32\u003e [[-BackupDirectory] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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-DbaTLogResponsibly", "Links": "https://dbatools.io/Expand-DbaTLogResponsibly", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExpand-DbaTLogResponsibly -SqlInstance sqlcluster -Database db1 -TargetLogSizeMB 50000\r\n\r\nGrows the transaction log for database db1 on sqlcluster to 50000 MB and calculates the increment size.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExpand-DbaTLogResponsibly -SqlInstance sqlcluster -Database db1, db2 -TargetLogSizeMB 10000 -IncrementSizeMB 200\r\n\r\nGrows the transaction logs for databases db1 and db2 on sqlcluster to 1000MB and sets the growth increment to 200MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eExpand-DbaTLogResponsibly -SqlInstance sqlcluster -Database db1 -TargetLogSizeMB 10000 -LogFileId 9\r\n\r\nGrows the transaction log file with FileId 9 of the db1 database on sqlcluster instance to 10000MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eExpand-DbaTLogResponsibly -SqlInstance sqlcluster -Database (Get-Content D:\\DBs.txt) -TargetLogSizeMB 50000\r\n\r\nGrows the transaction log of the databases specified in the file \u0027D:\\DBs.txt\u0027 on sqlcluster instance to 50000MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eExpand-DbaTLogResponsibly -SqlInstance SqlInstance -Database db1,db2 -TargetLogSizeMB 100 -IncrementSizeMB 10 \r\n-ShrinkLogFile -ShrinkSizeMB 10 -BackupDirectory R:\\MSSQL\\Backup\r\n\r\nGrows the transaction logs for databases db1 and db2 on SQL server SQLInstance to 100MB, sets the incremental growth to \r\n10MB, shrinks the transaction log to 10MB and uses the directory R:\\MSSQL\\Backup for the required backups.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "AG", "AvailabilityGroup" ], "Syntax": "\r\nExport-DbaAvailabilityGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[[-AvailabilityGroup] \u003cObject[]\u003e] [[-ExcludeAvailabilityGroup] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [-NoClobber] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2012\r\n\r\nExports all Availability Groups from SQL server \"sql2012\". Output scripts are written to the Documents\\SqlAgExports \r\ndirectory by default.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2012 -Path C:\\temp\\availability_group_exports\r\n\r\nExports all Availability Groups from SQL server \"sql2012\". Output scripts are written to the \r\nC:\\temp\\availability_group_exports directory.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2012 -Path \u0027C:\\dir with spaces\\availability_group_exports\u0027 \r\n-AvailabilityGroups AG1,AG2\r\n\r\nExports Availability Groups AG1 and AG2 from SQL server \"sql2012\". Output scripts are written to the C:\\dir with \r\nspaces\\availability_group_exports directory.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaAvailabilityGroup -SqlInstance sql2014 -Path C:\\temp\\availability_group_exports -NoClobber\r\n\r\nExports all Availability Groups from SQL server \"sql2014\". Output scripts are written to the \r\nC:\\temp\\availability_group_exports directory. If the export file already exists it will not be overwritten.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nExport-DbaCredential [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Identity] \u003cString[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] \r\n[[-Credential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-ExcludePassword] [-Append] [[-InputObject] \u003cCredential[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports credentials INCLUDING PASSWORDS, unless specified otherwise, to sql file.", "Name": "Export-DbaCredential", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaCredential -SqlInstance sql2017 -Path C:\\temp\\cred.sql\r\n\r\nExports credentials, including passwords, from sql2017 to the file C:\\temp\\cred.sql\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nExport-DbaDacPackage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-AllUserDatabases] [[-Path] \u003cString\u003e] [[-ExtendedParameters] \u003cString\u003e] \r\n[[-ExtendedProperties] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Richie lee (@bzzzt_io)", "Synopsis": "Exports a dacpac from a server.", "Name": "Export-DbaDacPackage", "Links": "https://dbatools.io/Export-DbaDacPackage", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaDacPackage -SqlInstance sql2016 -Database SharePoint_Config\r\n\r\nExports the dacpac for SharePoint_Config on sql2016 to $home\\Documents\\SharePoint_Config.dacpac\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$moreprops = \"/p:VerifyExtraction=$true /p:CommandTimeOut=10\"\r\n\r\nExport-DbaDacPackage -SqlInstance sql2016 -Database SharePoint_Config -Path C:\\temp -ExtendedProperties $moreprops\r\n\r\nSets the CommandTimeout to 10 then extracts the dacpac for SharePoint_Config on sql2016 to \r\nC:\\temp\\SharePoint_Config.dacpac then verifies extraction.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 Fike (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", "Syntax": "\r\nExport-DbaDiagnosticQuery [-InputObject] \u003cObject[]\u003e [[-ConvertTo] \u003cString\u003e] [[-Path] \u003cFileInfo\u003e] [[-Suffix] \u003cString\u003e] \r\n[-NoPlanExport] [-NoQueryExport] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Andre Kamman (@AndreKamman), http://clouddba.io", "Synopsis": "Export-DbaDiagnosticQuery can convert ouput generated by Invoke-DbaDiagnosticQuery to CSV or Excel", "Name": "Export-DbaDiagnosticQuery", "Links": "https://dbatools.io/Export-DbaDiagnosticQuery", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -SqlInstance sql2016 | Export-DbaDiagnosticQuery -Path c:\\temp\r\n\r\nConverts output from Invoke-DbaDiagnosticQuery to multiple CSV files\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$output = Invoke-DbaDiagnosticQuery -SqlInstance sql2016\r\n\r\nExport-DbaDiagnosticQuery -InputObject $output -ConvertTo Excel\r\n\r\nConverts output from Invoke-DbaDiagnosticQuery to Excel worksheet(s) in the Documents folder\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaExecutionPlan", "Description": "Exports execution plans to disk. Can pipe from Get-DbaExecutionPlan\n\nThanks to\n https://www.simple-talk.com/sql/t-sql-programming/dmvs-for-query-plan-metadata/\n and\n http://www.scarydba.com/2017/02/13/export-plans-cache-sqlplan-file/\nfor the idea and query.", "Tags": [ "Performance", "ExecutionPlan" ], "Syntax": "\r\nExport-DbaExecutionPlan [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nExport-DbaExecutionPlan -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] -Path \u003cString\u003e [-SinceCreation \u003cDateTime\u003e] [-SinceLastExecution \u003cDateTime\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nExport-DbaExecutionPlan [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] -Path \u003cString\u003e -PipedObject \u003cObject[]\u003e \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports execution plans to disk.", "Name": "Export-DbaExecutionPlan", "Links": "https://dbatools.io/Export-DbaExecutionPlan", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaExecutionPlan -SqlInstance sqlserver2014a -Path C:\\Temp\r\n\r\nExports all execution plans for sqlserver2014a. Files saved in to C:\\Temp\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaExecutionPlan -SqlInstance sqlserver2014a -Database db1, db2 -SinceLastExecution \u00272016-07-01 10:47:00\u0027 \r\n-Path C:\\Temp\r\n\r\nExports all execution plans for databases db1 and db2 on sqlserver2014a since July 1, 2016 at 10:47 AM. Files saved in \r\nto C:\\Temp\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a | Export-DbaExecutionPlan -Path C:\\Temp\r\n\r\nGets all execution plans for sqlserver2014a. Using Pipeline exports them all to C:\\Temp\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a | Export-DbaExecutionPlan -Path C:\\Temp -WhatIf\r\n\r\nGets all execution plans for sqlserver2014a. Then shows what would happen if the results where piped to \r\nExport-DbaExecutionPlan\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaInstance", "Description": "Export-DbaInstance consolidates most of the export scripts in dbatools into one command.\n\nThis is useful when you\u0027re looking to Export entire instances. It less flexible than using the underlying functions.\nThink of it as an easy button. Unless an -Exclude is specified, it exports:\n\nAll databases.\nAll logins.\nAll database mail objects.\nAll credentials.\nAll objects within the Job Server (SQL Agent).\nAll linked servers.\nAll groups and servers within Central Management Server.\nAll SQL Server configuration objects (everything in sp_configure).\nAll user objects in system databases.\nAll system triggers.\nAll system backup devices.\nAll Audits.\nAll Endpoints.\nAll Extended Events.\nAll Policy Management objects.\nAll Resource Governor objects.\nAll Server Audit Specifications.\nAll Custom Errors (User Defined Messages).\nAll Server Roles.\nAll Availability Groups.", "Tags": "Export", "Syntax": "\r\nExport-DbaInstance [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-NoRecovery] [-IncludeDbMasterKey] [[-Exclude] \u003cString[]\u003e] [[-BatchSeparator] \r\n\u003cString\u003e] [[-ScriptingOption] \u003cScriptingOptions\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports SQL Server *ALL* databases, logins, database mail profiles/accounts, credentials, SQL Agent objects, linked servers,\nCentral Management Server objects, server configuration settings (sp_configure), user objects in systems databases,\nsystem triggers and backup devices from one SQL Server to another.\n\nFor more granular control, please use one of the -Exclude parameters and use the other functions available within the dbatools module.", "Name": "Export-DbaInstance", "Links": "https://dbatools.io/Export-DbaInstance", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaInstance -SqlInstance sqlserver\\instance -Destination sqlcluster\r\n\r\nAll databases, logins, job objects and sp_configure options will be exported from sqlserver\\instance to to disk.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaInstance -SqlInstance sqlcluster -Exclude Databases, Logins -Verbose\r\n\r\nExports everything but logins and databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaInstance -Verbose -SqlInstance sqlcluster -Exclude Databases, Logins\r\n\r\nExports everything but logins and databases.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nExport-DbaLinkedServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-LinkedServer] \u003cString[]\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] [-ExcludePassword] [-Append] [[-InputObject] \r\n\u003cLinkedServer[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports linked servers INCLUDING PASSWORDS, unless specified otherwise, to sql file.", "Name": "Export-DbaLinkedServer", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLinkedServer -SqlInstance sql2017 -Path C:\\temp\\ls.sql\r\n\r\nExports the linked servers, including passwords, from sql2017 to the file C:\\temp\\ls.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLinkedServer -SqlInstance sql2017 -Path C:\\temp\\ls.sql -ExcludePassword\r\n\r\nExports the linked servers, without passwords, from sql2017 to the file C:\\temp\\ls.sql\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nExport-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cObject[]\u003e] \r\n[[-ExcludeLogin] \u003cObject[]\u003e] [[-Database] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [-NoClobber] [-Append] [-NoDatabases] \r\n[-NoJobs] [-EnableException] [-ExcludeGoBatchSeparator] [[-DestinationVersion] \u003cString\u003e] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLogin -SqlInstance sql2005 -Path C:\\temp\\sql2005-logins.sql\r\n\r\nExports the logins for SQL Server \"sql2005\" and writes them to the file \"C:\\temp\\sql2005-logins.sql\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2014a -Exclude realcajun -SqlCredential $scred -Path C:\\temp\\logins.sql \r\n-Append\r\n\r\nAuthenticates to sqlserver2014a using SQL Authentication. Exports all logins except for realcajun to \r\nC:\\temp\\logins.sql, and appends to the file if it exists. If not, the file will be created.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2014a -Login realcajun, netnerds -Path C:\\temp\\logins.sql\r\n\r\nExports ONLY logins netnerds and realcajun FROM sqlserver2014a to the file C:\\temp\\logins.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2014a -Login realcajun, netnerds -Database HR, Accounting\r\n\r\nExports ONLY logins netnerds and realcajun FROM sqlserver2014a with the permissions on databases HR and Accounting\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2008 -Login realcajun, netnerds -Path C:\\temp\\login.sql \r\n-ExcludeGoBatchSeparator\r\n\r\nExports ONLY logins netnerds and realcajun FROM sqlserver2008 server, to the C:\\temp\\login.sql file without the \u0027GO\u0027 \r\nbatch separator.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaLogin -SqlInstance sqlserver2008 -Login realcajun -Path C:\\temp\\users.sql -DestinationVersion \r\nSQLServer2016\r\n\r\nExports login realcajun from sqlsever2008 to the file C:\\temp\\users.sql with syntax to run on SQL Server 2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nExport-DbaPfDataCollectorSetTemplate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[[-CollectorSet] \u003cString[]\u003e] [[-Path] \u003cString\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Path C:\\temp\\pf\r\n\r\nExports all data collector sets from to the C:\\temp\\pf folder.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet ComputerName sql2017 -CollectorSet \u0027System Correlation\u0027 | \r\nExport-DbaPfDataCollectorSetTemplate -Path C:\\temp\r\n\r\nExports the \u0027System Correlation\u0027 data collector set from sql2017 to C:\\temp.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaRegisteredServer", "Description": "Exports registered servers and registered server groups to file", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nExport-DbaRegisteredServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \r\n\u003cObject[]\u003e] [[-Path] \u003cString\u003e] [[-CredentialPersistenceType] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports registered servers and registered server groups to file", "Name": "Export-DbaRegisteredServer", "Links": "https://dbatools.io/Export-DbaRegisteredServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaRegisteredServer -SqlInstance sql2008\r\n\r\nExports all Registered Server and Registered Server Groups on sql2008 to an automatically generated file name in the \r\ncurrent directory\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaRegisteredServer -SqlInstance sql2008 -Group hr\\Seattle -Path C:\\temp\\Seattle.xml\r\n\r\nExports all Registered Server and Registered Server Groups with the Seattle group within the HR group on sql2008 to \r\nC:\\temp\\Seattle.xml\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2008, sql2012 | Export-DbaRegisteredServer\r\n\r\nExports all registered servers on sql2008 and sql2012. Warning - each one will have its own individual file. Consider \r\npiping groups.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sql2008, sql2012 | Export-DbaRegisteredServer\r\n\r\nExports all registered servers on sql2008 and sql2012, organized by group.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaRepServerSetting", "Description": "Exports replication server settings to file.", "Tags": "Replication", "Syntax": "\r\nExport-DbaRepServerSetting [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \r\n\u003cString\u003e] [[-ScriptOption] \u003cObject[]\u003e] [[-InputObject] \u003cReplicationServer[]\u003e] [[-Encoding] \u003cString\u003e] [-Passthru] \r\n[-NoClobber] [-Append] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports replication server settings to file.", "Name": "Export-DbaRepServerSetting", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaRepServerSetting -SqlInstance sql2017 -Path C:\\temp\\replication.sql\r\n\r\nExports the replication settings on sql2017 to the file C:\\temp\\replication.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepServer -SqlInstance sql2017 | Export-DbaRepServerSettings -Path C:\\temp\\replication.sql\r\n\r\nExports the replication settings on sql2017 to the file C:\\temp\\replication.sql\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaScript", "Description": "Exports scripts from SQL Management Objects", "Tags": [ "Migration", "Backup", "Export" ], "Syntax": "\r\nExport-DbaScript [-InputObject] \u003cObject[]\u003e [[-ScriptingOptionsObject] \u003cScriptingOptions\u003e] [[-Path] \u003cString\u003e] \r\n[[-Encoding] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [-NoPrefix] [-Passthru] [-NoClobber] [-Append] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Exports scripts from SQL Management Objects (SMO)", "Name": "Export-DbaScript", "Links": "https://dbatools.io/Export-DbaScript", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 | Export-DbaScript\r\n\r\nExports all jobs on the SQL Server sql2016 instance using a trusted connection - automatically determines filename as \r\n.\\sql2016-Job-Export-date.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 | Export-DbaScript -Path C:\\temp\\export.sql -Append\r\n\r\nExports all jobs on the SQL Server sql2016 instance using a trusted connection - Will append the output to the file \r\nC:\\temp\\export.sql if it already exists\r\nScript does not include Batch Seperator and will not compile\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance sql2016 -Database MyDatabase -Table \u0027dbo.Table1\u0027, \u0027dbo.Table2\u0027 -SqlCredential \r\n(Get-Credential sqladmin) | Export-DbaScript -Path C:\\temp\\export.sql\r\n\r\nExports only script for \u0027dbo.Table1\u0027 and \u0027dbo.Table2\u0027 in MyDatabase to C:temp\\export.sql and uses the SQL login \r\n\"sqladmin\" to login to sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 -Job syspolicy_purge_history, \u0027Hourly Log Backups\u0027 -SqlCredential \r\n(Get-Credential sqladmin) | Export-DbaScript -Path C:\\temp\\export.sql -NoPrefix\r\n\r\nExports only syspolicy_purge_history and \u0027Hourly Log Backups\u0027 to C:temp\\export.sql and uses the SQL login \"sqladmin\" to \r\nlogin to sql2016\r\nSuppress the output of a Prefix\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e#Set Scripting Options\r\n\r\n$options = New-DbaScriptingOption\r\n$options.ScriptSchema = $true\r\n$options.IncludeDatabaseContext = $true\r\n$options.IncludeHeaders = $false\r\n$Options.NoCommandTerminator = $false\r\n$Options.ScriptBatchTerminator = $true\r\n$Options.AnsiFile = $true\r\n\r\nGet-DbaAgentJob -SqlInstance sql2016 -Job syspolicy_purge_history, \u0027Hourly Log Backups\u0027 -SqlCredential sqladmin | \r\nExport-DbaScript -Path C:\\temp\\export.sql -ScriptingOptionsObject $options\r\n\r\nExports only syspolicy_purge_history and \u0027Hourly Log Backups\u0027 to C:temp\\export.sql and uses the SQL login \"sqladmin\" to \r\nlogin to sql2016\r\nAppends a batch separator at end of each script.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2014 | Export-DbaScript -Passthru | ForEach-Object { \r\n$_.Replace(\u0027sql2014\u0027,\u0027sql2016\u0027) } | Set-Content -Path C:\\temp\\export.sql\r\n\r\nExports jobs and replaces all instances of the servername \"sql2014\" with \"sql2016\" then writes to C:\\temp\\export.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e#Set Scripting Options\r\n\r\n$options = New-DbaScriptingOption\r\n$options.ScriptSchema = $true\r\n$options.IncludeDatabaseContext = $true\r\n$options.IncludeHeaders = $false\r\n$Options.NoCommandTerminator = $false\r\n$Options.ScriptBatchTerminator = $true\r\n$Options.AnsiFile = $true\r\n\r\n$Databases = Get-DbaDatabase -SqlInstance sql2016 -ExcludeDatabase master, model, msdb,tempdb\r\n\r\nforeach ($db in $Databases) {\r\n Export-DbaScript -InputObject $db -Path C:\\temp\\export.sql -Append -Encoding UTF8 -ScriptingOptionsObject $options \r\n-NoPrefix\r\n}\r\n\r\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaSpConfigure", "Description": "Exports advanced sp_configure global configuration options to sql file.", "Tags": [ "SpConfig", "Configure", "Configuration" ], "Syntax": "\r\nExport-DbaSpConfigure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaSpConfigure -SqlInstance sourceserver\r\n\r\nExports the SPConfigure settings on sourceserver. As no Path was defined outputs to My Documents folder with default \r\nname format of Servername-MMDDYYYYhhmmss-sp_configure.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaSpConfigure -SqlInstance sourceserver -Path C:\\temp\r\n\r\nExports the SPConfigure settings on sourceserver to the directory C:\\temp using the default name format\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nExport-DbaSpConfigure -SqlInstance sourceserver -SqlCredential $cred -Path C:\\temp\\sp_configure.sql\r\n\r\nExports the SPConfigure settings on sourceserver to the file C:\\temp\\sp_configure.sql. Uses SQL Authentication to \r\nconnect. Will require SysAdmin rights if needs to set \u0027show advanced options\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027Server1\u0027, \u0027Server2\u0027 | Export-DbaSpConfigure -Path C:\\temp\\configure.sql\r\n\r\nExports the SPConfigure settings for Server1 and Server2 using pipeline. As more than 1 Server adds prefix of \r\nServername and date to the file name and saves to file like C:\\temp\\Servername-MMDDYYYYhhmmss-configure.sql\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nExport-DbaUser [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-User] \u003cObject[]\u003e] [[-DestinationVersion] \u003cString\u003e] [[-Path] \u003cString\u003e] [-NoClobber] \r\n[-Append] [-EnableException] [[-ScriptingOptionsObject] \u003cScriptingOptions\u003e] [-ExcludeGoBatchSeparator] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaUser -SqlInstance sql2005 -Path C:\\temp\\sql2005-users.sql\r\n\r\nExports SQL for the users in server \"sql2005\" and writes them to the file \"C:\\temp\\sql2005-users.sql\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2014a $scred -Path C:\\temp\\users.sql -Append\r\n\r\nAuthenticates to sqlserver2014a using SQL Authentication. Exports all users to C:\\temp\\users.sql, and appends to the \r\nfile if it exists. If not, the file will be created.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2014a -User User1, User2 -Path C:\\temp\\users.sql\r\n\r\nExports ONLY users User1 and User2 from sqlsever2014a to the file C:\\temp\\users.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2008 -User User1 -Path C:\\temp\\users.sql -DestinationVersion SQLServer2016\r\n\r\nExports user User1 from sqlsever2008 to the file C:\\temp\\users.sql with syntax to run on SQL Server 2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2008 -Database db1,db2 -Path C:\\temp\\users.sql\r\n\r\nExports ONLY users from db1 and db2 database on sqlserver2008 server, to the C:\\temp\\users.sql file.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$options = New-DbaScriptingOption\r\n\r\n$options.ScriptDrops = $false\r\n$options.WithDependencies = $true\r\n\r\nExport-DbaUser -SqlInstance sqlserver2008 -Database db1,db2 -Path C:\\temp\\users.sql -ScriptingOptionsObject $options\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaUser -SqlInstance sqlserver2008 -Database db1,db2 -Path C:\\temp\\users.sql -ExcludeGoBatchSeparator\r\n\r\nExports ONLY users from db1 and db2 database on sqlserver2008 server, to the C:\\temp\\users.sql file without the \u0027GO\u0027 \r\nbatch separator.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Export-DbaXECsv", "Description": "Exports Extended Events to a CSV file.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nExport-DbaXECsv [-InputObject] \u003cObject[]\u003e [-Path] \u003cString\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Gianluca Sartori (@spaghettidba)", "Synopsis": "Exports Extended Events to a CSV file.", "Name": "Export-DbaXECsv", "Links": "https://dbatools.io/Export-DbaXECsv", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem -Path C:\\temp\\sample.xel | Export-DbaXECsv -Path c:\\temp\\sample.csv\r\n\r\nWrites Extended Events data to the file \"C:\\temp\\events.csv\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2014 -Session deadlocks | Export-DbaXECsv -Path c:\\temp\\events.csv\r\n\r\nWrites Extended Events data to the file \"C:\\temp\\events.csv\".\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nExport-DbaXESessionTemplate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Session] \r\n\u003cObject[]\u003e] [[-Path] \u003cString\u003e] [[-InputObject] \u003cSession[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eExport-DbaXESessionTemplate -SqlInstance sql2017 -Path C:\\temp\\xe\r\n\r\nExports an XESession XML Template for all Extended Event Sessions on sql2017 to the C:\\temp\\xe folder.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 -Session system_health | Export-DbaXESessionTemplate -Path C:\\temp\\xe\r\n\r\nGets the system_health Extended Events Session from sql2017 and then exports as an XESession XML Template to C:\\temp\\xe\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nFind-DbaAgentJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-JobName \u003cString[]\u003e] \r\n[-ExcludeJobName \u003cString[]\u003e] [-StepName \u003cString[]\u003e] [-LastUsed \u003cInt32\u003e] [-IsDisabled] [-IsFailed] [-IsNotScheduled] \r\n[-IsNoEmailNotification] [-Category \u003cString[]\u003e] [-Owner \u003cString\u003e] [-Since \u003cDateTime\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -JobName *backup*\r\n\r\nReturns all agent job(s) that have backup in the name\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01, Dev02 -JobName Mybackup\r\n\r\nReturns all agent job(s) that are named exactly Mybackup\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -LastUsed 10\r\n\r\nReturns all agent job(s) that have not ran in 10 days\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -IsDisabled -IsNoEmailNotification -IsNotScheduled\r\n\r\nReturns all agent job(s) that are either disabled, have no email notification or don\u0027t have a schedule. returned with \r\ndetail\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$servers | Find-DbaAgentJob -IsFailed | Start-DbaAgentJob\r\n\r\nFinds all failed job then starts them. Consider using a -WhatIf at the end of Start-DbaAgentJob to see what it\u0027ll do \r\nfirst\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -LastUsed 10 -Exclude \"Yearly - RollUp Workload\", \"SMS - Notification\"\r\n\r\nReturns all agent jobs that havent ran in the last 10 days ignoring jobs \"Yearly - RollUp Workload\" and \"SMS - \r\nNotification\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01 -Category \"REPL-Distribution\", \"REPL-Snapshot\" -Detailed | Format-Table \r\n-AutoSize -Wrap\r\n\r\nReturns all job/s on Dev01 that are in either category \"REPL-Distribution\" or \"REPL-Snapshot\" with detailed output\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaAgentJob -SqlInstance Dev01, Dev02 -IsFailed -Since \u00272016-07-01 10:47:00\u0027\r\n\r\nReturns all agent job(s) on Dev01 and Dev02 that have failed since July of 2016 (and still have history in msdb)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance CMSServer -Group Production | Find-DbaAgentJob -Disabled -IsNotScheduled | \r\nFormat-Table -AutoSize -Wrap\r\n\r\nQueries CMS server to return all SQL instances in the Production folder and then list out all agent jobs that have \r\neither been disabled or have no schedule.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nFind-DbaBackup [-Path] \u003cString\u003e [-BackupFileExtension] \u003cString\u003e [-RetentionPeriod] \u003cString\u003e [-CheckArchiveBit] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chris Sommer, @cjsommer, www.cjsommer.com", "Synopsis": "Finds SQL Server backups on disk.", "Name": "Find-DbaBackup", "Links": "https://dbatools.io/Find-DbaBackup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaBackup -Path \u0027C:\\MSSQL\\SQL Backup\\\u0027 -BackupFileExtension trn -RetentionPeriod 48h\r\n\r\n\u0027*.trn\u0027 files in \u0027C:\\MSSQL\\SQL Backup\\\u0027 and all subdirectories that are more than 48 hours old will be included.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaBackup -Path \u0027C:\\MSSQL\\Backup\\\u0027 -BackupFileExtension bak -RetentionPeriod 7d -CheckArchiveBit\r\n\r\n\u0027*.bak\u0027 files in \u0027C:\\MSSQL\\Backup\\\u0027 and all subdirectories that are more than 7 days old will be included, but only if \r\nthe files have been backed up to another location as verified by checking the Archive bit.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nFind-DbaCommand [[-Pattern] \u003cString\u003e] [[-Tag] \u003cString[]\u003e] [[-Author] \u003cString\u003e] [[-MinimumVersion] \u003cString\u003e] \r\n[[-MaximumVersion] \u003cString\u003e] [-Rebuild] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Simone Bizzotto", "Synopsis": "Finds dbatools commands searching through the inline help text", "Name": "Find-DbaCommand", "Links": "https://dbatools.io/Find-DbaCommand", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand \"snapshot\"\r\n\r\nFor lazy typers: finds all commands searching the entire help for \"snapshot\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand -Pattern \"snapshot\"\r\n\r\nFor rigorous typers: finds all commands searching the entire help for \"snapshot\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand -Tag copy\r\n\r\nFinds all commands tagged with \"copy\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand -Tag copy,user\r\n\r\nFinds all commands tagged with BOTH \"copy\" and \"user\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand -Author chrissy\r\n\r\nFinds every command whose author contains our beloved \"chrissy\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand -Author chrissy -Tag copy\r\n\r\nFinds every command whose author contains our beloved \"chrissy\" and it tagged as \"copy\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaCommand -Pattern snapshot -Rebuild\r\n\r\nFinds all commands searching the entire help for \"snapshot\", rebuilding the index (good for developers)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nFind-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Property] \u003cString\u003e] \r\n[-Pattern] \u003cString\u003e [-Exact] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabase -SqlInstance \"DEV01\", \"DEV02\", \"UAT01\", \"UAT02\", \"PROD01\", \"PROD02\" -Pattern Report\r\n\r\nReturns all database from the SqlInstances that have a database with Report in the name\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabase -SqlInstance \"DEV01\", \"DEV02\", \"UAT01\", \"UAT02\", \"PROD01\", \"PROD02\" -Pattern TestDB -Exact | \r\nSelect-Object *\r\n\r\nReturns all database from the SqlInstances that have a database named TestDB with a detailed output.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabase -SqlInstance \"DEV01\", \"DEV02\", \"UAT01\", \"UAT02\", \"PROD01\", \"PROD02\" -Property ServiceBrokerGuid \r\n-Pattern \u0027-faeb-495a-9898-f25a782835f5\u0027 | Select-Object *\r\n\r\nReturns all database from the SqlInstances that have the same Service Broker GUID with a detailed output\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Find-DbaDbGrowthEvent", "Description": "Finds any database AutoGrow events in the Default Trace.\n\nThe following events are included:\n 92 - Data File Auto Grow\n 93 - Log File Auto Grow\n 94 - Data File Auto Shrink\n 95 - Log File Auto Shrink", "Tags": [ "AutoGrow", "Growth", "Database" ], "Syntax": "\r\nFind-DbaDbGrowthEvent [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-EventType] \u003cString\u003e] [[-FileType] \u003cString\u003e] [-UseLocalTime] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Aaron Nelson", "Synopsis": "Finds any database AutoGrow events in the Default Trace.", "Name": "Find-DbaDbGrowthEvent", "Links": "https://dbatools.io/Find-DbaDatabaseGrowthEvent", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance localhost\r\n\r\nReturns any database AutoGrow events in the Default Trace with UTC time for the instance for every database on the \r\nlocalhost instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance localhost -UseLocalTime\r\n\r\nReturns any database AutoGrow events in the Default Trace with the local time of the instance for every database on the \r\nlocalhost instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016, ServerA\\SQL2014\r\n\r\nReturns any database AutoGrow events in the Default Traces for every database on ServerA\\sql2016 \u0026 ServerA\\SQL2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016 | Format-Table -AutoSize -Wrap\r\n\r\nReturns any database AutoGrow events in the Default Trace for every database on the ServerA\\SQL2016 instance in a table \r\nformat.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016 -EventType Shrink\r\n\r\nReturns any database Auto Shrink events in the Default Trace for every database on the ServerA\\SQL2016 instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDatabaseGrowthEvent -SqlInstance ServerA\\SQL2016 -EventType Growth -FileType Data\r\n\r\nReturns any database Auto Growth events on data files in the Default Trace for every database on the ServerA\\SQL2016 \r\ninstance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Find-DbaDisabledIndex", "Description": "This command will help you to find disabled indexes on a database or a list of databases.", "Tags": "Index", "Syntax": "\r\nFind-DbaDisabledIndex [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-NoClobber] [-Append] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Jason Squires, sqlnotnull.com", "Synopsis": "Find Disabled indexes", "Name": "Find-DbaDisabledIndex", "Links": "https://dbatools.io/Find-DbadisabledIndex", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbadisabledIndex -SqlInstance sql2005\r\n\r\nGenerates the SQL statements to drop the selected disabled indexes on server \"sql2005\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbadisabledIndex -SqlInstance sqlserver2016 -SqlCredential $cred\r\n\r\nGenerates the SQL statements to drop the selected disabled indexes on server \"sqlserver2016\", using SQL Authentication \r\nto connect to the database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbadisabledIndex -SqlInstance sqlserver2016 -Database db1, db2\r\n\r\nGenerates the SQL Statement to drop selected indexes in databases db1 \u0026 db2 on server \"sqlserver2016\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbadisabledIndex -SqlInstance sqlserver2016\r\n\r\nGenerates the SQL statements to drop selected indexes on all user databases.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\nAlso tells how much space you can save by dropping the index.\n\nWe show the type of compression so you can make a more considered decision.\n\nFor now only supports CLUSTERED and NONCLUSTERED indexes.\n\nYou can select the indexes you want to drop on the gridview and when clicking OK, the DROP statement will be generated.\n\nOutput:\n TableName\n IndexName\n KeyColumns\n IncludedColumns\n IndexSizeMB\n IndexType\n CompressionDescription (When 2008+)\n [RowCount]\n IsDisabled\n IsFiltered (When 2008+)", "Tags": "Index", "Syntax": "\r\nFind-DbaDuplicateIndex [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [-IncludeOverlapping] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Find duplicate and overlapping indexes.", "Name": "Find-DbaDuplicateIndex", "Links": "https://dbatools.io/Find-DbaDuplicateIndex", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sql2005 | Out-File -FilePath C:\\temp\\sql2005-DuplicateIndexes.sql\r\n\r\nGenerates SQL statements to drop the selected duplicate indexes in server \"sql2005\" and writes them to the file \r\n\"C:\\temp\\sql2005-DuplicateIndexes.sql\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sql2005 | Out-File -FilePath C:\\temp\\sql2005-DuplicateIndexes.sql -Append\r\n\r\nGenerates SQL statements to drop the selected duplicate indexes and writes/appends them to the file \r\n\"C:\\temp\\sql2005-DuplicateIndexes.sql\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sqlserver2014a -SqlCredential $cred\r\n\r\nFinds exact duplicate indexes on all user databases present on sqlserver2014a, using SQL authentication.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sqlserver2014a -Database db1, db2\r\n\r\nFinds exact duplicate indexes on the db1 and db2 databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaDuplicateIndex -SqlInstance sqlserver2014a -IncludeOverlapping\r\n\r\nFinds both duplicate and overlapping indexes on all user databases.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 unproblematic 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" ], "Syntax": "\r\nFind-DbaInstance -ComputerName \u003cDbaInstanceParameter[]\u003e [-Credential \u003cPSCredential\u003e] [-SqlCredential \u003cPSCredential\u003e] \r\n[-ScanType {TCPPort | SqlConnect | SqlService | DNSResolve | SPN | Browser | Ping | Default | All}] [-DomainController \r\n\u003cString\u003e] [-TCPPort \u003cInt32[]\u003e] [-MinimumConfidence {None | Low | Medium | High}] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nFind-DbaInstance -DiscoveryType {IPRange | Domain | DataSourceEnumeration | All} [-Credential \u003cPSCredential\u003e] \r\n[-SqlCredential \u003cPSCredential\u003e] [-ScanType {TCPPort | SqlConnect | SqlService | DNSResolve | SPN | Browser | Ping | \r\nDefault | All}] [-IpAddress \u003cString[]\u003e] [-DomainController \u003cString\u003e] [-TCPPort \u003cInt32[]\u003e] [-MinimumConfidence {None | \r\nLow | Medium | High}] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Scott Sutherland, 2018 NetSPI", "Synopsis": "Search for SQL Server Instances.", "Name": "Find-DbaInstance", "Links": "https://dbatools.io/Find-DbaInstance", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaInstance -DiscoveryType Domain,DataSourceEnumeration\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaInstance -DiscoveryType All\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-ADComputer -Filter \"*\" | Find-DbaInstance\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-Content .\\servers.txt | Find-DbaInstance -SqlCredential $cred -ScanType Browser,SqlConnect\r\n\r\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\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "AD", "ActiveDirectory", "Group", "Security" ], "Syntax": "\r\nFind-DbaLoginInGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Finds Logins in Active Directory groups that have logins on the SQL Instance.", "Name": "Find-DbaLoginInGroup", "Links": "https://dbatools.io/Find-DbaLoginInGroup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaLoginInGroup -SqlInstance DEV01 -Login \"MyDomain\\Stephen.Bennett\"\r\n\r\nReturns all active directory groups with logins on Sql Instance DEV01 that contain the AD user Stephen.Bennett.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaLoginInGroup -SqlInstance DEV01\r\n\r\nReturns all active directory users within all windows AD groups that have logins on the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaLoginInGroup -SqlInstance DEV01 | Where-Object Login -like \u0027*stephen*\u0027\r\n\r\nReturns all active directory users within all windows AD groups that have logins on the instance whose login contains \r\n\u0027stephen\u0027\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nFind-DbaOrphanedFile [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cObject\u003e] [[-Path] \u003cString[]\u003e] \r\n[[-FileType] \u003cString[]\u003e] [-LocalOnly] [-RemoteOnly] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sqlserver2014a\r\n\r\nConnects to sqlserver2014a, authenticating with Windows credentials, and searches for orphaned files. Returns server \r\nname, local filename, and unc path to file.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sqlserver2014a -SqlCredential $cred\r\n\r\nConnects to sqlserver2014a, authenticating with SQL Server authentication, and searches for orphaned files. Returns \r\nserver name, local filename, and unc path to file.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014 -Path \u0027E:\\Dir1\u0027, \u0027E:\\Dir2\u0027\r\n\r\nFinds the orphaned files in \"E:\\Dir1\" and \"E:Dir2\" in addition to the default directories.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014 -LocalOnly\r\n\r\nReturns only the local filepaths for orphaned files.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014 -RemoteOnly\r\n\r\nReturns only the remote filepath for orphaned files.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaOrphanedFile -SqlInstance sql2014, sql2016 -FileType fsf, mld\r\n\r\nFinds the orphaned ending with \".fsf\" and \".mld\" in addition to the default filetypes \".mdf\", \".ldf\", \".ndf\" for both \r\nthe servers sql2014 and sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nFind-DbaSimilarTable [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-SchemaName \u003cString\u003e] [-TableName \u003cString\u003e] [-ExcludeViews] [-IncludeSystemDatabases] \r\n[-MatchPercentThreshold \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01\r\n\r\nSearches all user database tables and views for each, returns all tables or views with their matching tables/views and \r\nmatch percent\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks\r\n\r\nSearches AdventureWorks database and lists tables/views and their corresponding matching tables/views with match percent\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -SchemaName HumanResource\r\n\r\nSearches AdventureWorks database and lists tables/views in the HumanResource schema with their corresponding matching \r\ntables/views with match percent\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -SchemaName HumanResource -Table Employee\r\n\r\nSearches AdventureWorks database and lists tables/views in the HumanResource schema and table Employee with its \r\ncorresponding matching tables/views with match percent\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaSimilarTable -SqlInstance DEV01 -Database AdventureWorks -MatchPercentThreshold 60\r\n\r\nSearches AdventureWorks database and lists all tables/views with its corresponding matching tables/views with match \r\npercent greater than or equal to 60\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nFind-DbaStoredProcedure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] -Pattern \u003cString\u003e [-IncludeSystemObjects] [-IncludeSystemDatabases] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance DEV01 -Pattern whatever\r\n\r\nSearches all user databases stored procedures for \"whatever\" in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance sql2016 -Pattern \u0027\\w+@\\w+\\.\\w+\u0027\r\n\r\nSearches all databases for all stored procedures that contain a valid email pattern in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance DEV01 -Database MyDB -Pattern \u0027some string\u0027 -Verbose\r\n\r\nSearches in \"mydb\" database stored procedures for \"some string\" in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaStoredProcedure -SqlInstance sql2016 -Database MyDB -Pattern RUNTIME -IncludeSystemObjects\r\n\r\nSearches in \"mydb\" database stored procedures for \"runtime\" in the textbody\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nFind-DbaTrigger [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] -Pattern \u003cString\u003e [-TriggerLevel \u003cString\u003e] [-IncludeSystemObjects] \r\n[-IncludeSystemDatabases] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Cláudio 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaTrigger -SqlInstance DEV01 -Pattern whatever\r\n\r\nSearches all user databases triggers for \"whatever\" in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaTrigger -SqlInstance sql2016 -Pattern \u0027\\w+@\\w+\\.\\w+\u0027\r\n\r\nSearches all databases for all triggers that contain a valid email pattern in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaTrigger -SqlInstance DEV01 -Database MyDB -Pattern \u0027some string\u0027 -Verbose\r\n\r\nSearches in \"mydb\" database triggers for \"some string\" in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaTrigger -SqlInstance sql2016 -Database MyDB -Pattern RUNTIME -IncludeSystemObjects\r\n\r\nSearches in \"mydb\" database triggers for \"runtime\" in the textbody\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Find-DbaUnusedIndex", "Description": "This command will help you to find Unused indexes on a database or a list of databases\n\nAlso tells how much space you can save by dropping the index.\nWe show the type of compression so you can make a more considered decision.\nFor now only supported for CLUSTERED and NONCLUSTERED indexes\n\nYou can select the indexes you want to drop on the gridview and by clicking OK the drop statement will be generated.", "Tags": "Index", "Syntax": "\r\nFind-DbaUnusedIndex [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-Path] \u003cString\u003e] [-NoClobber] [-Append] [-IgnoreUptime] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Aaron Nelson (@SQLvariant), SQLvariant.com", "Synopsis": "Find Unused indexes", "Name": "Find-DbaUnusedIndex", "Links": "https://dbatools.io/Find-DbaUnusedIndex", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUnusedIndex -SqlInstance sql2005 -Path C:\\temp\\sql2005-UnusedIndexes.sql\r\n\r\nGenerates the SQL statements to drop the selected unused indexes on server \"sql2005\". The statements are written to the \r\nfile \"C:\\temp\\sql2005-UnusedIndexes.sql\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUnusedIndex -SqlInstance sql2005 -Path C:\\temp\\sql2005-UnusedIndexes.sql -Append\r\n\r\nGenerates the SQL statements to drop the selected unused indexes on server \"sql2005\". The statements are written to the \r\nfile \"C:\\temp\\sql2005-UnusedIndexes.sql\", appending if the file already exists.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUnusedIndex -SqlInstance sqlserver2016 -SqlCredential $cred\r\n\r\nGenerates the SQL statements to drop the selected unused indexes on server \"sqlserver2016\", using SQL Authentication to \r\nconnect to the database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUnusedIndex -SqlInstance sqlserver2016 -Database db1, db2\r\n\r\nGenerates the SQL Statement to drop the selected unused indexes in databases db1 \u0026 db2 on server \"sqlserver2016\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUnusedIndex -SqlInstance sqlserver2016\r\n\r\nGenerates the SQL statements to drop the selected unused indexes on all user databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eFine-DbaUnusedIndex -SqlInstance sqlserver2016 -IgnoreUptime\r\n\r\nGenerates the SQL statements to drop the selected unused indexes on all user databases even if the instance has been \r\nonline for less than 7 days.\r\nNote that results may not have enough detail for all indexes, so care should be taken when using them or the generated \r\nscripts. Best practice is to allow a full week to capture the majority of index use cases\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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)\n Database Owner\n Agent Job Owner\n Used in Credential\n USed in Proxy\n SQL Agent Steps using a Proxy\n Endpoints\n Server Roles\n Database Schemas\n Database Roles\n Database Assembles\n Database Synonyms", "Tags": "Object", "Syntax": "\r\nFind-DbaUserObject [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Pattern \u003cString\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/", "Synopsis": "Searches SQL Server to find user-owned objects (ie. 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUserObject -SqlInstance DEV01 -Pattern ad\\stephen\r\n\r\nSearches user objects for owner ad\\stephen\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaUserObject -SqlInstance DEV01 -Verbose\r\n\r\nShows all user owned (non-sa, non-dbo) objects and verbose output\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nFind-DbaView [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] -Pattern \u003cString\u003e [-IncludeSystemObjects] [-IncludeSystemDatabases] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Cláudio 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaView -SqlInstance DEV01 -Pattern whatever\r\n\r\nSearches all user databases views for \"whatever\" in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaView -SqlInstance sql2016 -Pattern \u0027\\w+@\\w+\\.\\w+\u0027\r\n\r\nSearches all databases for all views that contain a valid email pattern in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaView -SqlInstance DEV01 -Database MyDB -Pattern \u0027some string\u0027 -Verbose\r\n\r\nSearches in \"mydb\" database views for \"some string\" in the textbody\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eFind-DbaView -SqlInstance sql2016 -Database MyDB -Pattern RUNTIME -IncludeSystemObjects\r\n\r\nSearches in \"mydb\" database views for \"runtime\" in the textbody\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nFormat-DbaBackupInformation [-BackupHistory] \u003cObject[]\u003e [[-ReplaceDatabaseName] \u003cObject\u003e] [-ReplaceDbNameInFile] \r\n[[-DataFileDirectory] \u003cString\u003e] [[-LogFileDirectory] \u003cString\u003e] [[-DestinationFileStreamDirectory] \u003cString\u003e] \r\n[[-DatabaseNamePrefix] \u003cString\u003e] [[-DatabaseFilePrefix] \u003cString\u003e] [[-DatabaseFileSuffix] \u003cString\u003e] \r\n[[-RebaseBackupFolder] \u003cString\u003e] [-Continue] [[-FileMapping] \u003cHashtable\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$History | Format-DbaBackupInformation -ReplaceDatabaseName NewDb\r\n\r\nChanges as databasename references to NewDb, both in the database name and any restore paths. Note, this will fail if \r\nthe BackupHistory object contains backups for more than 1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$History | Format-DbaBackupInformation -ReplaceDatabaseName @{\u0027OldB\u0027=\u0027NewDb\u0027;\u0027ProdHr\u0027=\u0027DevHr\u0027}\r\n\r\nWill change all occurrences of original database name in the backup history (names and restore paths) using the mapping \r\nin the hashtable.\r\nIn this example any occurence of OldDb will be replaced with NewDb and ProdHr with DevPR\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$History | Format-DbaBackupInformation -DataFileDirectory \u0027D:\\DataFiles\\\u0027 -LogFileDirectory \u0027E:\\LogFiles\\\r\n\r\nThis example with change the restore path for all datafiles (everything that is not a log file) to d:\\datafiles\r\nAnd all Transaction Log files will be restored to E:\\Logfiles\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$History | Formate-DbaBackupInformation -RebaseBackupFolder f:\\backups\r\n\r\nThis example changes the location that SQL Server will look for the backups. This is useful if you\u0027ve moved the backups \r\nto a different location\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgDatabase", "Description": "Default view provides most common set of properties for information on the database in an Availability Group(s).\n\nInformation returned on the database will be specific to that replica, whether it is primary or a secondary.\n\nThis command will return an SMO object, but it is the AvailabilityDatabases object and not the Server.Databases object.", "Tags": [ "Hadr", "AG", "AvailabilityGroup", "Replica" ], "Syntax": "\r\nGet-DbaAgDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \r\n\u003cObject[]\u003e] [[-Database] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton)", "Synopsis": "Outputs the databases involved in the Availability Group(s) found on the server.", "Name": "Get-DbaAgDatabase", "Links": "https://dbatools.io/Get-DbaAgDatabase", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sqlserver2014a\r\n\r\nReturns basic information on all the databases in each Availability Group found on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sqlserver2014a -AvailabilityGroup AG-a\r\n\r\nReturns basic information on all the databases in the Availability Group AG-a on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgDatabase -SqlInstance sqlserver2014a -AvailabilityGroup AG-a -Database AG-Database\r\n\r\nReturns basic information on the database AG-Database found in the Availability Group AG-a on server sqlserver2014a\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgentAlert", "Description": "This function returns SQL Agent alerts.", "Tags": [ "Agent", "SMO" ], "Syntax": "\r\nGet-DbaAgentAlert [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentAlert -SqlInstance ServerA,ServerB\\instanceB\r\n\r\nReturns all SQL Agent alerts on serverA and serverB\\instanceB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027serverA\u0027,\u0027serverB\\instanceB\u0027 | Get-DbaAgentAlert\r\n\r\nReturns all SQL Agent alerts on serverA and serverB\\instanceB\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaAgentJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \r\n\u003cObject[]\u003e] [-NoDisabledJobs] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost\r\n\r\nReturns all SQL Agent Jobs on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost, sql2016\r\n\r\nReturns all SQl Agent Jobs for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost -Job BackupData, BackupDiff\r\n\r\nReturns all SQL Agent Jobs named BackupData and BackupDiff from the local SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost -ExcludeJob BackupDiff\r\n\r\nReturns all SQl Agent Jobs for the local SQL Server instances, except the BackupDiff Job.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance localhost -NoDisabledJobs\r\n\r\nReturns all SQl Agent Jobs for the local SQL Server instances, excluding the disabled jobs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$servers | Get-DbaAgentJob | Out-GridView -Passthru | Start-DbaAgentJob -WhatIf\r\n\r\nFind all of your Jobs from SQL Server instances in the $servers collection, select the jobs you want to start then see \r\njobs would start if you ran Start-DbaAgentJob\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgentJobCategory", "Description": "Get-DbaAgentJobCategory makes it possible to retrieve the job categories.", "Tags": [ "Agent", "Job", "JobCategory" ], "Syntax": "\r\nGet-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \r\n\u003cString[]\u003e] [[-CategoryType] \u003cString\u003e] [-Force] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Get-DbaAgentJobCategory retrieves the job categories.", "Name": "Get-DbaAgentJobCategory", "Links": "https://dbatools.io/Get-DbaAgentJobCategory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobCategory -SqlInstance sql1\r\n\r\nReturn all the job categories.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Log Shipping\u0027\r\n\r\nReturn all the job categories that have the name \u0027Log Shipping\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobCategory -SqlInstance sstad-pc -CategoryType MultiServerJob\r\n\r\nReturn all the job categories that have a type MultiServerJob.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaAgentJobHistory [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-StartDate \r\n\u003cDateTime\u003e] [-EndDate \u003cDateTime\u003e] [-NoJobSteps] [-WithOutputFile] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaAgentJobHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] \r\n[-ExcludeJob \u003cObject[]\u003e] [-StartDate \u003cDateTime\u003e] [-EndDate \u003cDateTime\u003e] [-NoJobSteps] [-WithOutputFile] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaAgentJobHistory [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] [-ExcludeJob \u003cObject[]\u003e] [-StartDate \r\n\u003cDateTime\u003e] [-EndDate \u003cDateTime\u003e] [-NoJobSteps] [-WithOutputFile] -JobCollection \u003cJob\u003e [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets execution history of SQL Agent Job on instance(s) of SQL Server.", "Name": "Get-DbaAgentJobHistory", "Links": "https://dbatools.io/Get-DbaAgentJobHistory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance localhost\r\n\r\nReturns all SQL Agent Job execution results on the local default SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance localhost, sql2016\r\n\r\nReturns all SQL Agent Job execution results for the local and sql2016 SQL Server instances.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\\Inst2K17\u0027 | Get-DbaAgentJobHistory\r\n\r\nReturns all SQL Agent Job execution results for sql1 and sql2\\Inst2K17.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 | select *\r\n\r\nReturns all properties for all SQl Agent Job execution results on sql2\\Inst2K17.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -Job \u0027Output File Cleanup\u0027\r\n\r\nReturns all properties for all SQl Agent Job execution results of the \u0027Output File Cleanup\u0027 job on sql2\\Inst2K17.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -Job \u0027Output File Cleanup\u0027 -WithOutputFile\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -NoJobSteps\r\n\r\nReturns the SQL Agent Job execution results for the whole jobs on sql2\\Inst2K17, leaving out job step execution results.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobHistory -SqlInstance sql2\\Inst2K17 -StartDate \u00272017-05-22\u0027 -EndDate \u00272017-05-23 12:30:00\u0027\r\n\r\nReturns the SQL Agent Job execution results between 2017/05/22 00:00:00 and 2017/05/23 12:30:00 on sql2\\Inst2K17.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 | Where Name -match backup | Get-DbaAgentJobHistory\r\n\r\nGets all jobs with the name that match the regex pattern \"backup\" and then gets the job history from those. You can \r\nalso use -Like *backup* in this example.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaAgentJobOutputFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] \r\n[-ExcludeJob \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Rob Sewell (https://sqldbawithabeard.com)", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Job \u0027The Agent Job\u0027\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME,SERVERNAME2 -Job \u0027The Agent Job\u0027\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$Servers = \u0027SERVER\u0027,\u0027SERVER\\INSTANCE1\u0027\r\n\r\nGet-DbaAgentJobOutputFile -SqlInstance $Servers -Job \u0027The Agent Job\u0027 -OpenFile\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME | Out-GridView\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e(Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME | Out-GridView -PassThru).FileName | Invoke-Item\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Verbose\r\n\r\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] \r\n[-ExcludeJob \u003cObject[]\u003e] [-NoDisabledJobs] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost\r\n\r\nReturns all SQL Agent Job Steps on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost, sql2016\r\n\r\nReturns all SQL Agent Job Steps for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost -Job BackupData, BackupDiff\r\n\r\nReturns all SQL Agent Job Steps for the jobs named BackupData and BackupDiff from the local SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost -ExcludeJob BackupDiff\r\n\r\nReturns all SQL Agent Job Steps for the local SQL Server instances, except for the BackupDiff Job.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJobStep -SqlInstance localhost -NoDisabledJobs\r\n\r\nReturns all SQL Agent Job Steps for the local SQL Server instances, excluding the disabled jobs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$servers | Get-DbaAgentJobStep\r\n\r\nFind all of your Job Steps from SQL Server instances in the $servers collection\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgentLog", "Description": "Gets the \"SQL Agent Error Log\" of an instance. Returns all 10 error logs by default.", "Tags": "Logging", "Syntax": "\r\nGet-DbaAgentLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-LogNumber] \u003cInt32[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentLog -SqlInstance sql01\\sharepoint\r\n\r\nReturns the entire error log for the SQL Agent on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentLog -SqlInstance sql01\\sharepoint -LogNumber 3, 6\r\n\r\nReturns log numbers 3 and 6 for the SQL Agent on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaAgentLog -LogNumber 0\r\n\r\nReturns the most recent SQL Agent error logs for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgentOperator", "Description": "This function returns SQL Agent operators.", "Tags": [ "Agent", "Operator" ], "Syntax": "\r\nGet-DbaAgentOperator [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Operator \u003cObject[]\u003e] \r\n[-ExcludeOperator \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentOperator -SqlInstance ServerA,ServerB\\instanceB\r\n\r\nReturns any SQL Agent operators on serverA and serverB\\instanceB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027ServerA\u0027,\u0027ServerB\\instanceB\u0027 | Get-DbaAgentOperator\r\n\r\nReturns all SQL Agent operators on serverA and serverB\\instanceB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentOperator -SqlInstance ServerA -Operator Dba1,Dba2\r\n\r\nReturns only the SQL Agent Operators Dba1 and Dba2 on ServerA.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentOperator -SqlInstance ServerA,ServerB -ExcludeOperator Dba3\r\n\r\nReturns all the SQL Agent operators on ServerA and ServerB, except the Dba3 operator.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgentProxy", "Description": "This function returns SQL Agent proxies.", "Tags": [ "Agent", "SMO" ], "Syntax": "\r\nGet-DbaAgentProxy [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Proxy \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentProxy -SqlInstance ServerA,ServerB\\instanceB\r\n\r\nReturns all SQL Agent proxies on serverA and serverB\\instanceB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027serverA\u0027,\u0027serverB\\instanceB\u0027 | Get-DbaAgentProxy\r\n\r\nReturns all SQL Agent proxies on serverA and serverB\\instanceB\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgentSchedule", "Description": "This function returns SQL Agent Shared Schedules.", "Tags": [ "Agent", "Schedule" ], "Syntax": "\r\nGet-DbaAgentSchedule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Schedule \u003cObject[]\u003e] [-SqlCredential \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance localhost\r\n\r\nReturns all SQL Agent Shared Schedules on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance localhost, sql2016\r\n\r\nReturns all SQL Agent Shared Schedules for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "AG", "AvailabilityGroup" ], "Syntax": "\r\nGet-DbaAgHadr [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton | http://blog.wsmelton.info)", "Synopsis": "Gets the Hadr service setting on the specified SQL Server instance.", "Name": "Get-DbaAgHadr", "Links": "https://dbatools.io/Get-DbaAgHadr", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgHadr -SqlInstance sql2016\r\n\r\nReturns a status of the Hadr setting for sql2016 SQL Server instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgListener", "Description": "Default view provides most common set of properties for information on the database in an Availability Group(s).\n\nInformation returned on the database will be specific to that replica, whether it is primary or a secondary.\n\nThis command will return an SMO object, but it is the AvailabilityDatabases object and not the Server.Databases object.", "Tags": [ "AG", "AvailabilityGroup", "Listener" ], "Syntax": "\r\nGet-DbaAgListener [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \r\n\u003cString[]\u003e] [[-Listener] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Viorel Ciucu (@viorelciucu)", "Synopsis": "Outputs the name of the Listener for the Availability Group(s) found on the server.", "Name": "Get-DbaAgListener", "Links": "https://dbatools.io/Get-DbaAgListener", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgListener -SqlInstance sqlserver2014a\r\n\r\nReturns basic information on the listener found on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgListener -SqlInstance sqlserver2014a -AvailabilityGroup AG-a\r\n\r\nReturns basic information on the listener found on sqlserver2014a in the Availability Group AG-a\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAgReplica", "Description": "Default view provides most common set of properties for information on the Availability Group(s)\u0027 Replica.", "Tags": [ "AG", "AvailabilityGroup", "Replica" ], "Syntax": "\r\nGet-DbaAgReplica [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-AvailabilityGroup] \r\n\u003cObject[]\u003e] [[-Replica] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton) | Chrissy LeMaire (@ctrlb)", "Synopsis": "Outputs the Availability Group(s)\u0027 Replica object found on the server.", "Name": "Get-DbaAgReplica", "Links": "https://dbatools.io/Get-DbaAgReplica", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sqlserver2014a\r\n\r\nReturns basic information on all the Availability Group(s) replica(s) found on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sqlserver2014a -AvailabilityGroup AG-a\r\n\r\nShows basic information on the replica(s) found on Availability Group AG-a on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgReplica -SqlInstance sqlserver2014a | Select *\r\n\r\nReturns full object properties on all Availability Group(s) replica(s) on sqlserver2014a\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaAvailabilityGroup", "Description": "Default view provides most common set of properties for information on the Availability Group(s).", "Tags": [ "Hadr", "AG", "AvailabilityGroup" ], "Syntax": "\r\nGet-DbaAvailabilityGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[[-AvailabilityGroup] \u003cObject[]\u003e] [-IsPrimary] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton) | Chrissy LeMaire (@ctrlb)", "Synopsis": "Outputs the Availability Group(s) object found on the server.", "Name": "Get-DbaAvailabilityGroup", "Links": "https://dbatools.io/Get-DbaAvailabilityGroup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a\r\n\r\nReturns basic information on all the Availability Group(s) found on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a -AvailabilityGroup AG-a\r\n\r\nShows basic information on the Availability Group AG-a on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a | Select *\r\n\r\nReturns full object properties on all Availability Group(s) on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAvailabilityGroup -SqlInstance sqlserver2014a -AvailabilityGroup AG-a -IsPrimary\r\n\r\nReturns true/false if the server, sqlserver2014a, is the primary replica for AG-a Availability Group.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaAvailableCollation [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAvailableCollation -SqlInstance sql2016\r\n\r\nGets all the collations from server sql2016 using NT authentication\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaBackupDevice", "Description": "The Get-DbaBackupDevice command gets SQL Backup Device information for each instance(s) of SQL Server.", "Tags": "Backup", "Syntax": "\r\nGet-DbaBackupDevice [-SqlInstance] \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupDevice -SqlInstance localhost\r\n\r\nReturns all Backup Devices on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupDevice -SqlInstance localhost, sql2016\r\n\r\nReturns all Backup Devices for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \r\n\u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Force] [-Since \u003cDateTime\u003e] [-DeviceType \u003cString[]\u003e] [-Raw] [-LastLsn \r\n\u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaBackupHistory -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-IncludeCopyOnly] [-Last] [-LastFull] [-LastDiff] [-LastLog] [-DeviceType \u003cString[]\u003e] \r\n[-Raw] [-LastLsn \u003cBigInteger\u003e] [-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Returns backup history details for databases on a SQL Server.", "Name": "Get-DbaBackupHistory", "Links": "https://dbatools.io/Get-DbaBackupHistory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance SqlInstance2014a\r\n\r\nReturns server name, database, username, backup type, date for all database backups still in msdb history on \r\nSqlInstance2014a. This may return many rows; consider using filters that are included in other examples.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nGet-DbaBackupHistory -SqlInstance SqlInstance2014a -SqlCredential $cred\r\n\r\nDoes the same as above but connect to SqlInstance2014a as SQL user \"sqladmin\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance SqlInstance2014a -Database db1, db2 -Since \u00272016-07-01 10:47:00\u0027\r\n\r\nReturns backup information only for databases db1 and db2 on SqlInstance2014a since July 1, 2016 at 10:47 AM.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014, pubs -Force | Format-Table\r\n\r\nReturns information only for AdventureWorks2014 and pubs and formats the results as a table.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Last\r\n\r\nReturns information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Last -DeviceType Disk\r\n\r\nReturns information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014, but \r\nonly for backups to disk.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Last -DeviceType 148,107\r\n\r\nReturns information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014, but \r\nonly for backups with device_type 148 and 107.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -LastFull\r\n\r\nReturns information about the most recent full backup for AdventureWorks2014 on sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance sql2014 -Database AdventureWorks2014 -Type Full\r\n\r\nReturns information about all Full backups for AdventureWorks2014 on sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2016 | Get-DbaBackupHistory\r\n\r\nReturns database backup information for every database on every server listed in the Central Management Server on \r\nsql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 11 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupHistory -SqlInstance SqlInstance2014a, sql2016 -Force\r\n\r\nReturns detailed backup history for all databases on SqlInstance2014a and sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaBackupInformation -Path \u003cObject[]\u003e -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] \r\n[-DatabaseName \u003cString[]\u003e] [-SourceInstance \u003cString[]\u003e] [-NoXpDirTree] [-DirectoryRecurse] [-EnableException] \r\n[-MaintenanceSolution] [-IgnoreLogBackup] [-ExportPath \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-Anonymise] [-NoClobber] \r\n[-PassThru] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaBackupInformation -Path \u003cObject[]\u003e [-DatabaseName \u003cString[]\u003e] [-SourceInstance \u003cString[]\u003e] [-EnableException] \r\n[-MaintenanceSolution] [-IgnoreLogBackup] [-ExportPath \u003cString\u003e] [-AzureCredential \u003cString\u003e] [-Import] [-Anonymise] \r\n[-NoClobber] [-PassThru] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Scan backup files and creates a set, compatible with Restore-DbaDatabase", "Name": "Get-DbaBackupInformation", "Links": "https://dbatools.io/Get-DbaBackupInformation", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupInformation -SqlInstance Server1 -Path c:\\backups\\ -DirectoryRecurse\r\n\r\nWill use the Server1 instance to recursively read all backup files under c:\\backups, and return a dbatools \r\nBackupHistory object\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupInformation -SqlInstance Server1 -Path c:\\backups\\ -DirectoryRecurse -ExportPath \r\nc:\\store\\BackupHistory.xml\r\n\r\n#Copy the file c:\\store\\BackupHistory.xml to another machine via preferred technique, and the on 2nd machine:\r\n\r\nGet-DbaBackupInformation -Import -Path c:\\store\\BackupHistory.xml | Restore-DbaDatabase -SqlInstance Server2 \r\n-TrustDbBackupHistory\r\n\r\nThis allows you to move backup history across servers, or to preserve backup history even after the original server has \r\nbeen purged\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBackupInformation -SqlInstance Server1 -Path c:\\backups\\ -DirectoryRecurse -ExportPath \r\nc:\\store\\BackupHistory.xml -PassThru |\r\n\r\nRestore-DbaDatabase -SqlInstance Server2 -TrustDbBackupHistory\r\n\r\nIn this example we gather backup information, export it to an xml file, and then pass it on through to \r\nRestore-DbaDatabase\r\nThis allows us to repeat the restore without having to scan all the backup files again\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem c:\\backups\\ -recurse -files |\r\n\r\nWhere {$_.extension -in (\u0027.bak\u0027,\u0027.trn\u0027) -and $_.LastWriteTime -gt (get-date).AddMonths(-1)} |\r\n Get-DbaBackupInformation -SqlInstance Server1 -ExportPath c:\\backupHistory.xml\r\n\r\nThis lets you keep a record of all backup history from the last month on hand to speed up refreshes\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\network\\backups\r\n\r\n$Backups += Get-DbaBackupInformation -SqlInstance Server2 -NoXpDirTree -Path c:\\backups\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\network\\backups -MaintenanceSolution\r\n\r\nWhen MaintenanceSolution is indicated we know we are dealing with the output from Ola Hallengren\u0027s backup scripts. So \r\nwe make sure that a FULL folder exists in the first level of Path, if not we shortcut scanning all the files as we have \r\nnothing to work with\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\network\\backups -MaintenanceSolution \r\n-IgnoreLogBackup\r\n\r\nAs we know we are dealing with an Ola Hallengren style backup folder from the MaintenanceSolution switch, when \r\nIgnoreLogBackup is also included we can ignore the LOG folder to skip any scanning of log backups. Note this also means \r\nthey WON\u0027T be restored\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 Lifecycle Policy", "Tags": "SqlBuild", "Syntax": "\r\nGet-DbaBuildReference [[-Build] \u003cVersion[]\u003e] [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [-Update] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Returns SQL Server Build infos on a SQL instance", "Name": "Get-DbaBuildReference", "Links": "https://dbatools.io/Get-DbaBuildReference", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBuildReference -Build \"12.00.4502\"\r\n\r\nReturns information about a build identified by \"12.00.4502\" (which is SQL 2014 with SP1 and CU11)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBuildReference -Build \"12.00.4502\" -Update\r\n\r\nReturns information about a build trying to fetch the most up to date index online. When the online version is newer, \r\nthe local one gets overwritten\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaBuildReference -Build \"12.0.4502\",\"10.50.4260\"\r\n\r\nReturns information builds identified by these versions strings\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a | Get-DbaBuildReference\r\n\r\nIntegrate with other commandlets to have builds checked for all your registered servers on sqlserver2014a\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaClientAlias", "Description": "Gets SQL Server alias by reading HKLM:\\SOFTWARE\\Microsoft\\MSSQLServer\\Client", "Tags": "Alias", "Syntax": "\r\nGet-DbaClientAlias [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClientAlias\r\n\r\nGets all SQL Server client aliases on the local computer\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClientAlias -ComputerName workstationx\r\n\r\nGets all SQL Server client aliases on Workstationx\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027Server1\u0027, \u0027Server2\u0027 | Get-DbaClientAlias\r\n\r\nGets all SQL Server client aliases on Server1 and Server2\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaClientProtocol [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClientProtocol -ComputerName sqlserver2014a\r\n\r\nGets the SQL Server related client protocols on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaClientProtocol\r\n\r\nGets the SQL Server related client protocols on computers sql1, sql2 and sql3.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClientProtocol -ComputerName sql1,sql2 | Out-Gridview\r\n\r\nGets the SQL Server related client protocols on computers sql1 and sql2, and shows them in a grid view.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e(Get-DbaClientProtocol -ComputerName sql2 | Where { $_.DisplayName = \u0027via\u0027 }).Disable()\r\n\r\nDisables the VIA ClientNetworkProtocol on computer sql2.\r\nIf successful, returncode 0 is shown.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaClusterNode", "Description": "Returns the name of the current node(s) in the SQL Server cluster.\n\nIf the -ActiveNode Parameter is passed it only returns the name of the Server currently hosting the clustered instance.", "Tags": [ "Cluster", "WSFC", "FCI" ], "Syntax": "\r\nGet-DbaClusterNode [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-ActiveNode] [-Detailed] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns the node(s) of a SQL Cluster.", "Name": "Get-DbaClusterNode", "Links": "https://dbatools.io/Get-DbaClusterNode", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClusterNode -SqlInstance sqlcluster\r\n\r\nReturns all nodes in the cluster and details about each node.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClusterNode -SqlInstance sqlcluster -ActiveNode\r\n\r\nReturns the name of the active node in the cluster\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaCmConnection", "Description": "Retrieves windows management connections from the cache", "Tags": [ "ComputerManagement", "CIM" ], "Syntax": "\r\nGet-DbaCmConnection [[-ComputerName] \u003cString[]\u003e] [-UserName \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "Retrieves windows management connections from the cache", "Name": "Get-DbaCmConnection", "Links": "https://dbatools.io/Get-DbaCmConnection", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection\r\n\r\nList all cached connections.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection sql2014\r\n\r\nList the cached connection - if any - to the server sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection -UserName \"*charles*\"\r\n\r\nList all cached connection that use a username containing \"charles\" as default or override credentials.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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-DbaWmConnection.", "Tags": [ "ComputerManagement", "CIM" ], "Syntax": "\r\nGet-DbaCmObject [-ClassName] \u003cString\u003e [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] \r\n[-Namespace \u003cString\u003e] [-DoNotUse {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-Force] [-SilentlyContinue] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaCmObject [-Query] \u003cString\u003e [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-Namespace \r\n\u003cString\u003e] [-DoNotUse {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-Force] [-SilentlyContinue] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "Retrieves Wmi/Cim-Style information from computers.", "Name": "Get-DbaCmObject", "Links": "https://dbatools.io/Get-DbaCmObject", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmObject win32_OperatingSystem\r\n\r\nRetrieves the common operating system information from the local computer.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmObject -Computername \"sql2014\" -ClassName Win32_OperatingSystem -Credential $cred -DoNotUse CimRM\r\n\r\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 \r\ndefault to windows credentials (unless another default has been set).\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaComputerCertificate", "Description": "Gets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption", "Tags": "Certificate", "Syntax": "\r\nGet-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Store] \r\n\u003cString\u003e] [[-Folder] \u003cString\u003e] [[-Path] \u003cString\u003e] [[-Thumbprint] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerCertificate\r\n\r\nGets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerCertificate -ComputerName sql2016\r\n\r\nGets computer certificates on sql2016 that are candidates for using with SQL Server\u0027s network encryption\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerCertificate -ComputerName sql2016 -Thumbprint 8123472E32AB412ED4288888B83811DB8F504DED, \r\n04BFF8B3679BB01A986E097868D8D494D70A46D6\r\n\r\nGets computer certificates on sql2016 that match thumbprints 8123472E32AB412ED4288888B83811DB8F504DED or \r\n04BFF8B3679BB01A986E097868D8D494D70A46D6\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaComputerSystem", "Description": "Gets computer system information from the server and returns as an object.", "Tags": "ServerInfo", "Syntax": "\r\nGet-DbaComputerSystem [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-IncludeAws] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton | http://blog.wsmelton.info)", "Synopsis": "Gets computer system information from the server.", "Name": "Get-DbaComputerSystem", "Links": "https://dbatools.io/Get-DbaComputerSystem", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerSystem\r\n\r\nReturns information about the local computer\u0027s computer system\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerSystem -ComputerName sql2016\r\n\r\nReturns information about the sql2016\u0027s computer system\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerSystem -ComputerName sql2016 -IncludeAws\r\n\r\nReturns information about the sql2016\u0027s computer system and includes additional properties around the EC2 instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaConnection [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaConnection -SqlInstance sql2016, sql2017\r\n\r\nReturns client connection information from sql2016 and sql2017\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 destionation server but the process\ncolumn is specific to -SqlInstance passed.", "Tags": "CPU", "Syntax": "\r\nGet-DbaCpuUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [[-Threshold] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCpuUsage -SqlInstance sql2017\r\n\r\nLogs into the SQL Server instance \"sql2017\" and also the Computer itself (via WMI) to gather information\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$usage = Get-DbaCpuUsage -SqlInstance sql2017\r\n\r\n$usage.Process\r\n\r\nExplores the processes (from Get-DbaProcess) associated with the usage results\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCpuUsage -SqlInstance sql2017 -SqlCredential (Get-Credential sqladmin) -Credential (Get-Credential \r\nad\\sqldba)\r\n\r\nLogs into the SQL instance using the SQL Login \u0027sqladmin\u0027 and then Windows instance as \u0027ad\\sqldba\u0027\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaCredential", "Description": "The Get-DbaCredential command gets SQL Credential information for each instance(s) of SQL Server.", "Tags": "Credential", "Syntax": "\r\nGet-DbaCredential [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Name \u003cString[]\u003e] \r\n[-ExcludeName \u003cString[]\u003e] [-Identity \u003cString[]\u003e] [-ExcludeIdentity \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCredential -SqlInstance localhost\r\n\r\nReturns all SQL Credentials on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCredential -SqlInstance localhost, sql2016 -Name \u0027PowerShell Proxy\u0027\r\n\r\nReturns the SQL Credentials named \u0027PowerShell Proxy\u0027 for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCredential -SqlInstance localhost, sql2016 -Identity ad\\powershell\r\n\r\nReturns the SQL Credentials for the account \u0027ad\\powershell\u0027 on the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaCustomError", "Description": "The Get-DbaCustomError command gets SQL Custom Error Message information for each instance(s) of SQL Server.", "Tags": "CustomError", "Syntax": "\r\nGet-DbaCustomError [-SqlInstance] \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCustomError -SqlInstance localhost\r\n\r\nReturns all Custom Error Message(s) on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCustomError -SqlInstance localhost, sql2016\r\n\r\nReturns all Custom Error Message(s) for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-ExcludeAllUserDb] [-ExcludeAllSystemDb] [-Owner \u003cString[]\u003e] [-Encrypted] [-Status \r\n\u003cString[]\u003e] [-Access \u003cString\u003e] [-RecoveryModel \u003cString[]\u003e] [-NoFullBackup] [-NoFullBackupSince \u003cDateTime\u003e] \r\n[-NoLogBackup] [-NoLogBackupSince \u003cDateTime\u003e] [-EnableException] [-IncludeLastUsed] [-OnlyAccessible] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Garry Bargsley (@gbargsley | http://blog.garrybargsley.com)", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance localhost\r\n\r\nReturns all databases on the local default SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance localhost -ExcludeAllUserDb\r\n\r\nReturns only the system databases on the local default SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance localhost -ExcludeAllSystemDb\r\n\r\nReturns only the user databases on the local default SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027,\u0027sql2016\u0027 | Get-DbaDatabase\r\n\r\nReturns databases on multiple instances piped into the function.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress -RecoveryModel full,Simple\r\n\r\nReturns only the user databases in Full or Simple recovery model from SQL Server instance SQL1\\SQLExpress.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress -Status Normal\r\n\r\nReturns only the user databases with status \u0027normal\u0027 from SQL Server instance SQL1\\SQLExpress.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress -IncludeLastUsed\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress,SQL2 -ExcludeDatabase model,master\r\n\r\nReturns all databases except master and model from SQL Server instances SQL1\\SQLExpress and SQL2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress,SQL2 -Encrypted\r\n\r\nReturns only databases using TDE from SQL Server instances SQL1\\SQLExpress and SQL2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL1\\SQLExpress,SQL2 -Access ReadOnly\r\n\r\nReturns only read only databases from SQL Server instances SQL1\\SQLExpress and SQL2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 11 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance SQL2,SQL3 -Database OneDB,OtherDB\r\n\r\nReturns databases \u0027OneDb\u0027 and \u0027OtherDB\u0027 from SQL Server instances SQL2 and SQL3 if databases by those names exist on \r\nthose instances.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbAssembly", "Description": "The Get-DbaDbAssembly command gets SQL Database Assembly information for each instance(s) of SQL Server.", "Tags": [ "Assembly", "Database" ], "Syntax": "\r\nGet-DbaDbAssembly [-SqlInstance] \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbAssembly -SqlInstance localhost\r\n\r\nReturns all Database Assembly on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbAssembly -SqlInstance localhost, sql2016\r\n\r\nReturns all Database Assembly for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbCertificate", "Description": "Gets database certificates", "Tags": "Certificate", "Syntax": "\r\nGet-DbaDbCertificate [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-Certificate] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets database certificates", "Name": "Get-DbaDbCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance sql2016\r\n\r\nGets all certificates\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance Server1 -Database db1\r\n\r\nGets the certificate for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCertificate -SqlInstance Server1 -Database db1 -Certificate cert1\r\n\r\nGets the cert1 certificate within the db1 database\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbCheckConstraint", "Description": "Gets database Checks constraints.", "Tags": "Database", "Syntax": "\r\nGet-DbaDbCheckConstraint [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemTable] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Cláudio Silva ( @ClaudioESSilva | https://claudioessilva.eu)", "Synopsis": "Gets database Check constraints.", "Name": "Get-DbaDbCheckConstraint", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance sql2016\r\n\r\nGets all database check constraints.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance Server1 -Database db1\r\n\r\nGets the check constraints for the db1 database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the check constraints for all databases except db1.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCheckConstraint -SqlInstance Server1 -ExcludeSystemTable\r\n\r\nGets the check constraints for all databases that are not system objects.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbCheckConstraint\r\n\r\nGets the check constraints for the databases on Sql1 and Sql2/sqlexpress.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDbCompression [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Jess Pomfret (@jpomfret jesspomfret.com)", "Synopsis": "Gets tables and indexes size and current compression settings.", "Name": "Get-DbaDbCompression", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCompression -SqlInstance localhost\r\n\r\nReturns objects size and current compression level for all user databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCompression -SqlInstance localhost -Database TestDatabase\r\n\r\nReturns objects size and current compression level for objects within the TestDatabase database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbCompression -SqlInstance localhost -ExcludeDatabase TestDatabases\r\n\r\nReturns objects size and current compression level for objects in all databases except the TestDatabase database.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDbEncryption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01\r\n\r\nList all encryption found on the instance by database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01 -Database MyDB\r\n\r\nList all encryption found for the MyDB database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01 -ExcludeDatabase MyDB\r\n\r\nList all encryption found for all databases except MyDB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbEncryption -SqlInstance DEV01 -IncludeSystemDBs\r\n\r\nList all encryption found for all databases including the system databases.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDbExtentDiff [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Viorel Ciucu, viorel.ciucu@gmail.com, 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet the changes for the DBA database.\r\n\r\nGet-DbaDbExtentDiff -SqlInstance SQL2016 -Database DBA\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet the changes for the DB01 database on multiple servers.\r\n\r\nGet-DbaDbExtentDiff -SqlInstance $SQL2017N1, $SQL2017N2, $SQL2016 -Database DB01 -SqlCredential $Cred\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbFile", "Description": "Returns detailed information about database files. Does not use SMO - SMO causes enumeration and this command avoids that.", "Tags": "Database", "Syntax": "\r\nGet-DbaDbFile [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-InputObject \r\n\u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaDbFile -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-InputObject \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Returns detailed information about database files.", "Name": "Get-DbaDbFile", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbFile -SqlInstance sql2016\r\n\r\nWill return an object containing all filegroups and their contained files for every database on the sql2016 SQL Server \r\ninstance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbFile -SqlInstance sql2016 -Database Impromptu\r\n\r\nWill return an object containing all filegroups and their contained files for the Impromptu Database on the sql2016 SQL \r\nServer instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbFile -SqlInstance sql2016 -Database Impromptu, Trading\r\n\r\nWill return an object containing all filegroups and their contained files for the Impromptu and Trading databases on \r\nthe sql2016 SQL Server instance\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbForeignKey", "Description": "Gets database Foreign Keys.", "Tags": [ "Database", "ForeignKey", "Table" ], "Syntax": "\r\nGet-DbaDbForeignKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemTable] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Cláudio Silva ( @ClaudioESSilva | https://claudioessilva.eu)", "Synopsis": "Gets database Foreign Keys.", "Name": "Get-DbaDbForeignKey", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance sql2016\r\n\r\nGets all database Foreign Keys.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance Server1 -Database db1\r\n\r\nGets the Foreign Keys for the db1 database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the Foreign Keys for all databases except db1.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbForeignKey -SqlInstance Server1 -ExcludeSystemTable\r\n\r\nGets the Foreign Keys from all tables that are not system objects from all databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbForeignKey\r\n\r\nGets the Foreign Keys for the databases on Sql1 and Sql2/sqlexpress.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMail", "Description": "Gets the database mail from SQL Server", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMail [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the database mail from SQL Server", "Name": "Get-DbaDbMail", "Links": "https://dbatools.io/Get-DbaDbMail", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMail -SqlInstance sql01\\sharepoint\r\n\r\nReturns the db mail server object on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMail -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the db mail server object on sql01\\sharepoint then return a bunch more columns\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMail\r\n\r\nReturns the db mail server object for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMailAccount", "Description": "Gets database mail accounts from SQL Server", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMailAccount [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Account] \r\n\u003cString[]\u003e] [[-ExcludeAccount] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets database mail accounts from SQL Server", "Name": "Get-DbaDbMailAccount", "Links": "https://dbatools.io/Get-DbaDbMailAccount", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailAccount -SqlInstance sql01\\sharepoint\r\n\r\nReturns dbmail accounts on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailAccount -SqlInstance sql01\\sharepoint -Account \u0027The DBA Team\u0027\r\n\r\nReturns The DBA Team dbmail account from sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailAccount -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the dbmail accounts on sql01\\sharepoint then return a bunch more columns\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMail | Get-DbaDbMailAccount\r\n\r\nReturns the db dbmail accounts for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMailConfig", "Description": "Gets database mail configs from SQL Server", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMailConfig [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] \r\n[[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets database mail configs from SQL Server", "Name": "Get-DbaDbMailConfig", "Links": "https://dbatools.io/Get-DbaDbMailConfig", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailConfig -SqlInstance sql01\\sharepoint\r\n\r\nReturns dbmail configs on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailConfig -SqlInstance sql01\\sharepoint -Name ProhibitedExtensions\r\n\r\nReturns the ProhibitedExtensions configuration on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailConfig -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the dbmail configs on sql01\\sharepoint then return a bunch more columns\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMail | Get-DbaDbMailConfig\r\n\r\nReturns the dbmail configs for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMailHistory", "Description": "Gets the history of mail sent from a SQL instance", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMailHistory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Since] \u003cDateTime\u003e] \r\n[[-Status] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailHistory -SqlInstance sql01\\sharepoint\r\n\r\nReturns the entire dbmail history on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailHistory -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the entire dbmail history on sql01\\sharepoint then return a bunch more columns\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMailHistory\r\n\r\nReturns the all dbmail history for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMailLog", "Description": "Gets the DBMail log from a SQL instance", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMailLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Since] \u003cDateTime\u003e] \r\n[[-Type] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailLog -SqlInstance sql01\\sharepoint\r\n\r\nReturns the entire dbmail log on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailLog -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the entire dbmail log on sql01\\sharepoint, includes all returned information.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMailLog -Type Error, Information\r\n\r\nReturns only the Error and Information dbmail log for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMailProfile", "Description": "Gets database mail profiles from SQL Server", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMailProfile [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Profile] \r\n\u003cString[]\u003e] [[-ExcludeProfile] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets database mail profiles from SQL Server", "Name": "Get-DbaDbMailProfile", "Links": "https://dbatools.io/Get-DbaDbMailProfile", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailProfile -SqlInstance sql01\\sharepoint\r\n\r\nReturns dbmail profiles on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailProfile -SqlInstance sql01\\sharepoint -Profile \u0027The DBA Team\u0027\r\n\r\nReturns The DBA Team dbmail profile from sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailProfile -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the dbmail profiles on sql01\\sharepoint then return a bunch more columns\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMail | Get-DbaDbMailProfile\r\n\r\nReturns the dbmail profiles for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMailServer", "Description": "Gets database mail servers from SQL Server", "Tags": [ "databasemail", "dbmail", "mail" ], "Syntax": "\r\nGet-DbaDbMailServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Server] \u003cString[]\u003e] \r\n[[-Account] \u003cString[]\u003e] [[-InputObject] \u003cSqlMail[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets database mail servers from SQL Server", "Name": "Get-DbaDbMailServer", "Links": "https://dbatools.io/Get-DbaDbMailServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailServer -SqlInstance sql01\\sharepoint\r\n\r\nReturns all dbmail servers on sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailServer -SqlInstance sql01\\sharepoint -Server DbaTeam\r\n\r\nReturns The DBA Team dbmail server from sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMailServer -SqlInstance sql01\\sharepoint | Select *\r\n\r\nReturns the dbmail servers on sql01\\sharepoint then return a bunch more columns\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDbMail | Get-DbaDbMailServer\r\n\r\nReturns the dbmail servers for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbMasterKey", "Description": "Gets specified database master key", "Tags": [ "Certificate", "Database" ], "Syntax": "\r\nGet-DbaDbMasterKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets specified database master key", "Name": "Get-DbaDbMasterKey", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMasterKey -SqlInstance sql2016\r\n\r\nGets all master database keys\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbMasterKey -SqlInstance Server1 -Database db1\r\n\r\nGets the master key for the db1 database\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDbPageInfo [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] \r\n[[-Schema] \u003cString[]\u003e] [[-Table] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPageInfo -SqlInstance sql2017\r\n\r\nReturns page information for all databases on sql2017\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPageInfo -SqlInstance sql2017, sql2016 -Database testdb\r\n\r\nReturns page information for the testdb on sql2017 and sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$servers | Get-DbaDatabase -Database testdb | Get-DbaDbPageInfo\r\n\r\nReturns page information for the testdb on all $servers\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbPartitionFunction", "Description": "Gets database Partition Functions", "Tags": "Database", "Syntax": "\r\nGet-DbaDbPartitionFunction [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database Partition Functions", "Name": "Get-DbaDbPartitionFunction", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPartitionFunction -SqlInstance sql2016\r\n\r\nGets all database Partition Functions\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPartitionFunction -SqlInstance Server1 -Database db1\r\n\r\nGets the Partition Functions for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPartitionFunction -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the Partition Functions for all databases except db1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbPartitionFunction\r\n\r\nGets the Partition Functions for the databases on Sql1 and Sql2/sqlexpress\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbPartitionScheme", "Description": "Gets database Partition Schemes", "Tags": "Database", "Syntax": "\r\nGet-DbaDbPartitionScheme [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database Partition Schemes", "Name": "Get-DbaDbPartitionScheme", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPartitionScheme -SqlInstance sql2016\r\n\r\nGets all database Partition Schemes\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPartitionScheme -SqlInstance Server1 -Database db1\r\n\r\nGets the Partition Schemes for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbPartitionScheme -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the Partition Schemes for all databases except db1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbPartitionScheme\r\n\r\nGets the Partition Schemes for the databases on Sql1 and Sql2/sqlexpress\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbQueryStoreOption", "Description": "Retrieves and returns the Query Store configuration for every database that has the Query Store feature enabled.", "Tags": "QueryStore", "Syntax": "\r\nGet-DbaDbQueryStoreOption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Enrico van de Laar ( @evdlaar )", "Synopsis": "Get the Query Store configuration for Query Store enabled databases.", "Name": "Get-DbaDbQueryStoreOption", "Links": "https://dbatools.io/Get-DbaQueryStoreOptions", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbQueryStoreOption -SqlInstance ServerA\\sql\r\n\r\nReturns Query Store configuration settings for every database on the ServerA\\sql instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbQueryStoreOption -SqlInstance ServerA\\sql | Where-Object {$_.ActualState -eq \"ReadWrite\"}\r\n\r\nReturns the Query Store configuration for all databases on ServerA\\sql where the Query Store feature is in Read/Write \r\nmode.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbQueryStoreOption -SqlInstance localhost | format-table -AutoSize -Wrap\r\n\r\nReturns Query Store configuration settings for every database on the ServerA\\sql instance inside a table format.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDbRecoveryModel [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-RecoveryModel] \r\n\u003cString[]\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Verbose\r\n\r\nGets all databases on SQL Server instance sql2014 having RecoveryModel set to BulkLogged\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRecoveryModel -SqlInstance sql2014 -Database TestDB\r\n\r\nGets recovery model information for TestDB. If TestDB does not exist on the instance we don\u0027t return anything.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbRole", "Description": "Get database roles on a Sql instance.\n\nDefault output includes columns SQLServer, Database, Role.", "Tags": [ "Roles", "Database", "Security" ], "Syntax": "\r\nGet-DbaDbRole [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeFixedRole] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Get database roles on a Sql instance.", "Name": "Get-DbaDbRole", "Links": "https://dbatools.io/Get-DbaDbRole", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRole -SqlInstance ServerA\r\n\r\nReturns a custom object displaying SQLServer, Database, Role for all DatabaseRoles on sql instance ServerA.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRole -SqlInstance ServerA | Out-Gridview\r\n\r\nReturns a gridview displaying SQLServer, Database, Role for all DatabaseRoles on sql instance ServerA.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRole -SqlInstance ServerB\\sql16 -ExcludeDatabase DBADB,TestDB\r\n\r\nReturns SQLServer, Database, Role for DatabaseRoles on sql instance ServerB\\sql16, except those in databases DBADB and \r\nTestDB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027ServerB\\sql16\u0027,\u0027ServerA\u0027 | Get-DbaDbRole\r\n\r\nReturns SQLServer, Database, Role for DatabaseRoles on sql instances ServerA and ServerB\\sql16.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRole -SqlInstance ServerB\\sql16 -Database AccountingDB\r\n\r\nReturns SQLServer, Database, Role for DatabaseRoles in database AccountingDB on sql instance ServerB\\sql16.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbRole -SqlInstance ServerB\\sql16 -ExcludeFixedRoles\r\n\r\nReturns SQLServer, Database, Role for DatabaseRoles on sql instance ServerB\\sql16, but not the fixed roles.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaDbSnapshot [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-Snapshot] \u003cObject[]\u003e] [[-ExcludeSnapshot] \u003cObject[]\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Get database snapshots with details", "Name": "Get-DbaDbSnapshot", "Links": "https://dbatools.io/Get-DbaDbSnapshot", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sqlserver2014a\r\n\r\nReturns a custom object displaying Server, Database, DatabaseCreated, SnapshotOf, SizeMB, DatabaseCreated\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting\r\n\r\nReturns information for database snapshots having HR and Accounting as base dbs\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sqlserver2014a -Snapshot HR_snapshot, Accounting_snapshot\r\n\r\nReturns information for database snapshots HR_snapshot and Accounting_snapshot\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDbSpace [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSpace -SqlInstance localhost\r\n\r\nReturns all user database files and free space information for the localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSpace -SqlInstance localhost | Where-Object {$_.PercentUsed -gt 80}\r\n\r\nReturns all user database files and free space information for the local host. Filters the output object by any files \r\nthat have a percent used of greater than 80%.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaDbSpace\r\n\r\nReturns all user database files and free space information for the localhost and localhost\\namedinstance SQL Server \r\ninstances. Processes data via the pipeline.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSpace -SqlInstance localhost -Database db1, db2\r\n\r\nReturns database files and free space information for the db1 and db2 on localhost.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaDbState [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Gets various options for databases, hereby called \"states\"", "Name": "Get-DbaDbState", "Links": "https://dbatools.io/Get-DbaDbState", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbState -SqlInstance sqlserver2014a\r\n\r\nGets options for all databases of the sqlserver2014a instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbState -SqlInstance sqlserver2014a -Database HR, Accounting\r\n\r\nGets options for both HR and Accounting database of the sqlserver2014a instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbState -SqlInstance sqlserver2014a -Exclude HR\r\n\r\nGets options for all databases of the sqlserver2014a instance except HR\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027sqlserver2014a\u0027, \u0027sqlserver2014b\u0027 | Get-DbaDbState\r\n\r\nGets options for all databases of sqlserver2014a and sqlserver2014b instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbStoredProcedure", "Description": "Gets database Stored Procedures", "Tags": [ "Database", "StoredProcedure", "Proc" ], "Syntax": "\r\nGet-DbaDbStoredProcedure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemSp] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database Stored Procedures", "Name": "Get-DbaDbStoredProcedure", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance sql2016\r\n\r\nGets all database Stored Procedures\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance Server1 -Database db1\r\n\r\nGets the Stored Procedures for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the Stored Procedures for all databases except db1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbStoredProcedure -SqlInstance Server1 -ExcludeSystemSp\r\n\r\nGets the Stored Procedures for all databases that are not system objects\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbStoredProcedure\r\n\r\nGets the Stored Procedures for the databases on Sql1 and Sql2/sqlexpress\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbTable", "Description": "Shows table information around table row and data sizes and if it has any table type information.", "Tags": [ "Database", "Tables" ], "Syntax": "\r\nGet-DbaDbTable [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [[-Table] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Database Test1\r\n\r\nReturn all tables in the Test1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Database MyDB -Table MyTable\r\n\r\nReturn only information on the table MyTable from the database MyDB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Table MyTable\r\n\r\nReturns information on table called MyTable if it exists in any database on the server, under any schema\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTable -SqlInstance DEV01 -Table dbo.[First.Table]\r\n\r\nReturns information on table called First.Table on schema dbo if it exists in any database on the server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaDbTable -Database DBA -Table Commandlog\r\n\r\nReturns information on the CommandLog table in the DBA database on both instances localhost and the named instance \r\nlocalhost\\namedinstance\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbTrigger", "Description": "Get all existing database triggers on one or more SQL instances.", "Tags": [ "Database", "Trigger" ], "Syntax": "\r\nGet-DbaDbTrigger [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTrigger -SqlInstance sql2017\r\n\r\nReturns all database triggers\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017 -Database supa | Get-DbaDbTrigger\r\n\r\nReturns all triggers for database supa on sql2017\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbTrigger -SqlInstance sql2017 -Database supa\r\n\r\nReturns all triggers for database supa on sql2017\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbUdf", "Description": "Gets database User Defined Functions", "Tags": [ "Security", "Database" ], "Syntax": "\r\nGet-DbaDbUdf [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemUdf] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database User Defined Functions", "Name": "Get-DbaDbUdf", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance sql2016\r\n\r\nGets all database User Defined Functions\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance Server1 -Database db1\r\n\r\nGets the User Defined Functions for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the User Defined Functions for all databases except db1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUdf -SqlInstance Server1 -ExcludeSystemUdf\r\n\r\nGets the User Defined Functions for all databases that are not system objects (there can be 100+ system User Defined \r\nFunctions in each DB)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbUdf\r\n\r\nGets the User Defined Functions for the databases on Sql1 and Sql2/sqlexpress\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbUser", "Description": "Gets database users", "Tags": [ "Security", "Database" ], "Syntax": "\r\nGet-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemUser] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database users", "Name": "Get-DbaDbUser", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUser -SqlInstance sql2016\r\n\r\nGets all database users\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUser -SqlInstance Server1 -Database db1\r\n\r\nGets the users for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUser -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the users for all databases except db1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUser -SqlInstance Server1 -ExcludeSystemUser\r\n\r\nGets the users for all databases that are not system objects, like \u0027dbo\u0027, \u0027guest\u0027 or \u0027INFORMATION_SCHEMA\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbUser\r\n\r\nGets the users for the databases on Sql1 and Sql2/sqlexpress\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDbView", "Description": "Gets database views for each SqlInstance.", "Tags": [ "Security", "Database" ], "Syntax": "\r\nGet-DbaDbView [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-ExcludeSystemView] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDbaKlaas )", "Synopsis": "Gets database views for each SqlInstance.", "Name": "Get-DbaDbView", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbView -SqlInstance sql2016\r\n\r\nGets all database views\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbView -SqlInstance Server1 -Database db1\r\n\r\nGets the views for the db1 database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbView -SqlInstance Server1 -ExcludeDatabase db1\r\n\r\nGets the views for all databases except db1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbView -SqlInstance Server1 -ExcludeSystemView\r\n\r\nGets the views for all databases that are not system objects (there can be 400+ system views in each DB)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaDbView\r\n\r\nGets the views for the databases on Sql1 and Sql2/sqlexpress\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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:\n http://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\n http://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" ], "Syntax": "\r\nGet-DbaDbVirtualLogFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbVirtualLogFile -SqlInstance sqlcluster\r\n\r\nReturns all user database virtual log file details for the sqlcluster instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbVirtualLogFile -SqlInstance sqlserver | Group-Object -Property Database | Where-Object Count -gt 50\r\n\r\nReturns user databases that have 50 or more VLFs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027sqlserver\u0027,\u0027sqlcluster\u0027 | Get-DbaDbVirtualLogFile\r\n\r\nReturns all VLF information for the sqlserver and sqlcluster SQL Server instances. Processes data via the pipeline.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbVirtualLogFile -SqlInstance sqlcluster -Database db1, db2\r\n\r\nReturns the VLF counts for the db1 and db2 databases on sqlcluster.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaDefaultPath", "Description": "Gets the default SQL Server paths for data, logs and backups", "Tags": "Config", "Syntax": "\r\nGet-DbaDefaultPath [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDefaultPath -SqlInstance sql01\\sharepoint\r\n\r\nReturns the default file paths for sql01\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaDefaultPath\r\n\r\nReturns the default file paths for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDependency [[-InputObject] \u003cObject\u003e] [-AllowSystemObjects] [-Parents] [-IncludeSelf] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$table = (Get-DbaDatabase -SqlInstance sql2012 -Database Northwind).tables | Where Name -eq Customers\r\n\r\n$table | Get-DbaDependency\r\n\r\nReturns everything that depends on the \"Customers\" table\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDetachedDatabaseInfo [-SqlInstance] \u003cDbaInstanceParameter\u003e [-Path] \u003cString\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDetachedDatabaseInfo -SqlInstance sql2016 -Path M:\\Archive\\mydb.mdf\r\n\r\nReturns information about the detached database file M:\\Archive\\mydb.mdf using the SQL Server instance sql2016. The M \r\ndrive is relative to the SQL Server instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDiskSpace [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Unit] \u003cString\u003e] \r\n[-CheckForSql] [[-SqlCredential] \u003cPSCredential\u003e] [[-ExcludeDrive] \u003cString[]\u003e] [-CheckFragmentation] [-Force] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (clemaire@gmail.com) \u0026 Jakob Bindslet (jakob@bindslet.dk)", "Synopsis": "Displays disk information for all local disk on a server.", "Name": "Get-DbaDiskSpace", "Links": "https://dbatools.io/Get-DbaDiskSpace", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042\r\n\r\nGet disk space for the server srv0042.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042 -Unit MB\r\n\r\nGet disk space for the server srv0042 and displays in megabytes (MB).\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042, srv0007 -Unit TB\r\n\r\nGet disk space from two servers and displays in terabytes (TB).\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042 -Force\r\n\r\nGet all disk and volume space information.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDiskSpace -ComputerName srv0042 -ExcludeDrive \u0027C:\\\u0027\r\n\r\nGet all disk and volume space information.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaDump [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDump -SqlInstance sql2016\r\n\r\nShows the detailed information for memory dump(s) located on sql2016 instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDump -SqlInstance sql2016 -SqlCredential (Get-Credential sqladmin)\r\n\r\nShows the detailed information for memory dump(s) located on sql2016 instance. Logs into the SQL Server using the SQL \r\nlogin \u0027sqladmin\u0027\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaEndpoint", "Description": "The Get-DbaEndpoint command gets SQL Endpoint(s) information for each instance(s) of SQL Server.", "Tags": "Endpoint", "Syntax": "\r\nGet-DbaEndpoint [-SqlInstance] \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Garry Bargsley (@gbargsley), http://blog.garrybargsley.com", "Synopsis": "Gets SQL Endpoint(s) information for each instance(s) of SQL Server.", "Name": "Get-DbaEndpoint", "Links": "https://dbatools.io/Get-DbaEndpoint", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance localhost\r\n\r\nReturns all Endpoint(s) on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaEndpoint -SqlInstance localhost, sql2016\r\n\r\nReturns all Endpoint(s) for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaErrorLog", "Description": "Gets the \"SQL Error Log\" of an instance. Returns all 10 error logs by default.", "Tags": [ "Instance", "ErrorLog" ], "Syntax": "\r\nGet-DbaErrorLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-LogNumber] \u003cInt32[]\u003e] \r\n[[-Source] \u003cObject[]\u003e] [[-Text] \u003cString\u003e] [[-After] \u003cDateTime\u003e] [[-Before] \u003cDateTime\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint\r\n\r\nReturns every log entry from sql01\\sharepoint SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -LogNumber 3, 6\r\n\r\nReturns all log entries for log number 3 and 6 on sql01\\sharepoint SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -Source Logon\r\n\r\nReturns every log entry, with a source of Logon, from sql01\\sharepoint SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -LogNumber 3 -Text \"login failed\"\r\n\r\nReturns every log entry for log number 3, with \"login failed\" in the text, from sql01\\sharepoint SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2014\",\"sql2016\", \"sqlcluster\\sharepoint\"\r\n\r\n$servers | Get-DbaErrorLog -LogNumber 0\r\n\r\nReturns the most recent SQL Server error logs for \"sql2014\",\"sql2016\" and \"sqlcluster\\sharepoint\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -After \u00272016-11-14 00:00:00\u0027\r\n\r\nReturns every log entry found after the date 14 November 2016 from sql101\\sharepoint SQL Server instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLog -SqlInstance sql01\\sharepoint -Before \u00272016-08-16 00:00:00\u0027\r\n\r\nReturns every log entry found before the date 16 August 2016 from sql101\\sharepoint SQL Server instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaErrorLogConfig [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton)", "Synopsis": "Pulls the configuration for the ErrorLog on a given SQL Server instance", "Name": "Get-DbaErrorLogConfig", "Links": "https://dbatools.io/Get-DbaErrorLogConfig", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaErrorLogConfig -SqlInstance server2017,server2014\r\n\r\nReturns error log configuration for server2017 and server2014\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaEstimatedCompletionTime [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016\r\n\r\nGets estimated completion times for queries performed against the entire server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016 | Select *\r\n\r\nGets estimated completion times for queries performed against the entire server PLUS the SQL query text of each command\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016 | Where-Object { $_.Text -match \u0027somequerytext\u0027 }\r\n\r\nGets results for commands whose queries only match specific text (match is like LIKE but way more powerful)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaEstimatedCompletionTime -SqlInstance sql2016 -Database Northwind,pubs,Adventureworks2014\r\n\r\nGets estimated completion times for queries performed against the Northwind, pubs, and Adventureworks2014 databases\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaExecutionPlan", "Description": "Gets execution plans and metadata. Can pipe to Export-DbaExecutionPlan\n\nThanks to\n https://www.simple-talk.com/sql/t-sql-programming/dmvs-for-query-plan-metadata/\n and\n http://www.scarydba.com/2017/02/13/export-plans-cache-sqlplan-file/\nfor the idea and query.", "Tags": "Performance", "Syntax": "\r\nGet-DbaExecutionPlan [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-SinceCreation] \u003cDateTime\u003e] [[-SinceLastExecution] \u003cDateTime\u003e] \r\n[-ExcludeEmptyQueryPlan] [-Force] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets execution plans and metadata", "Name": "Get-DbaExecutionPlan", "Links": "https://dbatools.io/Get-DbaExecutionPlan", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a\r\n\r\nGets all execution plans on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a -Database db1, db2 -SinceLastExecution \u00272016-07-01 10:47:00\u0027\r\n\r\nGets all execution plans for databases db1 and db2 on sqlserver2014a since July 1, 2016 at 10:47 AM.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sqlserver2014a, sql2016 -Exclude db1 | Format-Table\r\n\r\nGets execution plan info for all databases except db1 on sqlserver2014a and sql2016 and makes the output pretty\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaExecutionPlan -SqlInstance sql2014 -Database AdventureWorks2014, pubs -Force\r\n\r\nGets super detailed information for execution plans on only for AdventureWorks2014 and pubs\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sqlserver2014a\",\"sql2016t\"\r\n\r\n$servers | Get-DbaExecutionPlan -Force\r\n\r\nGets super detailed information for execution plans on sqlserver2014a and sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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,\n even if SQL was installed to a non-default path. This has been\n verified on SQL 2008R2 and SQL 2012. Further verification may be needed.\n2. The discovery report displays installed components for the version of SQL\n Server associated with setup.exe, along with installed components of all\n lesser versions of SQL Server that are installed.", "Tags": [ "Feature", "Component" ], "Syntax": "\r\nGet-DbaFeature [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFeature -ComputerName sql2017, sql2016, sql2005\r\n\r\nGets all SQL Server features for all instances on sql2017, sql2016 and sql2005.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFeature -Verbose\r\n\r\nGets all SQL Server features for all instances on localhost. Outputs to screen if no instances are found.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFeature -ComputerName sql2017 -Credential (Get-Credential ad\\sqladmin)\r\n\r\nGets all SQL Server features for all instances on sql2017 using the ad\\sqladmin credential (which has access to the \r\nWindows Server).\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \u003cString[]\u003e] [[-FileType] \r\n\u003cString[]\u003e] [[-Depth] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFile -SqlInstance sqlserver2014a -Path E:\\Dir1\r\n\r\nLogs into the SQL Server \"sqlserver2014a\" using Windows credentials and searches E:\\Dir for all files\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFile -SqlInstance sqlserver2014a -SqlCredential $cred -Path \u0027E:\\sql files\u0027\r\n\r\nLogs into the SQL Server \"sqlserver2014a\" using alternative credentials and returns all files in \u0027E:\\sql files\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$all = Get-DbaDefaultPath -SqlInstance sql2014\r\n\r\nGet-DbaFile -SqlInstance sql2014 -Path $all.Data, $all.Log, $all.Backup -Depth 3\r\nReturns the files in the default data, log and backup directories on sql2014, 3 directories deep (recursively).\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFile -SqlInstance sql2014 -Path \u0027E:\\Dir1\u0027, \u0027E:\\Dir2\u0027\r\n\r\nReturns the files in \"E:\\Dir1\" and \"E:Dir2\" on sql2014\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFile -SqlInstance -Path \u0027E:\\Dir1\u0027 sql2014, sql2016 -FileType fsf, mld\r\n\r\nFinds files in E:\\Dir1 ending with \".fsf\" and \".mld\" for both the servers sql2014 and sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaFile -SqlInstance -Path \u0027E:\\Dir1\u0027 sql2014, sql2016 -FileType fsf, mld\r\n\r\nFinds files in E:\\Dir1 ending with \".fsf\" and \".mld\" for both the servers sql2014 and sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaForceNetworkEncryption [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Force Encryption settings for a SQL Server instance", "Name": "Get-DbaForceNetworkEncryption", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaForceNetworkEncryption\r\n\r\nGets Force Encryption properties on the default (MSSQLSERVER) instance on localhost - requires (and checks for) RunAs \r\nadmin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaForceNetworkEncryption -SqlInstance sql01\\SQL2008R2SP2\r\n\r\nGets Force Network Encryption for the SQL2008R2SP2 on sql01. Uses Windows Credentials to both login and view the \r\nregistry.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaHelpIndex [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [[-ObjectName] \u003cString\u003e] [-IncludeStats] \r\n[-IncludeDataTypes] [-Raw] [-IncludeFragmentation] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB\r\n\r\nReturns information on all indexes on the MyDB database on the localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB,MyDB2\r\n\r\nReturns information on all indexes on the MyDB \u0026 MyDB2 databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1\r\n\r\nReturns index information on the object dbo.Table1 in the database MyDB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1 -IncludeStats\r\n\r\nReturns information on the indexes and statistics for the table dbo.Table1 in the MyDB database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1 -IncludeDataTypes\r\n\r\nReturns the index information for the table dbo.Table1 in the MyDB database, and includes the data types for the key \r\nand include columns.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -ObjectName dbo.Table1 -Raw\r\n\r\nReturns the index information for the table dbo.Table1 in the MyDB database, and returns the numerical data without \r\nlocalized separators.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -IncludeStats -Raw\r\n\r\nReturns the index information for all indexes in the MyDB database as well as their statistics, and formats the \r\nnumerical data without localized separators.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaHelpIndex -SqlInstance localhost -Database MyDB -IncludeFragmentation\r\n\r\nReturns the index information for all indexes in the MyDB database as well as their fragmentation\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2017 -Database MyDB | Get-DbaHelpIndex\r\n\r\nReturns the index information for all indexes in the MyDB database\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaInstanceProperty", "Description": "The Get-DbaInstanceProperty command gets SQL Server instance properties from the SMO object sqlserver.", "Tags": [ "Instance", "Configure", "Configuration" ], "Syntax": "\r\nGet-DbaInstanceProperty [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-InstanceProperty \r\n\u003cObject[]\u003e] [-ExcludeInstanceProperty \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance localhost\r\n\r\nReturns SQL Server instance properties on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance sql2, sql4\\sqlexpress\r\n\r\nReturns SQL Server instance properties on default instance on sql2 and sqlexpress instance on sql4\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql2\u0027,\u0027sql4\u0027 | Get-DbaInstanceProperty\r\n\r\nReturns SQL Server instance properties on sql2 and sql4\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance sql2,sql4 -InstanceProperty DefaultFile\r\n\r\nReturns SQL Server instance property DefaultFile on instance sql2 and sql4\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaInstanceProperty -SqlInstance sql2,sql4 -ExcludeInstanceProperty DefaultFile\r\n\r\nReturns all SQL Server instance properties except DefaultFile on instance sql2 and sql4\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nGet-DbaInstanceProperty -SqlInstance sql2 -SqlCredential $cred\r\n\r\nConnects using sqladmin credential and returns SQL Server instance properties from sql2\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaInstanceUserOption", "Description": "The Get-DbaInstanceUserOption command gets SQL Instance user options from the SMO object sqlserver.", "Tags": [ "Instance", "Configure", "UserOption" ], "Syntax": "\r\nGet-DbaInstanceUserOption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaInstanceUserOption -SqlInstance localhost\r\n\r\nReturns SQL Instance user options on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaInstanceUserOption -SqlInstance sql2, sql4\\sqlexpress\r\n\r\nReturns SQL Instance user options on default instance on sql2 and sqlexpress instance on sql4\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql2\u0027,\u0027sql4\u0027 | Get-DbaInstanceUserOption\r\n\r\nReturns SQL Instance user options on sql2 and sql4\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaLastBackup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Get date/time for last known backups of databases.", "Name": "Get-DbaLastBackup", "Links": "https://dbatools.io/Get-DbaLastBackup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987\r\n\r\nReturns a custom object displaying Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup, \r\nSinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987\r\n\r\nReturns a custom object with Server name, Database name, and the date the last time backups were performed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987 | Select *\r\n\r\nReturns a custom object with Server name, Database name, and the date the last time backups were performed, and also \r\nrecoverymodel and calculations on how long ago backups were taken and what the status is.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLastBackup -SqlInstance ServerA\\sql987 | Select * | Out-Gridview\r\n\r\nReturns a gridview displaying Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup, \r\nSinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaLastGoodCheckDb [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Jakob Bindslet (jakob@bindslet.dk)", "Synopsis": "Get date/time for last known good DBCC CHECKDB", "Name": "Get-DbaLastGoodCheckDb", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLastGoodCheckDb -SqlInstance ServerA\\sql987\r\n\r\nReturns a custom object displaying Server, Database, DatabaseCreated, LastGoodCheckDb, DaysSinceDbCreated, \r\nDaysSinceLastGoodCheckDb, Status and DataPurityEnabled\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLastGoodCheckDb -SqlInstance ServerA\\sql987 -SqlCredential (Get-Credential sqladmin) | Format-Table \r\n-AutoSize\r\n\r\nReturns a formatted table displaying Server, Database, DatabaseCreated, LastGoodCheckDb, DaysSinceDbCreated, \r\nDaysSinceLastGoodCheckDb, Status and DataPurityEnabled. Authenticates using SQL Server authentication.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaLinkedServer", "Description": "Retrieves information about each linked server on the instance", "Tags": [ "LinkedServer", "Linked" ], "Syntax": "\r\nGet-DbaLinkedServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-LinkedServer] \r\n\u003cObject[]\u003e] [[-ExcludeLinkedServer] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stephen Bennett ( https://sqlnotesfromtheunderground.wordpress.com/ )", "Synopsis": "Gets all linked servers and summary of information from the sql servers listed", "Name": "Get-DbaLinkedServer", "Links": "https://dbatools.io/Get-DbaLinkedServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLinkedServer -SqlInstance DEV01\r\n\r\nReturns all Linked Servers for the SQL Server instance DEV01\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaLocaleSetting", "Description": "Gets the Locale settings on one or more computers.\n\nRequires Local Admin rights on destination computer(s).", "Tags": "OS", "Syntax": "\r\nGet-DbaLocaleSetting [[-ComputerName] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Gets the Locale settings on a computer.", "Name": "Get-DbaLocaleSetting", "Links": "https://dbatools.io/Get-DbaLocaleSetting", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLocaleSetting -ComputerName sqlserver2014a\r\n\r\nGets the Locale settings on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaLocaleSetting\r\n\r\nGets the Locale settings on computers sql1, sql2 and sql3.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLocaleSetting -ComputerName sql1,sql2 | Out-Gridview\r\n\r\nGets the Locale settings on computers sql1 and sql2, and shows them in a grid view.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] \r\n[-IncludeFilter \u003cObject[]\u003e] [-ExcludeLogin \u003cObject[]\u003e] [-ExcludeFilter \u003cObject[]\u003e] [-NoSystem] [-SQLLogins] \r\n[-WindowsLogins] [-HasAccess] [-Locked] [-Disabled] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Mitchell Hamann (@SirCaptainMitch)", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016\r\n\r\nGets all the logins from server sql2016 using NT authentication and returns the SMO login objects\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SqlCredential $sqlcred\r\n\r\nGets all the logins for a given SQL Server using a passed credential object and returns the SMO login objects\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SqlCredential $sqlcred -Login dbatoolsuser,TheCaptain\r\n\r\nGet specific logins from server sql2016 returned as SMO login objects.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -IncludeFilter \u0027##*\u0027,\u0027NT *\u0027\r\n\r\nGet all user objects from server sql2016 beginning with \u0027##\u0027 or \u0027NT \u0027, returned as SMO login objects.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -ExcludeLogin dbatoolsuser\r\n\r\nGet all user objects from server sql2016 except the login dbatoolsuser, returned as SMO login objects.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -WindowsLogins\r\n\r\nGet all user objects from server sql2016 that are Windows Logins\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -WindowsLogins -IncludeFilter *Rob*\r\n\r\nGet all user objects from server sql2016 that are Windows Logins and have Rob in the name\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SQLLogins\r\n\r\nGet all user objects from server sql2016 that are SQLLogins\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -SQLLogins -IncludeFilter *Rob*\r\n\r\nGet all user objects from server sql2016 that are SQLLogins and have Rob in the name\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -NoSystem\r\n\r\nGet all user objects from server sql2016 that are not system objects\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 11 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql2016 -ExcludeFilter \u0027##*\u0027,\u0027NT *\u0027\r\n\r\nGet all user objects from server sql2016 except any beginning with \u0027##\u0027 or \u0027NT \u0027, returned as SMO login objects.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 12 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql2016\u0027, \u0027sql2014\u0027 | Get-DbaLogin -SqlCredential $sqlcred\r\n\r\nUsing Get-DbaLogin on the pipeline, you can also specify which names you would like with -Login.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 13 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql2016\u0027, \u0027sql2014\u0027 | Get-DbaLogin -SqlCredential $sqlcred -Locked\r\n\r\nUsing Get-DbaLogin on the pipeline to get all locked logins on servers sql2016 and sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 14 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql2016\u0027, \u0027sql2014\u0027 | Get-DbaLogin -SqlCredential $sqlcred -HasAccess -Disabled\r\n\r\nUsing Get-DbaLogin on the pipeline to get all Disabled logins that have access on servers sql2016 or sql2014.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaLogShippingError", "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", "Syntax": "\r\nGet-DbaLogShippingError [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Action] \u003cString[]\u003e] [[-DateTimeFrom] \u003cDateTime\u003e] [[-DateTimeTo] \r\n\u003cDateTime\u003e] [-Primary] [-Secondary] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Get-DbaLogShippingError returns all the log shipping errors that occurred", "Name": "Get-DbaLogShippingError", "Links": "https://dbatools.io/Get-DbaLogShippingError", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogShippingError -SqlInstance sql1\r\n\r\nGet all the log shipping errors that occurred\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogShippingError -SqlInstance sql1 -Action Backup\r\n\r\nGet the errors that have something to do with the backup of the databases\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogShippingError -SqlInstance sql1 -Secondary\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogShippingError -SqlInstance sql1 -DateTimeFrom \"01/05/2018\"\r\n\r\nGet the errors that have occurred from \"01/05/2018\". This can also be of format \"yyyy-MM-dd\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogShippingError -SqlInstance sql1 -Secondary -DateTimeFrom \"01/05/2018\" -DateTimeTo \"2018-01-07\"\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaMaintenanceSolutionLog [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-LogType] \r\n\u003cString[]\u003e] [[-Since] \u003cDateTime\u003e] [[-Path] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @powerdbaklaas )", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a\r\n\r\nGets the outcome of the IndexOptimize job on sql instance sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -SqlCredential $credential\r\n\r\nGets the outcome of the IndexOptimize job on sqlserver2014a, using SQL Authentication.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027sqlserver2014a\u0027, \u0027sqlserver2020test\u0027 | Get-DbaMaintenanceSolutionLog\r\n\r\nGets the outcome of the IndexOptimize job on sqlserver2014a and sqlserver2020test.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -Path \u0027D:\\logs\\maintenancesolution\\\u0027\r\n\r\nGets the outcome of the IndexOptimize job on sqlserver2014a, reading the log files in their custom location.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -Since \u00272017-07-18\u0027\r\n\r\nGets the outcome of the IndexOptimize job on sqlserver2014a, starting from july 18, 2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaintenanceSolutionLog -SqlInstance sqlserver2014a -LogType IndexOptimize\r\n\r\nGets the outcome of the IndexOptimize job on sqlserver2014a, the other options are not yet available! sorry\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaManagementObject [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-VersionNumber] \r\n\u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaManagementObject\r\n\r\nReturns all versions of SMO on the computer\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaManagementObject -VersionNumber 13\r\n\r\nReturns just the version specified. If the version does not exist then it will return nothing.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.", "Tags": [ "MaxMemory", "Memory" ], "Syntax": "\r\nGet-DbaMaxMemory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaxMemory -SqlInstance sqlcluster,sqlserver2012\r\n\r\nGet memory settings for all servers within the SQL Server Central Management Server \"sqlcluster\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMaxMemory -SqlInstance sqlcluster | Where-Object { $_.SqlMaxMB -gt $_.TotalMB }\r\n\r\nFind all servers in Server Central Management Server that have \u0027Max Server Memory\u0027 set to higher than the total memory \r\nof the server (think 2147483647)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaMemoryUsage [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Simple] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMemoryUsage -ComputerName ServerA\r\n\r\nReturns a custom object displaying Server, counter instance, counter, number of pages, memory in KB, memory in MB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMemoryUsage -ComputerName ServerA\\sql987 -Simple\r\n\r\nReturns a custom object with Server, counter instance, counter, number of pages, memory in KB, memory in MB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMemoryUsage -ComputerName ServerA\\sql987 | Out-Gridview\r\n\r\nReturns a gridview displaying Server, counter instance, counter, number of pages, memory in KB, memory in MB\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaModule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-ModifiedSince] \u003cDateTime\u003e] [[-Type] \u003cString[]\u003e] [-NoSystemDb] [-NoSystemObjects] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaModule -SqlServer sql2008, sqlserver2012\r\n\r\nReturn all modules for servers sql2008 and sqlserver2012 sorted by Database, Modify_Date ASC.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaModule -SqlServer sql2008, sqlserver2012 | Select *\r\n\r\nShows hidden definition column (informative wall of text).\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaModule -SqlServer sql2008 -Database TestDB -ModifiedSince \"01/01/2017 10:00:00 AM\"\r\n\r\nReturn all modules on server sql2008 for only the TestDB database with a modified date after 01/01/2017 10:00:00 AM.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaModule -SqlServer sql2008 -Type View, Trigger, ScalarFunction\r\n\r\nReturn all modules on server sql2008 for all databases that are triggers, views or scalar functions.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaMsdtc [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMsdtc -ComputerName srv0042\r\n\r\nGet DTC status for the server srv0042\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$Computers = (Get-Content D:\\configfiles\\SQL\\MySQLInstances.txt | % {$_.split(\u0027\\\u0027)[0]})\r\n\r\n$Computers | Get-DbaMsdtc\r\n\r\nGet DTC status for all the computers in a .txt file\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMsdtc -Computername $Computers | where { $_.dtcservicestate -ne \u0027running\u0027 }\r\n\r\nGet DTC status for all the computers where the MSDTC Service is not running\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaMsdtc -ComputerName srv0042 | Out-Gridview\r\n\r\nGet DTC status for the computer srv0042 and show in a grid view\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaNetworkActivity [[-ComputerName] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaNetworkActivity -ComputerName sqlserver2014a\r\n\r\nGets the Current traffic on every Network Interface on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaNetworkActivity\r\n\r\nGets the Current traffic on every Network Interface on computers sql1, sql2 and sql3.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaNetworkActivity -ComputerName sql1,sql2 | Out-Gridview\r\n\r\nGets the Current traffic on every Network Interface on computers sql1 and sql2, and shows them in a grid view.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaNetworkCertificate", "Description": "Gets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption", "Tags": "Certificate", "Syntax": "\r\nGet-DbaNetworkCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaNetworkCertificate\r\n\r\nGets computer certificates on localhost that are candidates for using with SQL Server\u0027s network encryption\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaNetworkCertificate -ComputerName sql2016\r\n\r\nGets computer certificates on sql2016 that are being used for SQL Server network encryption\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaOpenTransaction [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Displays all open transactions.", "Name": "Get-DbaOpenTransaction", "Links": "https://dbatools.io/Get-DbaOpenTransaction", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOpenTransaction -SqlInstance sqlserver2014a\r\n\r\nReturns open transactions for sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOpenTransaction -SqlInstance sqlserver2014a -SqlCredential (Get-Credential sqladmin)\r\n\r\nLogs into sqlserver2014a using the login \"sqladmin\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaOperatingSystem", "Description": "Gets operating system information from the server and returns as an object.", "Tags": [ "ServerInfo", "OperatingSystem" ], "Syntax": "\r\nGet-DbaOperatingSystem [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton | http://blog.wsmelton.info)", "Synopsis": "Gets operating system information from the server.", "Name": "Get-DbaOperatingSystem", "Links": "https://dbatools.io/Get-DbaOperatingSystem", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOperatingSystem\r\n\r\nReturns information about the local computer\u0027s operating system\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOperatingSystem -ComputerName sql2016\r\n\r\nReturns information about the sql2016\u0027s operating system\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaOrphanUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Get orphaned users.", "Name": "Get-DbaOrphanUser", "Links": "https://dbatools.io/Get-DbaOrphanUser", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOrphanUser -SqlInstance localhost\\sql2016\r\n\r\nFinds all orphan users without matching Logins in all databases present on server \u0027localhost\\sql2016\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOrphanUser -SqlInstance localhost\\sql2016 -SqlCredential $cred\r\n\r\nFinds all orphan users without matching Logins in all databases present on server \u0027localhost\\sql2016\u0027. SQL Server \r\nauthentication will be used in connecting to the server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaOrphanUser -SqlInstance localhost\\sql2016 -Database db1\r\n\r\nFinds orphan users without matching Logins in the db1 database present on server \u0027localhost\\sql2016\u0027.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPageFileSetting", "Description": "This command uses CIM (or other, related computer management tools) to detect the pagefile configuration of the target compuer(s).\nNote that this may require local administrator privileges for the relevant computers.", "Tags": "CIM", "Syntax": "\r\nGet-DbaPageFileSetting [[-ComputerName] \u003cDbaInstanceParameter\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Returns information on the pagefile configuration of the target computer.", "Name": "Get-DbaPageFileSetting", "Links": "https://dbatools.io/Get-DbaPageFileSetting", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPageFileSetting -ComputerName ServerA,ServerB\r\n\r\nReturns a custom object displaying ComputerName, AutoPageFile, FileName, Status, LastModified, LastAccessed, \r\nAllocatedBaseSize, InitialSize, MaximumSize, PeakUsage, CurrentUsage for ServerA and ServerB\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027ServerA\u0027 | Get-DbaPageFileSetting\r\n\r\nReturns a custom object displaying ComputerName, AutoPageFile, FileName, Status, LastModified, LastAccessed, \r\nAllocatedBaseSize, InitialSize, MaximumSize, PeakUsage, CurrentUsage for ServerA\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPbmCategory", "Description": "Returns policy categories from policy based management from an instance.", "Tags": [ "Policy", "PoilcyBasedManagement", "PBM" ], "Syntax": "\r\nGet-DbaPbmCategory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \u003cString[]\u003e] \r\n[[-InputObject] \u003cPolicyStore[]\u003e] [-ExcludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmCategory -SqlInstance sql2016\r\n\r\nReturns all policy categories from the sql2016 PBM server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmCategory -SqlInstance sql2016 -SqlCredential $cred\r\n\r\nUses a credential $cred to connect and return all policy categories from the sql2016 PBM server\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPbmCategorySubscription", "Description": "Returns policy category subscriptions from policy based management from an instance.", "Tags": [ "Policy", "PoilcyBasedManagement", "PBM" ], "Syntax": "\r\nGet-DbaPbmCategorySubscription [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] \r\n[[-InputObject] \u003cPolicyStore[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmCategorySubscription -SqlInstance sql2016\r\n\r\nReturns all policy category subscriptions from the sql2016 PBM server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmCategorySubscription -SqlInstance sql2016 -SqlCredential $cred\r\n\r\nUses a credential $cred to connect and return all policy category subscriptions from the sql2016 PBM server\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPbmCondition", "Description": "Returns conditions from policy based management from an instance.", "Tags": [ "Policy", "PoilcyBasedManagement", "PBM" ], "Syntax": "\r\nGet-DbaPbmCondition [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Condition] \r\n\u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-IncludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmCondition -SqlInstance sql2016\r\n\r\nReturns all conditions from the sql2016 PBM server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmCondition -SqlInstance sql2016 -SqlCredential $cred\r\n\r\nUses a credential $cred to connect and return all conditions from the sql2016 PBM server\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPbmObjectSet", "Description": "Returns object sets from policy based management.", "Tags": [ "Policy", "PoilcyBasedManagement", "PBM" ], "Syntax": "\r\nGet-DbaPbmObjectSet [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-ObjectSet] \r\n\u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-IncludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns object sets from policy based management.", "Name": "Get-DbaPbmObjectSet", "Links": "https://dbatools.io/Get-DbaPbmObjectSet", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmObjectSet -SqlInstance sql2016\r\n\r\nReturns all object sets from the sql2016 PBM instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmObjectSet -SqlInstance sql2016 -SqlCredential $cred\r\n\r\nUses a credential $cred to connect and return all object sets from the sql2016 PBM instance\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPbmPolicy", "Description": "Returns details of policies with the option to filter on Category and SystemObjects.", "Tags": [ "Policy", "PoilcyBasedManagement", "PBM" ], "Syntax": "\r\nGet-DbaPbmPolicy [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Policy] \u003cString[]\u003e] \r\n[[-Category] \u003cString[]\u003e] [[-InputObject] \u003cPolicyStore[]\u003e] [-IncludeSystemObject] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stephen Bennett (https://sqlnotesfromtheunderground.wordpress.com/)", "Synopsis": "Returns polices from policy based management from an instance.", "Name": "Get-DbaPbmPolicy", "Links": "https://dbatools.io/Get-DbaPbmPolicy", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmPolicy -SqlInstance sql2016\r\n\r\nReturns all policies from sql2016 server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmPolicy -SqlInstance sql2016 -SqlCredential $cred\r\n\r\nUses a credential $cred to connect and return all policies from sql2016 instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmPolicy -SqlInstance sql2016 -Category MorningCheck\r\n\r\nReturns all policies from sql2016 server that part of the PolicyCategory MorningCheck\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPbmStore", "Description": "Returns the policy based management store.", "Tags": [ "Policy", "PoilcyBasedManagement", "PBM" ], "Syntax": "\r\nGet-DbaPbmStore [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns the policy based management store.", "Name": "Get-DbaPbmStore", "Links": "https://dbatools.io/Get-DbaPbmStore", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmStore -SqlInstance sql2016\r\n\r\nReturn the policy store from the sql2016 instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPbmStore -SqlInstance sql2016 -SqlCredential $cred\r\n\r\nUses a credential $cred to connect and return the policy store from the sql2016 instance\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaPermission [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeServerLevel] [-NoSystemObjects] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Get a list of Server and Database level permissions", "Name": "Get-DbaPermission", "Links": "https://dbatools.io/Get-DbaPermission", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPermission -SqlInstance ServerA\\sql987\r\n\r\nReturns a custom object with Server name, Database name, permission state, permission type, grantee and securable.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPermission -SqlInstance ServerA\\sql987 | Format-Table -AutoSize\r\n\r\nReturns a formatted table displaying Server, Database, permission state, permission type, grantee, granteetype, \r\nsecurable and securabletype.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPermission -SqlInstance ServerA\\sql987 -NoSystemObjects -IncludeServerLevel\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPermission -SqlInstance sql2016 -Database master\r\n\r\nReturns a custom object with permissions for the master database.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaPfAvailableCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Pattern] \r\n\u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfAvailableCounter\r\n\r\nGets all available counters on the local machine.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfAvailableCounter -Pattern *sql*\r\n\r\nGets all counters matching sql on the local machine.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfAvailableCounter -ComputerName sql2017 -Pattern *sql*\r\n\r\nGets all counters matching sql on the remote server sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfAvailableCounter -Pattern *sql*\r\n\r\nGets all counters matching sql on the local machine.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfAvailableCounter -Pattern *sql* | Add-DbaPfDataCollectorCounter -CollectorSet \u0027Test Collector Set\u0027 \r\n-Collector DataCollector01\r\n\r\nAdds all counters matching \"sql\" to the DataCollector01 within the \u0027Test Collector Set\u0027 CollectorSet.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPfDataCollector", "Description": "Gets Performance Monitor Data Collectors.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Syntax": "\r\nGet-DbaPfDataCollector [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \r\n\u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Performance Monitor Data Collectors.", "Name": "Get-DbaPfDataCollector", "Links": "https://dbatools.io/Get-DbaPfDataCollector", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollector\r\n\r\nGets all Collectors on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollector -ComputerName sql2017\r\n\r\nGets all Collectors on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollector -ComputerName sql2017, sql2016 -Credential (Get-Credential) -CollectorSet \u0027System \r\nCorrelation\u0027\r\n\r\nGets all Collectors for the \u0027System Correlation\u0027 CollectorSet on sql2017 and sql2016 using alternative credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Get-DbaPfDataCollector\r\n\r\nGets all Collectors for the \u0027System Correlation\u0027 CollectorSet.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPfDataCollectorCounter", "Description": "Gets Performance Counters.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Syntax": "\r\nGet-DbaPfDataCollectorCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [[-Counter] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Performance Counters.", "Name": "Get-DbaPfDataCollectorCounter", "Links": "https://dbatools.io/Get-DbaPfDataCollectorCounter", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounter\r\n\r\nGets all counters for all Collector Sets on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017\r\n\r\nGets all counters for all Collector Sets on on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017 -Counter \u0027\\Processor(_Total)\\% Processor Time\u0027\r\n\r\nGets the \u0027\\Processor(_Total)\\% Processor Time\u0027 counter on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017, sql2016 -Credential (Get-Credential) -CollectorSet \u0027System \r\nCorrelation\u0027\r\n\r\nGets all counters for the \u0027System Correlation\u0027 CollectorSet on sql2017 and sql2016 using alternative credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Get-DbaPfDataCollector | \r\nGet-DbaPfDataCollectorCounter\r\n\r\nGets all counters for the \u0027System Correlation\u0027 CollectorSet.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPfDataCollectorCounterSample", "Description": "Gets Performance Counter Samples.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Syntax": "\r\nGet-DbaPfDataCollectorCounterSample [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [[-Counter] \u003cString[]\u003e] [-Continuous] [[-ListSet]] \r\n[[-MaxSamples] \u003cInt32\u003e] [[-SampleInterval] \u003cInt32\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Performance Counter Samples.", "Name": "Get-DbaPfDataCollectorCounterSample", "Links": "https://dbatools.io/Get-DbaPfDataCollectorCounterSample", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample\r\n\r\nGets a single sample for all counters for all Collector Sets on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -Counter \u0027\\Processor(_Total)\\% Processor Time\u0027\r\n\r\nGets a single sample for all counters for all Collector Sets on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounter -ComputerName sql2017, sql2016 | Out-GridView -PassThru | \r\nGet-DbaPfDataCollectorCounterSample -MaxSamples 10\r\n\r\nGets 10 samples for all counters for all Collector Sets for servers sql2016 and sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -ComputerName sql2017\r\n\r\nGets a single sample for all counters for all Collector Sets on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -ComputerName sql2017, sql2016 -Credential (Get-Credential) -CollectorSet \r\n\u0027System Correlation\u0027\r\n\r\nGets a single sample for all counters for the \u0027System Correlation\u0027 CollectorSet on sql2017 and sql2016 using \r\nalternative credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounterSample -CollectorSet \u0027System Correlation\u0027\r\n\r\nGets a single sample for all counters for the \u0027System Correlation\u0027 CollectorSet.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPfDataCollectorSet", "Description": "Gets Performance Monitor Data Collector Set.", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Syntax": "\r\nGet-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \r\n\u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Performance Monitor Data Collector Set.", "Name": "Get-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Get-DbaPfDataCollectorSet", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet\r\n\r\nGets all Collector Sets on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2017\r\n\r\nGets all Collector Sets on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2017 -Credential (Get-Credential) -CollectorSet \u0027System Correlation\u0027\r\n\r\nGets the \u0027System Correlation\u0027 CollectorSet on sql2017 using alternative credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet | Select *\r\n\r\nDisplays extra columns and also exposes the original COM object in DataCollectorSetObject.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPfDataCollectorSetTemplate", "Description": "Parses Perf Monitor XML templates. Defaults to parsing templates in the dbatools template repository (\\bin\\perfmontemplates\\).", "Tags": [ "Performance", "DataCollector", "PerfCounter" ], "Syntax": "\r\nGet-DbaPfDataCollectorSetTemplate [[-Path] \u003cString[]\u003e] [[-Pattern] \u003cString\u003e] [[-Template] \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate\r\n\r\nReturns information about all the templates in the local dbatools repository.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate | Out-GridView -PassThru | Import-DbaPfDataCollectorSetTemplate -ComputerName \r\nsql2017 | Start-DbaPfDataCollectorSet\r\n\r\nAllows you to select a template, then deploys it to sql2017 and immediately starts the DataCollectorSet.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate | Select-Object *\r\n\r\nReturns more information about the template, including the full path/filename.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaPlanCache", "Description": "Checks ahoc and prepared plan cache for each database, if over 100 MBS you should consider you using Remove-DbaQueryPlan to clear the plan caches or turning on optimize for adhoc workloads configuration is 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", "Syntax": "\r\nGet-DbaPlanCache [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPlanCache -SqlInstance sql2017\r\n\r\nReturns the single use plan cache usage information for SQL Server instance 2017\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPlanCache -SqlInstance sql2017\r\n\r\nReturns the single use plan cache usage information for SQL Server instance 2017\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPlanCache -SqlInstance sql2017 -SqlCredential (Get-Credential sqladmin)\r\n\r\nReturns the single use plan cache usage information for SQL Server instance 2017 using login \u0027sqladmin\u0027\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaPrivilege [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPrivilege -ComputerName sqlserver2014a\r\n\r\nGets the local privileges on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaPrivilege\r\n\r\nGets the local privileges on computers sql1, sql2 and sql3.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPrivilege -ComputerName sql1,sql2 | Out-Gridview\r\n\r\nGets the local privileges on computers sql1 and sql2, and shows them in a grid view.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaProcess [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Spid] \u003cInt32[]\u003e] \r\n[[-ExcludeSpid] \u003cInt32[]\u003e] [[-Database] \u003cString[]\u003e] [[-Login] \u003cString[]\u003e] [[-Hostname] \u003cString[]\u003e] [[-Program] \r\n\u003cString[]\u003e] [-NoSystemSpid] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "This command displays SQL Server processes.", "Name": "Get-DbaProcess", "Links": "https://dbatools.io/Get-DbaProcess", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -Login base\\ctrlb, sa\r\n\r\nShows information about the processes for base\\ctrlb and sa on sqlserver2014a. Windows Authentication is used in \r\nconnecting to sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -SqlCredential $credential -Spid 56, 77\r\n\r\nShows information about the processes for spid 56 and 57. Uses alternative (SQL or Windows) credentials to authenticate \r\nto sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -Program \u0027Microsoft SQL Server Management Studio\u0027\r\n\r\nShows information about the processes that were created in Microsoft SQL Server Management Studio.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaProcess -SqlInstance sqlserver2014a -Host workstationx, server100\r\n\r\nShows information about the processes that were initiated by hosts (computers/clients) workstationx and server 1000.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaProductKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-SqlCms] \u003cString\u003e] \r\n[[-ServersFromFile] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaProductKey winxp, sqlservera, sqlserver2014a, win2k8\r\n\r\nGets SQL Server versions, editions and product keys for all instances within each server or workstation.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaQueryExecutionTime", "Description": "Quickly find slow query executions within a database. Results will include stored procedures and individual SQL statements.", "Tags": [ "Query", "Performance" ], "Syntax": "\r\nGet-DbaQueryExecutionTime [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \r\n\u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [[-MaxResultsPerDb] \u003cInt32\u003e] [[-MinExecs] \u003cInt32\u003e] [[-MinExecMs] \u003cInt32\u003e] \r\n[[-NoSystemDb]] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaQueryExecutionTime -SqlInstance sql2008, sqlserver2012\r\n\r\nReturn the top 100 slowest stored procedures or statements for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaQueryExecutionTime -SqlInstance sql2008 -Database TestDB\r\n\r\nReturn the top 100 slowest stored procedures or statements on server sql2008 for only the TestDB database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaQueryExecutionTime -SqlInstance sql2008 -Database TestDB -MaxResultsPerDb 100 -MinExecs 200 -MinExecMs \r\n1000\r\n\r\nReturn the top 100 slowest stored procedures or statements on server sql2008 for only the TestDB database,\r\nlimiting results to queries with more than 200 total executions and an execution time over 1000ms or higher.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRegisteredServer", "Description": "Returns an array of servers found in the CMS.", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nGet-DbaRegisteredServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] \r\n[[-ServerName] \u003cString[]\u003e] [[-Group] \u003cObject[]\u003e] [[-ExcludeGroup] \u003cObject[]\u003e] [[-Id] \u003cInt32[]\u003e] [-IncludeSelf] \r\n[-ExcludeCmsServer] [-ResolveNetworkName] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Bryan Hamby (@galador)", "Synopsis": "Gets list of SQL Server objects stored in SQL Server Central Management Server (CMS).", "Name": "Get-DbaRegisteredServer", "Links": "https://dbatools.io/Get-DbaRegisteredServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a\r\n\r\nGets a list of servers from the CMS on sqlserver2014a, using Windows Credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a -IncludeSelf\r\n\r\nGets a list of servers from the CMS on sqlserver2014a and includes sqlserver2014a in the output results.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a -SqlCredential $credential | Select-Object -Unique \r\n-ExpandProperty ServerName\r\n\r\nReturns only the server names from the CMS on sqlserver2014a, using SQL Authentication to authenticate to the server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a -Group HR, Accounting\r\n\r\nGets a list of servers in the HR and Accounting groups from the CMS on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a -Group HR\\Development\r\n\r\nReturns a list of servers in the HR and sub-group Development from the CMS on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRegisteredServerGroup", "Description": "Returns an array of Server Groups found in the CMS.", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nGet-DbaRegisteredServerGroup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Group] \r\n\u003cObject[]\u003e] [[-ExcludeGroup] \u003cObject[]\u003e] [[-Id] \u003cInt32[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Tony Wilhelm (@tonywsql)", "Synopsis": "Gets list of Server Groups objects stored in SQL Server Central Management Server (CMS).", "Name": "Get-DbaRegisteredServerGroup", "Links": "https://dbatools.io/Get-DbaRegisteredServerGroup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sqlserver2014a\r\n\r\nGets the top level groups from the CMS on sqlserver2014a, using Windows Credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sqlserver2014a -SqlCredential $credential\r\n\r\nGets the top level groups from the CMS on sqlserver2014a, using alternative credentials to authenticate to the server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sqlserver2014a -Group HR, Accounting\r\n\r\nGets the HR and Accounting groups from the CMS on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sqlserver2014a -Group HR\\Development\r\n\r\nReturns the sub-group Development of the HR group from the CMS on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRegisteredServerStore", "Description": "Returns a SQL Server Registered Server Store object - useful for working with Central Management Store", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nGet-DbaRegisteredServerStore [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Returns a SQL Server Registered Server Store Object", "Name": "Get-DbaRegisteredServerStore", "Links": "https://dbatools.io/Get-DbaRegisteredServerStore", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerStore -SqlInstance sqlserver2014a\r\n\r\nReturns a SQL Server Registered Server Store Object from sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerStore -SqlInstance sqlserver2014a -SqlCredential (Get-Credential sqladmin)\r\n\r\nReturns a SQL Server Registered Server Store Object from sqlserver2014a by logging in with the sqladmin login\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRegistryRoot", "Description": "Uses SQL WMI to find the Registry Root of each SQL Server instance on a computer", "Tags": [ "Configuration", "Registry" ], "Syntax": "\r\nGet-DbaRegistryRoot [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegistryRoot\r\n\r\nGets the registry root for all instances on localhost\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegistryRoot -ComputerName server1\r\n\r\nGets the registry root for all instances on server1\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRepDistributor", "Description": "This function locates and enumerates distributor information for a given SQL Server instance.", "Tags": "Replication", "Syntax": "\r\nGet-DbaRepDistributor [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepDistributor -SqlInstance sql2008, sqlserver2012\r\n\r\nRetrieve distributor information for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRepPublication", "Description": "Quickly find all transactional, merge, and snapshot publications on a specific server or database.", "Tags": "Replication", "Syntax": "\r\nGet-DbaRepPublication [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Database] \u003cObject[]\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [[-PublicationType] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Colin Douglas", "Synopsis": "Displays all publications for a server or database.", "Name": "Get-DbaRepPublication", "Links": "https://dbatools.io/Get-DbaRepPublication", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepPublication -SqlInstance sql2008, sqlserver2012\r\n\r\nReturn all publications for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepPublication -SqlInstance sql2008 -Database TestDB\r\n\r\nReturn all publications on server sql2008 for only the TestDB database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepPublication -SqlInstance sql2008 -PublicationType Transactional\r\n\r\nReturn all publications on server sql2008 for all databases that have Transactional publications\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRepServer", "Description": "Gets a replication server object", "Tags": "Replication", "Syntax": "\r\nGet-DbaRepServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets a replication server object", "Name": "Get-DbaRepServer", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepServer -SqlInstance sql2016\r\n\r\nGets the replication server object for sql2016 using Windows authentication\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRepServer -SqlInstance sql2016 -SqlCredential repadmin\r\n\r\nGets the replication server object for sql2016 using SQL authentication\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaResourceGovernor", "Description": "Gets the Resource Governor object", "Tags": "ResourceGovernor", "Syntax": "\r\nGet-DbaResourceGovernor [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets the Resource Governor object", "Name": "Get-DbaResourceGovernor", "Links": "https://dbatools.io/Get-DbaResourceGovernor", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaResourceGovernor -SqlInstance sql2016\r\n\r\nGets the resource governor object of the SqlInstance sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor\r\n\r\nGets the resource governor object on Sql1 and Sql2/sqlexpress instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRestoreHistory", "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" ], "Syntax": "\r\nGet-DbaRestoreHistory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Since] \u003cDateTime\u003e] [-Force] [-Last] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Returns restore history details for databases on a SQL Server.", "Name": "Get-DbaRestoreHistory", "Links": "https://dbatools.io/Get-DbaRestoreHistory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRestoreHistory -SqlInstance sql2016\r\n\r\nReturns server name, database, username, restore type, date for all restored databases on sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRestoreHistory -SqlInstance sql2016 -Database db1, db2 -Since \u00277/1/2016 10:47:00\u0027\r\n\r\nReturns restore information only for databases db1 and db2 on sql2016 since July 1, 2016 at 10:47 AM.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRestoreHistory -SqlInstance sql2014, sql2016 -Exclude db1\r\n\r\nLots of detailed information for all databases except db1 on sql2014 and sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRestoreHistory -SqlInstance sql2014 -Database AdventureWorks2014, pubs | Format-Table\r\n\r\nAdds From and To file information to output, returns information only for AdventureWorks2014 and pubs, and formats the \r\ndata as a table.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2016 | Get-DbaRestoreHistory\r\n\r\nReturns database restore information for every database on every server listed in the Central Management Server on \r\nsql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRgClassifierFunction", "Description": "Gets the Resource Governor custom classifier Function which is used for customize the workload groups usage", "Tags": [ "Migration", "ResourceGovernor" ], "Syntax": "\r\nGet-DbaRgClassifierFunction [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \r\n\u003cResourceGovernor[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Alessandro Alpi (@suxstellino), alessandroalpi.blog", "Synopsis": "Gets the Resource Governor custom classifier Function", "Name": "Get-DbaRgClassifierFunction", "Links": "https://dbatools.io/Get-DbaRgClassifierFunction", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRgClassifierFunction -SqlInstance sql2016\r\n\r\nGets the classifier function from sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor | Get-DbaRgClassifierFunction\r\n\r\nGets the classifier function object on Sql1 and Sql2/sqlexpress instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRgResourcePool", "Description": "Gets Resource Governor Pool objects, including internal or external", "Tags": "ResourceGovernor", "Syntax": "\r\nGet-DbaRgResourcePool [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Type] \u003cString\u003e] \r\n[[-InputObject] \u003cResourceGovernor[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRgResourcePool -SqlInstance sql2016\r\n\r\nGets the internal resource pools on sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor | Get-DbaRgResourcePool\r\n\r\nGets the internal resource pools on Sql1 and Sql2/sqlexpress instances\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027Sql1\u0027,\u0027Sql2/sqlexpress\u0027 | Get-DbaResourceGovernor | Get-DbaRgResourcePool -Type External\r\n\r\nGets the external resource pools on Sql1 and Sql2/sqlexpress instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRgWorkloadGroup", "Description": "Gets all Resource Governor Pool objects, including both internal and external", "Tags": "ResourceGovernor", "Syntax": "\r\nGet-DbaRgWorkloadGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-InputObject] \r\n\u003cResourcePool[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRgWorkloadGroup -SqlInstance sql2017\r\n\r\nGets the workload groups on sql2017\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaResourceGovernor -SqlInstance sql2017 | Get-DbaRgResourcePool | Get-DbaRgWorkloadGroup\r\n\r\nGets the workload groups on sql2017\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRoleMember", "Description": "Get members of all roles on a Sql instance.\n\nDefault output includes columns SQLServer, Database, Role, Member.", "Tags": [ "Role", "Database", "Security", "Login" ], "Syntax": "\r\nGet-DbaRoleMember [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeServerLevel] [-NoFixedRole] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Get members of all roles on a Sql instance.", "Name": "Get-DbaRoleMember", "Links": "https://dbatools.io/Get-DbaRoleMember", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRoleMember -SqlInstance ServerA\r\n\r\nReturns a custom object displaying SQLServer, Database, Role, Member for all DatabaseRoles.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRoleMember -SqlInstance sql2016 | Out-Gridview\r\n\r\nReturns a gridview displaying SQLServer, Database, Role, Member for all DatabaseRoles.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRoleMember -SqlInstance ServerA\\sql987 -IncludeServerLevel\r\n\r\nReturns a gridview displaying SQLServer, Database, Role, Member for both ServerRoles and DatabaseRoles.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaRunningJob", "Description": "This function returns agent jobs that active on the SQL Server instance when calling the command. The information is gathered the SMO JobServer.jobs and be returned either in detailed or standard format.", "Tags": [ "Process", "Session", "ActivityMonitor", "Agent", "Job" ], "Syntax": "\r\nGet-DbaRunningJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRunningJob -SqlInstance localhost\r\n\r\nReturns any active jobs on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRunningJob -SqlInstance localhost -Detailed\r\n\r\nReturns a detailed output of any active jobs on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaRunningJob\r\n\r\nReturns all active jobs on multiple instances piped into the function.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaSchemaChangeHistory", "Description": "Queries the default system trace for any DDL changes in the specified timeframe\nOnly works with SQL 2005 and later, as the system trace didn\u0027t exist before then", "Tags": [ "Migration", "Backup", "Database" ], "Syntax": "\r\nGet-DbaSchemaChangeHistory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \r\n\u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-Since \u003cDbaDateTime\u003e] [-Object \u003cString[]\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost\r\n\r\nReturns all DDL changes made in all databases on the SQL Server instance localhost since the system trace began\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost -Since (Get-Date).AddDays(-7)\r\n\r\nReturns all DDL changes made in all databases on the SQL Server instance localhost in the last 7 days\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance, Prod -Since (Get-Date).AddDays(-7)\r\n\r\nReturns all DDL changes made in the Prod and Finance databases on the SQL Server instance localhost in the last 7 days\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSchemaChangeHistory -SqlInstance localhost -Database Finance -Object AccountsTable -Since \r\n(Get-Date).AddDays(-7)\r\n\r\nReturns all DDL changes made to the AccountsTable object in the Finance database on the SQL Server instance localhost \r\nin the last 7 days\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaServerAudit", "Description": "The Get-DbaServerAudit command gets SQL Security Audit information for each instance(s) of SQL Server.", "Tags": [ "Audit", "Security", "SqlAudit" ], "Syntax": "\r\nGet-DbaServerAudit [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Audit \u003cString[]\u003e] \r\n[-ExcludeAudit \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerAudit -SqlInstance localhost\r\n\r\nReturns all Security Audits on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerAudit -SqlInstance localhost, sql2016\r\n\r\nReturns all Security Audits for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaServerAuditSpecification [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerAuditSpecification -SqlInstance localhost\r\n\r\nReturns all Security Audit Specifications on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerAuditSpecification -SqlInstance localhost, sql2016\r\n\r\nReturns all Security Audit Specifications for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaServerInstallDate", "Description": "By default, this command returns for each SQL Instance instance passed in:\nSQL Instance install date, formatted as a string\nHosting Windows server install date, formatted as a string", "Tags": "CIM", "Syntax": "\r\nGet-DbaServerInstallDate [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [-IncludeWindows] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Mitchell Hamann (@SirCaptainMitch), mitchellhamann.com", "Synopsis": "Returns the install date of a SQL Instance and Windows Server, depending on what is passed.", "Name": "Get-DbaServerInstallDate", "Links": "https://dbatools.io/Get-DbaServerInstallDate", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance SqlBox1\\Instance2\r\n\r\nReturns an object with SQL Instance Install date as a string and the Windows install date as string.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance winserver\\sqlexpress, sql2016\r\n\r\nReturns an object with SQL Instance Install date as a string and the Windows install date as a string for both \r\nSQLInstances that are passed to the cmdlet.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance sqlserver2014a, sql2016\r\n\r\nReturns an object with only the SQL Server Install date as a string.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerInstallDate -SqlInstance sqlserver2014a, sql2016 -IncludeWindows\r\n\r\nReturns an object with the Windows Install date and the SQL install date as a string.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2014 | Get-DbaServerInstallDate\r\n\r\nReturns an object with SQL Instance install date as a string for every server listed in the Central Management Server \r\non sql2014\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaServerProtocol [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerProtocol -ComputerName sqlserver2014a\r\n\r\nGets the SQL Server related server protocols on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaServerProtocol\r\n\r\nGets the SQL Server related server protocols on computers sql1, sql2 and sql3.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerProtocol -ComputerName sql1,sql2 | Out-Gridview\r\n\r\nGets the SQL Server related server protocols on computers sql1 and sql2, and shows them in a grid view.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e(Get-DbaServerProtocol -ComputerName sql1 | Where { $_.DisplayName = \u0027via\u0027 }).Disable()\r\n\r\nDisables the VIA ServerNetworkProtocol on computer sql1.\r\nIf successful, returncode 0 is shown.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaServerRole", "Description": "Gets the list of server-level roles for SQL Server instance.", "Tags": [ "ServerRole", "Security" ], "Syntax": "\r\nGet-DbaServerRole [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-ServerRole \u003cObject[]\u003e] \r\n[-ExcludeServerRole \u003cObject[]\u003e] [-ExcludeFixedRole] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Gets the list of server-level roles.", "Name": "Get-DbaServerRole", "Links": "https://dbatools.io/Get-DbaServerRole", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerRole -SqlInstance sql2016a\r\n\r\nOutputs list of server-level roles for sql2016a instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerRole -SqlInstance sql2017a -ExcludeFixedRole\r\n\r\nOutputs the server-level role(s) that are not fixed roles on sql2017a instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaServerTrigger", "Description": "Get all existing server triggers on one or more SQL instances.", "Tags": [ "Database", "Trigger" ], "Syntax": "\r\nGet-DbaServerTrigger [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerTrigger -SqlInstance sql2017\r\n\r\nReturns all server triggers on sql2017\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaService", "Description": "Gets the SQL Server related services on one or more computers.", "Tags": [ "Service", "SqlServer", "Instance", "Connect" ], "Syntax": "\r\nGet-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Credential \u003cPSCredential\u003e] \r\n[-Type \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-ServiceName \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "Synopsis": "Gets the SQL Server related services on a computer.", "Name": "Get-DbaService", "Links": "https://dbatools.io/Get-DbaService", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaService -ComputerName sqlserver2014a\r\n\r\nGets the SQL Server related services on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Get-DbaService\r\n\r\nGets the SQL Server related services on computers sql1, sql2 and sql3.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaService -ComputerName sql1,sql2 | Out-GridView\r\n\r\nGets the SQL Server related services on computers sql1 and sql2, and shows them in a grid view.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaService -ComputerName $MyServers -Type SSRS\r\n\r\nGets the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$services = Get-DbaService -ComputerName sql1 -Type Agent,Engine\r\n\r\n$services.ChangeStartMode(\u0027Manual\u0027)\r\n\r\nGets the SQL Server related services of types Sql Agent and DB Engine on computer sql1 and changes their startup mode \r\nto \u0027Manual\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e(Get-DbaService sql1 -Type Engine).Restart($true)\r\n\r\nCalls a Restart method for each Engine service on computer sql1 with -Force option.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaSpConfigure [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Name \u003cString[]\u003e] \r\n[-ExcludeName \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance localhost\r\n\r\nReturns all system configuration information on the localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027,\u0027localhost\\namedinstance\u0027 | Get-DbaSpConfigure\r\n\r\nReturns system configuration information on multiple instances piped into the function\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance sql2012 -Name \u0027max server memory (MB)\u0027\r\n\r\nReturns only the system configuration for MaxServerMemory on sql2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance sql2012 -ExcludeName \u0027max server memory (MB)\u0027, RemoteAccess | Out-GridView\r\n\r\nReturns system configuration information on sql2012 but excludes for \u0027max server memory (MB)\u0027 and \u0027remote access\u0027. \r\nValues returned in GridView\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential SqlCredential\r\n\r\n\u0027sql2012\u0027 | Get-DbaSpConfigure -SqlCredential $cred -Name RemoteAccess, \u0027max server memory (MB)\u0027 -ExcludeName \u0027remote \r\naccess\u0027 | Out-GridView\r\n\r\nReturns system configuration information on sql2012 using SQL Server Authentication. Only MaxServerMemory is returned \r\nas RemoteAccess was also excluded.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaSpn [[-ComputerName] \u003cString[]\u003e] [[-AccountName] \u003cString[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpn -ServerName SQLSERVERA -Credential (Get-Credential)\r\n\r\nReturns a custom object with SearchTerm (ServerName) and the SPNs that were found\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpn -AccountName domain\\account -Credential (Get-Credential)\r\n\r\nReturns a custom object with SearchTerm (domain account) and the SPNs that were found\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpn -ServerName SQLSERVERA,SQLSERVERB -Credential (Get-Credential)\r\n\r\nReturns a custom object with SearchTerm (ServerName) and the SPNs that were found for multiple computers\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaSsisEnvironmentVariable [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[[-Environment] \u003cObject[]\u003e] [[-EnvironmentExclude] \u003cObject[]\u003e] [[-Folder] \u003cObject[]\u003e] [[-FolderExclude] \u003cObject[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV -Folder DWH_ETL\r\n\r\nGets variables of \u0027DEV\u0027 environment located in \u0027DWH_ETL\u0027 folder on \u0027localhost\u0027 Server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV -Folder DWH_ETL, DEV2, QA\r\n\r\nGets variables of \u0027DEV\u0027 environment(s) located in folders \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV -FolderExclude DWH_ETL, DEV2, QA\r\n\r\nGets variables of \u0027DEV\u0027 environments located in folders other than \u0027DWH_ETL\u0027, \u0027DEV2\u0027 and \u0027QA\u0027 on \u0027localhost\u0027 server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -Environment DEV, PROD -Folder DWH_ETL, DEV2, QA\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -EnvironmentExclude DEV, PROD -Folder DWH_ETL, DEV2, QA\r\n\r\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 \r\nserver\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisEnvironmentVariable -SqlInstance localhost -EnvironmentExclude DEV, PROD -FolderExclude DWH_ETL, \r\nDEV2, QA\r\n\r\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 \r\n\u0027localhost\u0027 server\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027 | Get-DbaSsisEnvironmentVariable -EnvironmentExclude DEV, PROD\r\n\r\nGets all SSIS environments except \u0027DEV\u0027 and \u0027PROD\u0027 from \u0027localhost\u0027 server. The server name comes from pipeline\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003e\u0027SRV1\u0027, \u0027SRV3\u0027 | Get-DbaSsisEnvironmentVariable\r\n\r\nGets all SSIS environments from \u0027SRV1\u0027 and \u0027SRV3\u0027 servers. The server\u0027s names come from pipeline\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003e\u0027SRV1\u0027, \u0027SRV2\u0027 | Get-DbaSsisEnvironmentVariable DEV | Out-GridView\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003e\u0027localhost\u0027 | Get-DbaSsisEnvironmentVariable -EnvironmentExclude DEV, PROD | Select-Object -Property Name, Value \r\n| Where-Object {$_.Name -match \u0027^a\u0027} | Out-GridView\r\n\r\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaSsisExecutionHistory [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Since] \r\n\u003cDateTime\u003e] [[-Status] \u003cString[]\u003e] [[-Project] \u003cString[]\u003e] [[-Folder] \u003cString[]\u003e] [[-Environment] \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chris Tucker (ChrisTucker, @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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisExecutionHistory -SqlInstance SMTQ01 -Folder SMTQ_PRC\r\n\r\nGet all history items for SMTQ01 in folder SMTQ_PRC.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisExecutionHistory -SqlInstance SMTQ01 -Status Failed,Cancelled\r\n\r\nGets all failed or canceled executions for SMTQ01.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSsisExecutionHistory -SqlInstance SMTQ01,SMTQ02 -Status Failed,Cancelled -Whatif\r\n\r\nShows what would happen if the command were executed and would return the SQL statement that would be executed per \r\ninstance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaStartupParameter [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-Simple] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaStartupParameter -SqlInstance sql2014\r\n\r\nLogs into SQL WMI as the current user then displays the values for numerous startup parameters.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\r\n\r\nGet-DbaStartupParameter -SqlInstance sql2014 -Credential $wincred -Simple\r\n\r\nLogs in to WMI using the ad\\sqladmin credential and gathers simplified information about the SQL Server Startup \r\nParameters.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaSuspectPage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Database \u003cObject\u003e] [-SqlCredential \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSuspectPage -SqlInstance sql2016\r\n\r\nRetrieve any records stored for Suspect Pages on the sql2016 SQL Server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSuspectPage -SqlInstance sql2016 -Database Test\r\n\r\nRetrieve any records stored for Suspect Pages on the sql2016 SQL Server and the Test database only.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaTcpPort", "Description": "By default, this function returns just the TCP port used by the specified SQL Server.\n\nIf -Detailed 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" ], "Syntax": "\r\nGet-DbaTcpPort [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Detailed] [-ExcludeIpv6] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTcpPort -SqlInstance sqlserver2014a\r\n\r\nReturns just the port number for the default instance on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTcpPort -SqlInstance winserver\\sqlexpress, sql2016\r\n\r\nReturns an object with server name and port number for the sqlexpress on winserver and the default instance on sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTcpPort -SqlInstance sqlserver2014a, sql2016 -Detailed\r\n\r\nReturns an object with server name, IPAddress (ipv4 and ipv6), port and static ($true/$false) for sqlserver2014a and \r\nsql2016.\r\n\r\nRemote sqlwmi is used by default. If this doesn\u0027t work, then remoting is used. If neither work, it defaults to T-SQL \r\nwhich can provide only the port.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2014 | Get-DbaTcpPort -ExcludeIpv6 -Detailed\r\n\r\nReturns an object with server name, IPAddress (just ipv4), port and static ($true/$false) for every server listed in \r\nthe Central Management Server on sql2014.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaTempdbUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets Tempdb usage for running queries.", "Name": "Get-DbaTempdbUsage", "Links": "https://dbatools.io/Get-DbaTempdbUsage", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTempdbUsage -SqlInstance localhost\\SQLDEV2K14\r\n\r\nGets tempdb usage for localhost\\SQLDEV2K14\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbatoolsConfig", "Description": "Retrieves configuration elements by name.\nCan be used to search the existing configuration list.", "Tags": [ "Config", "Module" ], "Syntax": "\r\nGet-DbatoolsConfig [[-FullName] \u003cString\u003e] [-Force] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbatoolsConfig [[-Name] \u003cString\u003e] [[-Module] \u003cString\u003e] [-Force] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Friedrich Weinmann", "Synopsis": "Retrieves configuration elements by name.", "Name": "Get-DbatoolsConfig", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsConfig \u0027Mail.To\u0027\r\n\r\nRetrieves the configuration element for the key \"Mail.To\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsConfig -Force\r\n\r\nRetrieve all configuration elements from all modules, even hidden ones.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbatoolsConfigValue [-FullName] \u003cString\u003e [[-Fallback] \u003cObject\u003e] [-NotNull] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Friedrich Weinmann", "Synopsis": "Returns the configuration value stored under the specified name.", "Name": "Get-DbatoolsConfigValue", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsConfigValue -Name \u0027System.MailServer\u0027\r\n\r\nReturns the configured value that was assigned to the key \u0027System.MailServer\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsConfigValue -Name \u0027Default.CoffeeMilk\u0027 -Fallback 0\r\n\r\nReturns the configured value for \u0027Default.CoffeeMilk\u0027. If no such value is configured, it returns \u00270\u0027 instead.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbatoolsLog", "Description": "Returns log entries for dbatools. Handy when debugging or developing a script using it.", "Syntax": "\r\nGet-DbatoolsLog [[-FunctionName] \u003cString\u003e] [[-ModuleName] \u003cString\u003e] [[-Target] \u003cObject\u003e] [[-Tag] \u003cString[]\u003e] [[-Last] \r\n\u003cInt32\u003e] [[-Skip] \u003cInt32\u003e] [[-Runspace] \u003cGuid\u003e] [[-Level] {Critical | Important | Output | Significant | VeryVerbose | \r\nVerbose | SomewhatVerbose | System | Debug | InternalComment | Warning}] [-Errors] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Returns log entries for dbatools", "Name": "Get-DbatoolsLog", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsLog\r\n\r\nReturns all log entries currently in memory.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsLog -Target \"a\" -Last 1 -Skip 1\r\n\r\nReturns all log entries that targeted the object \"a\" in the second last execution sent.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsLog -Tag \"fail\" -Last 5\r\n\r\nReturns all log entries within the last 5 executions that contained the tag \"fail\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaTopResourceUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-Type \u003cString[]\u003e] [-Limit \u003cInt32\u003e] [-EnableException] [-ExcludeSystem] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2008, sql2012\r\n\r\nReturn the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and \r\nsql2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2008 -Type Duration, Frequency -Database TestDB\r\n\r\nReturn the highest usage by duration (top 20) and frequency (top 20) for the TestDB on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2016 -Limit 30\r\n\r\nReturn the highest usage by duration (top 30) and frequency (top 30) for the TestDB on sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2008, sql2012 -ExcludeSystem\r\n\r\nReturn the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and \r\nsql2012 without any System Objects\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTopResourceUsage -SqlInstance sql2016| Select *\r\n\r\nReturn all the columns plus the QueryPlan column\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaTrace [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Id \u003cInt32[]\u003e] [-Default] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2016\r\n\r\nLists all the tracefiles on the sql2016 SQL Server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2016 -Default\r\n\r\nLists the default trace information on the sql2016 SQL Server.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaTraceFlag", "Description": "Returns Trace Flags that are enabled globally on each instance(s) of SQL Server as an object.", "Tags": "TraceFlag", "Syntax": "\r\nGet-DbaTraceFlag [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-TraceFlag \u003cInt32[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTraceFlag -SqlInstance localhost\r\n\r\nReturns all Trace Flag information on the local default SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTraceFlag -SqlInstance localhost, sql2016\r\n\r\nReturns all Trace Flag(s) for the local and sql2016 SQL Server instances\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTraceFlag -SqlInstance localhost -TraceFlag 4199,3205\r\n\r\nReturns Trace Flag status for TF 4199 and 3205 for the local SQL Server instance if they are enabled.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nGet-DbaUptime [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaUptime -SqlInstance SqlBox1\\Instance2\r\n\r\nReturns an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot \r\ntime, host uptime as TimeSpan objects and host uptime as a string for the sqlexpress instance on winserver\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaUptime -SqlInstance winserver\\sqlexpress, sql2016\r\n\r\nReturns an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot \r\ntime, host uptime as TimeSpan objects and host uptime as a string for the sqlexpress instance on host winserver and \r\nthe default instance on host sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2014 | Get-DbaUptime\r\n\r\nReturns an object with SQL Server start time, uptime as TimeSpan object, uptime as a string, and Windows host boot \r\ntime, host uptime as TimeSpan objects and host uptime as a string for every server listed in the Central Management \r\nServer on sql2014\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaUserPermission [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [[-ExcludeSystemDatabase]] [-IncludePublicGuest] [-IncludeSystemObjects] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaUserPermission -SqlInstance sql2008, sqlserver2012\r\n\r\nCheck server and database permissions for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaUserPermission -SqlInstance sql2008 -Database TestDB\r\n\r\nCheck server and database permissions on server sql2008 for only the TestDB database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaUserPermission -SqlInstance sql2008 -Database TestDB -IncludePublicGuest -IncludeSystemObjects\r\n\r\nCheck server and database permissions on server sql2008 for only the TestDB database,\r\nincluding public and guest grants, and sys schema objects.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nGet-DbaWaitingTask [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cObject[]\u003e] \r\n[-IncludeSystemSpid] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton)", "Synopsis": "Displays waiting task.", "Name": "Get-DbaWaitingTask", "Links": "https://dbatools.io/Get-DbaWaitingTask", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitingTask -SqlInstance sqlserver2014a\r\n\r\nReturns the waiting task for all sessions on sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitingTask -SqlInstance sqlserver2014a -IncludeSystemSpid\r\n\r\nReturns the waiting task for all sessions (user and system) on sqlserver2014a\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaWaitResource", "Description": "Given a wait resource in the form of:\n \u0027PAGE: 10:1:9180084 \u0027\nreturns the database, data file and the system object which is being waited up.\nGiven a wait resource in the form of:\n \u0027KEY: 7:35457594073541168 (de21f92a1572)\u0027\nreturns the database, object and index that is being waited on, With the -row switch the row data will also be returned.", "Tags": [ "Pages", "DBCC" ], "Syntax": "\r\nGet-DbaWaitResource [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-WaitResource] \u003cString\u003e \r\n[-Row] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Returns the resource being waited upon", "Name": "Get-DbaWaitResource", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitResource -SqlInstance server1 -WaitResource \u0027PAGE: 10:1:9180084\u0027\r\n\r\nWill return an object containing; database name, data file name, schema name and the object which owns the resource\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitResource -Sql Instance server2 -WaitResource \u0027KEY: 7:35457594073541168 (de21f92a1572)\u0027\r\n\r\nWill return an object containing; database name, schema name and index name which is being waited on.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitResource -Sql Instance server2 -WaitResource \u0027KEY: 7:35457594073541168 (de21f92a1572)\u0027 -row\r\n\r\nWill return an object containing; database name, schema name and index name which is being waited on, and in addition \r\nthe contents of the locked row at the time the command is run.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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:\n WaitType\n Category\n WaitSeconds\n ResourceSeconds\n SignalSeconds\n WaitCount\n Percentage\n AverageWaitSeconds\n AverageResourceSeconds\n AverageSignalSeconds\n URL\n\nReference: https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/", "Tags": "WaitStatistic", "Syntax": "\r\nGet-DbaWaitStatistic [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Threshold \u003cInt32\u003e] \r\n[-IncludeIgnorable] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Displays wait statistics", "Name": "Get-DbaWaitStatistic", "Links": "https://dbatools.io/Get-DbaWaitStatistic", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitStatistic -SqlInstance sql2008, sqlserver2012\r\n\r\nCheck wait statistics for servers sql2008 and sqlserver2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitStatistic -SqlInstance sql2008 -Threshold 98 -IncludeIgnorable\r\n\r\nCheck wait statistics on server sql2008 for thresholds above 98% and include wait stats that are most often, but not \r\nalways, ignorable\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaWaitStatistic -SqlInstance sql2008 | Select *\r\n\r\nShows detailed notes, if available, from Paul\u0027s post\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$output = Get-DbaWaitStatistic -SqlInstance sql2008 -Threshold 100 -IncludeIgnorable | Select * | \r\nConvertTo-DbaDataTable\r\n\r\nCollects all Wait Statistics (including ignorable waits) on server sql2008 into a Data Table.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$output = Get-DbaWaitStatistic -SqlInstance sql2008\r\n\r\n$output\r\nforeach ($row in ($output | Sort-Object -Unique Url)) { Start-Process ($row).Url }\r\n\r\nDisplays the output then loads the associated sqlskills website for each result. Opens one tab per unique URL.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaWindowsLog", "Description": "Gets Windows Application events associated with an instance", "Tags": "Logging", "Syntax": "\r\nGet-DbaWindowsLog [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Start] \u003cDateTime\u003e] [[-End] \u003cDateTime\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [[-MaxThreads] \u003cInt32\u003e] [[-MaxRemoteThreads] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Drew Furgiuele", "Synopsis": "Gets Windows Application events associated with an instance", "Name": "Get-DbaWindowsLog", "Links": "https://dbatools.io/Get-DbaWindowsLog", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$ErrorLogs = Get-DbaWindowsLog -SqlInstance sql01\\sharepoint\r\n\r\n$ErrorLogs | Where-Object ErrorNumber -eq 18456\r\n\r\nReturns all lines in the errorlogs that have event number 18456 in them\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaXEObject", "Description": "This function returns a list of Traces on the specified SQL Server instance(s) and identifies the default Trace File", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nGet-DbaXEObject [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Type \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets a list of trace(s) from specified SQL Server instance(s).", "Name": "Get-DbaXEObject", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXEObject -SqlInstance sql2016\r\n\r\nLists all the XE Objects on the sql2016 SQL Server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXEObject -SqlInstance sql2017 -Type Action, Event\r\n\r\nLists all the XE Objects of type Action and Event on the sql2017 SQL Server.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaXESession", "Description": "Retrieves a list of Extended Events Sessions present on the specified SQL Server instance(s).", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nGet-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Session] \u003cObject[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance ServerA\\sql987\r\n\r\nReturns a custom object with ComputerName, SQLInstance, Session, StartTime, Status and other properties.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance ServerA\\sql987 | Format-Table ComputerName, SqlInstance, Session, Status -AutoSize\r\n\r\nReturns a formatted table displaying ComputerName, SqlInstance, Session, and Status.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\u0027ServerA\\sql987\u0027,\u0027ServerB\u0027 | Get-DbaXESession\r\n\r\nReturns a custom object with ComputerName, SqlInstance, Session, StartTime, Status and other properties, from multiple \r\nSQL instances.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaXESessionTarget", "Description": "Retrieves a list of Extended Events Session Targets from the specified SQL Server instance(s).", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nGet-DbaXESessionTarget [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString[]\u003e] [-Target \u003cString[]\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\nGet-DbaXESessionTarget -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString[]\u003e] \r\n[-Target \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nGet-DbaXESessionTarget [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString[]\u003e] [-Target \u003cString[]\u003e] -InputObject \r\n\u003cSession[]\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTarget -SqlInstance ServerA\\sql987 -Session system_health\r\n\r\nShows targets for the system_health session on ServerA\\sql987.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2016 -Session system_health | Get-DbaXESessionTarget\r\n\r\nReturns the targets for the system_health session on sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2016 -Session system_health | Get-DbaXESessionTarget -Target package0.event_file\r\n\r\nReturn only the package0.event_file target for the system_health session on sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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:\n Microsoft\u0027s Templates that come with SSMS\n Jes Borland\u0027s \"Everyday Extended Events\" presentation and GitHub repository (https://github.com/grrlgeek/extended-events)\n Christian Gräfe\u0027s XE Repo: https://github.com/chrgraefe/sqlscripts/blob/master/XE-Events/\n Erin Stellato\u0027s Blog: https://www.sqlskills.com/blogs/erin/\n\nSome profile templates converted using:\n sp_SQLskills_ConvertTraceToExtendedEvents.sql\n Jonathan M. Kehayias, SQLskills.com\n http://sqlskills.com/blogs/jonathan", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nGet-DbaXESessionTemplate [[-Path] \u003cString[]\u003e] [[-Pattern] \u003cString\u003e] [[-Template] \u003cString[]\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTemplate\r\n\r\nReturns information about all the templates in the local dbatools repository.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTemplate | Out-GridView -PassThru | Import-DbaXESessionTemplate -SqlInstance sql2017 | \r\nStart-DbaXESession\r\n\r\nAllows you to select a Session template, then import it to the specified instance and start the session.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTemplate -Path \"$home\\Documents\\SQL Server Management Studio\\Templates\\XEventTemplates\"\r\n\r\nReturns information about all the templates in your local XEventTemplates repository.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTemplate -Pattern duration\r\n\r\nReturns information about all the templates that match the word \"duration\" in the title, category or body.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTemplate | Select-Object *\r\n\r\nReturns more information about the template, including the full path/filename.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaXESmartTarget", "Description": "Gets an XESmartTarget PowerShell Job created by Start-DbaXESmartTarget.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nGet-DbaXESmartTarget [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets an XESmartTarget PowerShell Job created by Start-DbaXESmartTarget.", "Name": "Get-DbaXESmartTarget", "Links": "https://dbatools.io/Get-DbaXESmartTarget\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESmartTarget\r\n\r\nGets an XESmartTarget PowerShell Job created by Start-DbaXESmartTarget.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Get-DbaXEStore", "Description": "Get a Extended Events store", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nGet-DbaXEStore [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Get a Extended Events store", "Name": "Get-DbaXEStore", "Links": "https://dbatools.io/Get-DbaXEStore", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXEStore -SqlInstance ServerA\\sql987\r\n\r\nReturns an XEvent Store.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nImport-DbaCsvToSql [-Csv \u003cString[]\u003e] -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cObject\u003e] [-Table \u003cString\u003e] \r\n[-Schema \u003cString\u003e] [-Truncate] [-Delimiter \u003cString\u003e] [-SingleColumn] [-FirstRowColumns] [-First \u003cInt32\u003e] [-BatchSize \r\n\u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-TableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] \r\n[-shellswitch] [-SqlCredentialPath \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\nImport-DbaCsvToSql [-Csv \u003cString[]\u003e] -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cObject\u003e] [-Table \u003cString\u003e] \r\n[-Schema \u003cString\u003e] [-Truncate] [-Delimiter \u003cString\u003e] [-SingleColumn] [-FirstRowColumns] [-Turbo] [-First \u003cInt32\u003e] \r\n[-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-TableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] \r\n[-KeepNulls] [-shellswitch] [-SqlCredentialPath \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\nImport-DbaCsvToSql [-Csv \u003cString[]\u003e] -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cObject\u003e] [-Table \u003cString\u003e] \r\n[-Schema \u003cString\u003e] [-Truncate] [-Delimiter \u003cString\u003e] [-SingleColumn] [-FirstRowColumns] [-Safe] [-First \u003cInt32\u003e] \r\n[-Query \u003cString\u003e] [-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] [-TableLock] [-CheckConstraints] [-FireTriggers] \r\n[-KeepIdentity] [-KeepNulls] [-shellswitch] [-SqlCredentialPath \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv C:\\temp\\housing.csv -SqlInstance sql001 -Database markets\r\n\r\nImports the entire comma-delimited housing.csv to the SQL \"markets\" database on a SQL Server named sql001.\r\n\r\nSince a table name was not specified, the table name is automatically determined from filename as \"housing\" and a \r\nprompt will appear to confirm table name.\r\n\r\nThe first row is not skipped, as it does not contain column names.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv .\\housing.csv -SqlInstance sql001 -Database markets -Table housing -First 100000 -Safe \r\n-Delimiter \"`t\" -FirstRowColumns\r\n\r\nImports the first 100,000 rows of the tab delimited housing.csv file to the \"housing\" table in the \"markets\" database \r\non a SQL Server named sql001. Since -Safe was specified, the OleDB method will be used for the bulk import. The first \r\nrow is skipped, as it contains column names.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -csv C:\\temp\\huge.txt -SqlInstance sqlcluster -Database locations -Table latitudes -Delimiter \r\n\"|\" -Turbo\r\n\r\nImports all records from the pipe delimited huge.txt file using the fastest method possible into the latitudes table \r\nwithin the locations database. Obtains a table lock for the duration of the bulk copy operation. This specific command \r\nhas been used\r\nto import over 10.5 million rows in 2 minutes.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv C:\\temp\\housing.csv, .\\housing2.csv -SqlInstance sql001 -Database markets -Table housing \r\n-Delimiter \"`t\" -query \"select top 100000 column1, column3 from csv\" -Truncate\r\n\r\nTruncates the \"housing\" table, then imports columns 1 and 3 of the first 100000 rows of the tab-delimited housing.csv \r\nin the C:\\temp directory, and housing2.csv in the current directory. Since the query is executed against both files, a \r\ntotal of 200,000 rows will be imported.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv C:\\temp\\housing.csv -SqlInstance sql001 -Database markets -Table housing -query \"select \r\naddress, zip from csv where state = \u0027Louisiana\u0027\" -FirstRowColumns -Truncate -FireTriggers\r\n\r\nUses the first line to determine CSV column names. Truncates the \"housing\" table on the SQL Server, then imports the \r\naddress and zip columns from all records in the housing.csv where the state equals Louisiana.\r\n\r\nTriggers are fired for all rows. Note that this does slightly slow down the import.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv c:\\temp\\SingleColumn.csv -SqlInstance sql001 -Database markets -Table TempTable \r\n-SingleColumn\r\n\r\nUpload the single column Csv SingleColumn.csv to Temptable which has just one column\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv \"\\\\FileServer\\To Import\\housing.csv\" -SqlInstance sql001 -Database markets\r\n\r\nImports the entire comma-delimited housing.csv located in the share named \"To Import\" on FileServer to the SQL \r\n\"markets\" database on a SQL Server named sql001.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaCsvToSql -Csv \u0027\\\\FileServer\\R$\\To Import\\housing.csv\u0027 -SqlInstance sql001 -Database markets\r\n\r\nImports the entire comma-delimited housing.csv located in the directory R:\\To Import on FileServer using the \r\nadministrative share to the SQL \"markets\" database on a SQL Server named sql001.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nImport-DbaPfDataCollectorSetTemplate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[[-DisplayName] \u003cString\u003e] [-SchedulesEnabled] [[-RootPath] \u003cString\u003e] [-Segment] [[-SegmentMaxDuration] \u003cInt32\u003e] \r\n[[-SegmentMaxSize] \u003cInt32\u003e] [[-Subdirectory] \u003cString\u003e] [[-SubdirectoryFormat] \u003cInt32\u003e] [[-SubdirectoryFormatPattern] \r\n\u003cString\u003e] [[-Task] \u003cString\u003e] [-TaskRunAsSelf] [[-TaskArguments] \u003cString\u003e] [[-TaskUserTextArguments] \u003cString\u003e] \r\n[-StopOnCompletion] [[-Path] \u003cString[]\u003e] [[-Template] \u003cString[]\u003e] [[-Instance] \u003cString[]\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template \u0027Long Running Query\u0027\r\n\r\nCreates a new data collector set named \u0027Long Running Query\u0027 from the dbatools repository on the SQL Server sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template \u0027Long Running Query\u0027 -DisplayName \u0027New Long \r\nrunning query\u0027 -Confirm\r\n\r\nCreates a new data collector set named \"New Long Running Query\" using the \u0027Long Running Query\u0027 template. Forces a \r\nconfirmation if the template exists.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2017 -Session db_ola_health | Remove-DbaPfDataCollectorSet\r\n\r\nImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template db_ola_health | Start-DbaPfDataCollectorSet\r\n\r\nImports a session if it exists, then recreates it using a template.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSetTemplate | Out-GridView -PassThru | Import-DbaPfDataCollectorSetTemplate -ComputerName \r\nsql2017\r\n\r\nAllows you to select a Session template then import to an instance named sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaPfDataCollectorSetTemplate -ComputerName sql2017 -Template \u0027Long Running Query\u0027 -Instance SHAREPOINT\r\n\r\nCreates a new data collector set named \u0027Long Running Query\u0027 from the dbatools repository on the SQL Server sql2017 for \r\nboth the default and the SHAREPOINT instance.\r\n\r\nIf you\u0027d like to remove counters for the default instance, use Remove-DbaPfDataCollectorCounter.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Import-DbaRegisteredServer", "Description": "Imports registered servers and registered server groups to SQL Server Central Management Server (CMS)", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nImport-DbaRegisteredServer [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Path] \r\n\u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [[-Group] \u003cObject\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Imports registered servers and registered server groups to SQL Server Central Management Server (CMS)", "Name": "Import-DbaRegisteredServer", "Links": "https://dbatools.io/Import-DbaRegisteredServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaRegisteredServer -SqlInstance sql2012 -Path C:\\temp\\corp-regservers.xml\r\n\r\nImports C:\\temp\\corp-regservers.xml to the CMS on sql2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaRegisteredServer -SqlInstance sql2008 -Group hr\\Seattle -Path C:\\temp\\Seattle.xml\r\n\r\nImports C:\\temp\\Seattle.xml to Seattle subgroup within the hr group on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2008, sql2012 | Import-DbaRegisteredServer -SqlInstance sql2017\r\n\r\nImports all registered servers from sql2008 and sql2012 to sql2017\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sql2008 -Group hr\\Seattle | Import-DbaRegisteredServer -SqlInstance \r\nsql2017 -Group Seattle\r\n\r\nImports all registered servers from the hr\\Seattle group on sql2008 to the Seattle group on sql2017\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Import-DbaSpConfigure", "Description": "Updates sp_configure settings on destination server.", "Tags": [ "SpConfig", "Configure", "Configuration" ], "Syntax": "\r\nImport-DbaSpConfigure [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nImport-DbaSpConfigure [-Source \u003cDbaInstanceParameter\u003e] [-Destination \u003cDbaInstanceParameter\u003e] [-SourceSqlCredential \r\n\u003cPSCredential\u003e] [-DestinationSqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nImport-DbaSpConfigure [-SqlInstance \u003cDbaInstanceParameter\u003e] [-Path \u003cString\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Updates sp_configure settings on destination server.", "Name": "Import-DbaSpConfigure", "Links": "https://dbatools.io/Import-DbaSpConfigure", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaSpConfigure -Source sqlserver -Destination sqlcluster\r\n\r\nImports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using Windows \r\nAuthentication\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaSpConfigure -Source sqlserver -Destination sqlcluster -Force\r\n\r\nImports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using Windows \r\nAuthentication. Will not do a version check between Source and Destination\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaSpConfigure -Source sqlserver -Destination sqlcluster -SourceSqlCredential $SourceSqlCredential \r\n-DestinationSqlCredential $DestinationSqlCredential\r\n\r\nImports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using the SQL \r\ncredentials stored in the variables $SourceSqlCredential and $DestinationSqlCredential\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaSpConfigure -SqlInstance sqlserver -Path .\\spconfig.sql -SqlCredential $SqlCredential\r\n\r\nImports the sp_configure settings from the file .\\spconfig.sql and sets them on the sqlserver server using the SQL \r\ncredential stored in the variable $SqlCredential\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Import-DbaXESessionTemplate", "Description": "Imports a new XESession XML Template either from the dbatools repository or a file you specify.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nImport-DbaXESessionTemplate [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \r\n\u003cString\u003e] [[-Path] \u003cString[]\u003e] [[-Template] \u003cString[]\u003e] [[-TargetFilePath] \u003cString\u003e] [[-TargetFileMetadataPath] \r\n\u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Imports a new XESession XML Template", "Name": "Import-DbaXESessionTemplate", "Links": "https://dbatools.io/Import-DbaXESessionTemplate", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaXESessionTemplate -SqlInstance sql2017 -Template db_query_wait_stats\r\n\r\nCreates a new XESession named db_query_wait_stats from the dbatools repository to the SQL Server sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eImport-DbaXESessionTemplate -SqlInstance sql2017 -Template db_query_wait_stats -Name \"Query Wait Stats\"\r\n\r\nCreates a new XESession named \"Query Wait Stats\" using the db_query_wait_stats template.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 -Session db_ola_health | Remove-DbaXESession\r\n\r\nImport-DbaXESessionTemplate -SqlInstance sql2017 -Template db_ola_health | Start-DbaXESession\r\n\r\nImports a session if it exists, then recreates it using a template.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESessionTemplate | Out-GridView -PassThru | Import-DbaXESessionTemplate -SqlInstance sql2017\r\n\r\nAllows you to select a Session template then import to an instance named sql2017.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInstall-DbaFirstResponderKit [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Branch] \r\n\u003cString\u003e] [[-Database] \u003cObject\u003e] [[-LocalFile] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance server1 -Database master\r\n\r\nLogs into server1 with Windows authentication and then installs the FRK in the master database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance server1\\instance1 -Database DBA\r\n\r\nLogs into server1\\instance1 with Windows authentication and then installs the FRK in the DBA database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance server1\\instance1 -Database master -SqlCredential $cred\r\n\r\nLogs into server1\\instance1 with SQL authentication and then installs the FRK in the master database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance sql2016\\standardrtm, sql2016\\sqlexpress, sql2014\r\n\r\nLogs into sql2016\\standardrtm, sql2016\\sqlexpress and sql2014 with Windows authentication and then installs the FRK in \r\nthe master database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2016\\standardrtm\", \"sql2016\\sqlexpress\", \"sql2014\"\r\n\r\n$servers | Install-DbaFirstResponderKit\r\n\r\nLogs into sql2016\\standardrtm, sql2016\\sqlexpress and sql2014 with Windows authentication and then installs the FRK in \r\nthe master database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaFirstResponderKit -SqlInstance sql2016 -Branch dev\r\n\r\nInstalls the dev branch version of the FRK in the master database on sql2016 instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInstall-DbaMaintenanceSolution [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject\u003e] [[-BackupLocation] \u003cString\u003e] [[-CleanupTime] \u003cInt32\u003e] [[-OutputFileDirectory] \u003cString\u003e] [-ReplaceExisting] \r\n[-LogToTable] [[-Solution] \u003cString\u003e] [-InstallJobs] [[-LocalFile] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Viorel Ciucu, viorel.ciucu@gmail.com, 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -CleanupTime 72\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -BackupLocation \"Z:\\SQLBackup\" -CleanupTime 72\r\n\r\nThis will create the Ola Hallengren\u0027s Solution objects. Existing objects are not affected in any way.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaMaintenanceSolution -SqlInstance RES14224 -Database DBA -BackupLocation \"Z:\\SQLBackup\" -CleanupTime \r\n72 -ReplaceExisting\r\n\r\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]\r\n\r\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Install-DbaWatchUpdate", "Description": "Adds the scheduled task to support Watch-DbaUpdate.", "Tags": "Module", "Syntax": "\r\nInstall-DbaWatchUpdate [[-TaskName] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaWatchUpdate\r\n\r\nAdds the scheduled task needed by Watch-DbaUpdate\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaWatchUpdate -TaskName MyScheduledTask\r\n\r\nWill create the scheduled task as the name MyScheduledTask\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInstall-DbaWhoIsActive [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-LocalFile \u003cString\u003e] \r\n[-Database \u003cObject\u003e] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaWhoIsActive -SqlInstance sqlserver2014a -Database master\r\n\r\nDownloads sp_WhoisActive from the internet and installs to sqlserver2014a\u0027s master database. Connects to SQL Server \r\nusing Windows Authentication.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaWhoIsActive -SqlInstance sqlserver2014a -SqlCredential $cred\r\n\r\nPops up a dialog box asking which database on sqlserver2014a you want to install the procedure into. Connects to SQL \r\nServer using SQL Authentication.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInstall-DbaWhoIsActive -SqlInstance sqlserver2014a -Database master -LocalFile \r\nc:\\SQLAdmin\\whoisactive_install.sql\r\n\r\nInstalls sp_WhoisActive to sqlserver2014a\u0027s master database from the local file whoisactive_install.sql\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$instances = Get-DbaRegisteredServer sqlserver\r\n\r\nInstall-DbaWhoIsActive -SqlInstance $instances -Database master\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Invoke-DbaAdvancedRestore", "Description": "This is the final piece in the Restore-DbaDatabase Stack. Usually a BackupHistory object will arrive here from Restore-DbaDatabse via the following pipeline:\nGet-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" ], "Syntax": "\r\nInvoke-DbaAdvancedRestore [-BackupHistory] \u003cObject[]\u003e [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [-OutputScriptOnly] [-VerifyOnly] [[-RestoreTime] \u003cDateTime\u003e] [[-StandbyDirectory] \u003cString\u003e] \r\n[-NoRecovery] [[-MaxTransferSize] \u003cInt32\u003e] [[-BlockSize] \u003cInt32\u003e] [[-BufferCount] \u003cInt32\u003e] [-Continue] \r\n[[-AzureCredential] \u003cString\u003e] [-WithReplace] [-KeepCDC] [[-PageRestore] \u003cObject[]\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance\r\n\r\nWill restore all the backups in the BackupHistory object according to the transformations it contains\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance -OutputScriptOnly\r\n\r\n$BackupHistory | Invoke-DbaAdvancedRestore -SqlInstance MyInstance\r\n\r\nFirst generates just the T-SQL restore scripts so they can be sanity checked, and then if they are good perform the \r\nfull restore. By reusing the BackupHistory object there is no need to rescan all the backup files again\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaBalanceDataFiles [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-Table \u003cObject[]\u003e] [-RebuildOffline] \r\n[-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nInvoke-DbaBalanceDataFiles -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-Table \u003cObject[]\u003e] [-RebuildOffline] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Re-balance data between data files", "Name": "Invoke-DbaBalanceDataFiles", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1\r\n\r\nThis command will distribute the data in database db1 on instance sql1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1 | Select-Object -ExpandProperty DataFilesEnd\r\n\r\nThis command will distribute the data in database db1 on instance sql1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1 -Table table1,table2,table5\r\n\r\nThis command will distribute the data for only the tables table1,table2 and table5\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaBalanceDataFiles -SqlInstance sql1 -Database db1 -RebuildOffline\r\n\r\nThis command will consider the fact that there might be a SQL Server edition that does not support online rebuilds of \r\nindexes.\r\nBy supplying this parameter you give permission to do the rebuilds offline if the edition does not support it.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Invoke-DbaCycleErrorLog", "Description": "Cycles the current error log for the instance (SQL Server) and/or SQL Server Agent.", "Tags": [ "Log", "Cycle" ], "Syntax": "\r\nInvoke-DbaCycleErrorLog [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Type] \u003cString\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton | http://blog.wsmelton.info)", "Synopsis": "Cycles the current instance or agent log.", "Name": "Invoke-DbaCycleErrorLog", "Links": "https://dbatools.io/Invoke-DbaCycleLog", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaCycleLog -SqlInstance sql2016 -Type agent\r\n\r\nCycles the current error log for the SQL Server Agent on SQL Server instance sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaCycleLog -SqlInstance sql2016 -Type instance\r\n\r\nCycles the current error log for the SQL Server instance on SQL Server instance sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaCycleLog -SqlInstance sql2016\r\n\r\nCycles the current error log for both SQL Server instance and SQL Server Agent on SQL Server instance sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 at sqlperformance: https://sqlperformance.com/2016/08/sql-statistics/expanding-dbcc-clonedatabase\n\nThanks to Microsoft Tiger Team for the code and idea https://github.com/Microsoft/tigertoolbox/", "Tags": [ "Statistics", "Performance" ], "Syntax": "\r\nInvoke-DbaDbClone [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject\u003e \r\n[-CloneDatabase \u003cString[]\u003e] [-UpdateStatistics] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Clones a database schema and statistics", "Name": "Invoke-DbaDbClone", "Links": "https://dbatools.io/Invoke-DbaDbClone", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone\r\n\r\nClones mydb to myclone on sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbClone -SqlInstance sql2016 -Database mydb -CloneDatabase myclone, myclone2 -UpdateStatistics\r\n\r\nUpdates the statistics of mydb then clones to myclone and myclone2\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaDbDecryptObject [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \r\n\u003cObject[]\u003e [[-ObjectName] \u003cString[]\u003e] [[-EncodingType] \u003cString\u003e] [[-ExportDestination] \u003cString\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ObjectName Function1\r\n\r\nDecrypt object \"Function1\" in DB1 of instance SQLDB1 and output the data to the user.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ObjectName Function1 -ExportDestination \r\nC:\\temp\\decrypt\r\n\r\nDecrypt object \"Function1\" in DB1 of instance SQLDB1 and output the data to the folder \"C:\\temp\\decrypt\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ExportDestination C:\\temp\\decrypt\r\n\r\nDecrypt all objects in DB1 of instance SQLDB1 and output the data to the folder \"C:\\temp\\decrypt\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbDecryptObject -SqlInstance SQLDB1 -Database DB1 -ObjectName Function1, Function2\r\n\r\nDecrypt objects \"Function1\" and \"Function2\" and output the data to the user.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\"SQLDB1\" | Invoke-DbaDbDecryptObject -Database DB1 -ObjectName Function1, Function2\r\n\r\nDecrypt objects \"Function1\" and \"Function2\" and output the data to the user using a pipeline for the instance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\n http://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-files\n http://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" ], "Syntax": "\r\nInvoke-DbaDbShrink [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-AllUserDatabases] [[-PercentFreeSpace] \u003cInt32\u003e] [[-ShrinkMethod] \u003cString\u003e] \r\n[[-FileType] \u003cString\u003e] [[-StepSizeMB] \u003cInt32\u003e] [[-StatementTimeout] \u003cInt32\u003e] [-LogsOnly] [-ExcludeIndexStats] \r\n[-ExcludeUpdateUsage] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2016 -Database Northwind,pubs,Adventureworks2014\r\n\r\nShrinks Northwind, pubs and Adventureworks2014 to have as little free space as possible.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2014 -Database AdventureWorks2014 -PercentFreeSpace 50\r\n\r\nShrinks AdventureWorks2014 to have 50% free space. So let\u0027s say AdventureWorks2014 was 1GB and it\u0027s using 100MB space. \r\nThe database free space would be reduced to 50MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2014 -Database AdventureWorks2014 -PercentFreeSpace 50 -FileType Data \r\n-StepSizeMB 25\r\n\r\nShrinks AdventureWorks2014 to have 50% free space, runs shrinks in 25MB chunks for improved performance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbShrink -SqlInstance sql2012 -AllUserDatabases\r\n\r\nShrinks all databases on SQL2012 (not ideal for production)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaDbUpgrade [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-NoCheckDb] [-NoUpdateUsage] [-NoUpdateStats] [-NoRefreshView] [-AllUserDatabases] \r\n[-Force] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbUpgrade -SqlInstance PRD-SQL-MSD01 -Database Test\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbUpgrade -SqlInstance PRD-SQL-INT01 -Database Test -NoRefreshView\r\n\r\nRuns the upgrade command skipping the sp_refreshview update on all views\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDbUpgrade -SqlInstance PRD-SQL-INT01 -Database Test -Force\r\n\r\nIf database Test is already at the correct compatibility, runs every necessary step\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 | Out-GridView -Passthru | Invoke-DbaDbUpgrade\r\n\r\nGet only specific databases using GridView and pass those to Invoke-DbaDbUpgrade\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaDiagnosticQuery [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] \r\n[-ExcludeQuery \u003cObject[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Path \u003cFileInfo\u003e] [-QueryName \u003cString[]\u003e] \r\n[-UseSelectionHelper] [-InstanceOnly] [-DatabaseSpecific] [-NoQueryTextColumn] [-NoPlanColumn] [-NoColumnParsing] \r\n[-OutputPath \u003cString\u003e] [-ExportQueries] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "André 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -SqlInstance sql2016\r\n\r\nRun the selection made by the user on the Sql Server instance specified.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaDiagnosticQuery -SqlInstance sql2016 -UseSelectionHelper | Export-DbaDiagnosticQuery -Path \r\nC:\\temp\\gboutput\r\n\r\nProvides a gridview with all the queries to choose from and will run the selection made by the user on the SQL Server \r\ninstance specified.\r\nThen it will export the results to Export-DbaDiagnosticQuery.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e# Exporting Queries To SQL Files\r\n\r\n- Parse the appropriate diagnostic queries by connecting to server to get version matched queries\r\n- Instead of running the diagnostic queries, export them to SQL files\r\n\r\n# Export All Queries to Disk\r\nInvoke-DbaDiagnosticQuery -sqlinstance localhost -ExportQueries -outputpath \"C:\\temp\\DiagnosticQueries\"\r\n\r\n# Export Database Specific Queries for all User Dbs\r\nInvoke-DbaDiagnosticQuery -sqlinstance localhost -DatabaseSpecific -DatabaseName \u0027tempdb\u0027 -ExportQueries -outputpath \r\n\"C:\\temp\\DiagnosticQueries\"\r\n\r\n# Export Database Specific Queries For One Target Database\r\nInvoke-DbaDiagnosticQuery -sqlinstance localhost -DatabaseSpecific -DatabaseName \u0027tempdb\u0027 -ExportQueries -outputpath \r\n\"C:\\temp\\DiagnosticQueries\"\r\n\r\n# Export Database Specific Queries For One Target Database and One Specific Query\r\nInvoke-DbaDiagnosticQuery -sqlinstance localhost -DatabaseSpecific -DatabaseName \u0027tempdb\u0027 -ExportQueries -outputpath \r\n\"C:\\temp\\DiagnosticQueries\" -queryname \u0027Database-scoped Configurations\u0027\r\n\r\n# Choose Queries To Export\r\nInvoke-DbaDiagnosticQuery -sqlinstance localhost -UseSelectionHelper\r\n\r\nThis will export with SqlInstance, DatabaseName, and QueryName as appropriate based on query.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e# Export Queries (not run) as returned object\r\n\r\n[System.Management.Automation.PSObject[]]$results = Invoke-DbaDiagnosticQuery -SqlInstance localhost -whatif\r\n\r\nParse the appropriate diagnostic queries by connecting to server, and instead of running them, return as \r\n[pscustomobject[]] to work with further\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e# Database Specific Handling\r\n\r\n$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -DatabaseSpecific -queryname \u0027Database-scoped \r\nConfigurations\u0027 -databasename $database\r\n\r\nRun diagnostic queries targeted at specific database, and only run database level queries against this database.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Invoke-DbaLogShipping", "Description": "Invoke-DbaLogShipping 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", "Syntax": "\r\nInvoke-DbaLogShipping [-SourceSqlInstance] \u003cObject\u003e [-DestinationSqlInstance] \u003cObject[]\u003e [[-SourceSqlCredential] \r\n\u003cPSCredential\u003e] [[-SourceCredential] \u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] \r\n[[-DestinationCredential] \u003cPSCredential\u003e] [-Database] \u003cObject[]\u003e [-BackupNetworkPath] \u003cString\u003e [[-BackupLocalPath] \r\n\u003cString\u003e] [[-BackupJob] \u003cString\u003e] [[-BackupRetention] \u003cInt32\u003e] [[-BackupSchedule] \u003cString\u003e] [-BackupScheduleDisabled] \r\n[[-BackupScheduleFrequencyType] \u003cObject\u003e] [[-BackupScheduleFrequencyInterval] \u003cObject[]\u003e] \r\n[[-BackupScheduleFrequencySubdayType] \u003cObject\u003e] [[-BackupScheduleFrequencySubdayInterval] \u003cInt32\u003e] \r\n[[-BackupScheduleFrequencyRelativeInterval] \u003cObject\u003e] [[-BackupScheduleFrequencyRecurrenceFactor] \u003cInt32\u003e] \r\n[[-BackupScheduleStartDate] \u003cString\u003e] [[-BackupScheduleEndDate] \u003cString\u003e] [[-BackupScheduleStartTime] \u003cString\u003e] \r\n[[-BackupScheduleEndTime] \u003cString\u003e] [[-BackupThreshold] \u003cInt32\u003e] [-CompressBackup] [[-CopyDestinationFolder] \u003cString\u003e] \r\n[[-CopyJob] \u003cString\u003e] [[-CopyRetention] \u003cInt32\u003e] [[-CopySchedule] \u003cString\u003e] [-CopyScheduleDisabled] \r\n[[-CopyScheduleFrequencyType] \u003cObject\u003e] [[-CopyScheduleFrequencyInterval] \u003cObject[]\u003e] \r\n[[-CopyScheduleFrequencySubdayType] \u003cObject\u003e] [[-CopyScheduleFrequencySubdayInterval] \u003cInt32\u003e] \r\n[[-CopyScheduleFrequencyRelativeInterval] \u003cObject\u003e] [[-CopyScheduleFrequencyRecurrenceFactor] \u003cInt32\u003e] \r\n[[-CopyScheduleStartDate] \u003cString\u003e] [[-CopyScheduleEndDate] \u003cString\u003e] [[-CopyScheduleStartTime] \u003cString\u003e] \r\n[[-CopyScheduleEndTime] \u003cString\u003e] [-DisconnectUsers] [[-FullBackupPath] \u003cString\u003e] [-GenerateFullBackup] \r\n[[-HistoryRetention] \u003cInt32\u003e] [-NoRecovery] [-NoInitialization] [[-PrimaryMonitorServer] \u003cString\u003e] \r\n[[-PrimaryMonitorCredential] \u003cPSCredential\u003e] [[-PrimaryMonitorServerSecurityMode] \u003cObject\u003e] \r\n[-PrimaryThresholdAlertEnabled] [[-RestoreDataFolder] \u003cString\u003e] [[-RestoreLogFolder] \u003cString\u003e] [[-RestoreDelay] \r\n\u003cInt32\u003e] [[-RestoreAlertThreshold] \u003cInt32\u003e] [[-RestoreJob] \u003cString\u003e] [[-RestoreRetention] \u003cInt32\u003e] [[-RestoreSchedule] \r\n\u003cString\u003e] [-RestoreScheduleDisabled] [[-RestoreScheduleFrequencyType] \u003cObject\u003e] [[-RestoreScheduleFrequencyInterval] \r\n\u003cObject[]\u003e] [[-RestoreScheduleFrequencySubdayType] \u003cObject\u003e] [[-RestoreScheduleFrequencySubdayInterval] \u003cInt32\u003e] \r\n[[-RestoreScheduleFrequencyRelativeInterval] \u003cObject\u003e] [[-RestoreScheduleFrequencyRecurrenceFactor] \u003cInt32\u003e] \r\n[[-RestoreScheduleStartDate] \u003cString\u003e] [[-RestoreScheduleEndDate] \u003cString\u003e] [[-RestoreScheduleStartTime] \u003cString\u003e] \r\n[[-RestoreScheduleEndTime] \u003cString\u003e] [[-RestoreThreshold] \u003cInt32\u003e] [[-SecondaryDatabasePrefix] \u003cString\u003e] \r\n[[-SecondaryDatabaseSuffix] \u003cString\u003e] [[-SecondaryMonitorServer] \u003cString\u003e] [[-SecondaryMonitorCredential] \r\n\u003cPSCredential\u003e] [[-SecondaryMonitorServerSecurityMode] \u003cObject\u003e] [-SecondaryThresholdAlertEnabled] [-Standby] \r\n[[-StandbyDirectory] \u003cString\u003e] [-UseExistingFullBackup] [[-UseBackupFolder] \u003cString\u003e] [-Force] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Invoke-DbaLogShipping sets up log shipping for one or more databases", "Name": "Invoke-DbaLogShipping", "Links": "https://dbatools.io/Invoke-DbaLogShipping", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$params = @{\r\n\r\nSourceSqlInstance = \u0027sql1\u0027\r\n DestinationSqlInstance = \u0027sql2\u0027\r\n Database = \u0027db1\u0027\r\n BackupNetworkPath= \u0027\\\\sql1\\logshipping\u0027\r\n BackupLocalPath= \u0027D:\\Data\\logshipping\u0027\r\n BackupScheduleFrequencyType = \u0027daily\u0027\r\n BackupScheduleFrequencyInterval = 1\r\n CompressBackup = $true\r\n CopyScheduleFrequencyType = \u0027daily\u0027\r\n CopyScheduleFrequencyInterval = 1\r\n GenerateFullBackup = $true\r\n RestoreScheduleFrequencyType = \u0027daily\u0027\r\n RestoreScheduleFrequencyInterval = 1\r\n SecondaryDatabaseSuffix = \u0027DR\u0027\r\n CopyDestinationFolder = \u0027\\\\sql2\\logshippingdest\u0027\r\n Force = $true\r\n}\r\n\r\nInvoke-DbaLogShipping @params\r\n\r\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 \r\ndaily.\r\nThe secondary database will be called \"db1_LS\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$params = @{\r\n\r\nSourceSqlInstance = \u0027sql1\u0027\r\n DestinationSqlInstance = \u0027sql2\u0027\r\n Database = \u0027db1\u0027\r\n BackupNetworkPath= \u0027\\\\sql1\\logshipping\u0027\r\n GenerateFullBackup = $true\r\n Force = $true\r\n}\r\n\r\nInvoke-DbaLogShipping @params\r\n\r\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 \r\nwhich would be the backup directory of the secondary server with the folder \"logshipping\" i.e. \r\n\"D:\\SQLBackup\\Logshiping\".\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Invoke-DbaLogShippingRecovery", "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", "Syntax": "\r\nInvoke-DbaLogShippingRecovery [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Database] \u003cString[]\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [-NoRecovery] [-EnableException] [-Force] [[-InputObject] \u003cDatabase[]\u003e] [[-Delay] \u003cInt32\u003e] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Invoke-DbaLogShippingRecovery recovers log shipped databases to a normal state to act upon a migration or disaster.", "Name": "Invoke-DbaLogShippingRecovery", "Links": "https://dbatools.io/Invoke-DbaLogShippingRecovery", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaLogShippingRecovery -SqlServer server1\r\n\r\nRecovers all the databases on the instance that are enabled for log shipping\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaLogShippingRecovery -SqlServer server1 -SqlCredential $cred -Verbose\r\n\r\nRecovers all the databases on the instance that are enabled for log shipping using a credential\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaLogShippingRecovery -SqlServer server1 -database db_logship -Verbose\r\n\r\nRecovers the database \"db_logship\" to a normal status\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003edb1, db2, db3, db4 | Invoke-DbaLogShippingRecovery -SqlServer server1 -Verbose\r\n\r\nRecovers the database db1, db2, db3, db4 to a normal status\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaLogShippingRecovery -SqlServer server1 -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\nrelog \"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" ], "Syntax": "\r\nInvoke-DbaPfRelog [[-Path] \u003cString[]\u003e] [[-Destination] \u003cString\u003e] [[-Type] \u003cString\u003e] [-Append] [-AllowClobber] \r\n[[-PerformanceCounter] \u003cString[]\u003e] [[-PerformanceCounterPath] \u003cString\u003e] [[-Interval] \u003cInt32\u003e] [[-BeginTime] \u003cDateTime\u003e] \r\n[[-EndTime] \u003cDateTime\u003e] [[-ConfigPath] \u003cString\u003e] [-Summary] [[-InputObject] \u003cObject[]\u003e] [-Multithread] [-AllTime] \r\n[-Raw] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaPfRelog -Path C:\\temp\\perfmon.blg\r\n\r\nCreates C:\\temp\\perfmon.tsv from C:\\temp\\perfmon.blg.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaPfRelog -Path C:\\temp\\perfmon.blg -Destination C:\\temp\\a\\b\\c\r\n\r\nCreates the temp, a, and b directories if needed, then generates c.tsv (tab separated) from C:\\temp\\perfmon.blg.\r\n\r\nReturns the newly created file as a file object.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -ComputerName sql2016 | Get-DbaPfDataCollector | Invoke-DbaPfRelog -Destination \r\nC:\\temp\\perf\r\n\r\nCreates C:\\temp\\perf if needed, then generates computername-datacollectorname.tsv (tab separated) from the latest logs \r\nof all data collector sets on sql2016. This destination format was chosen to avoid naming conflicts with piped input.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaPfRelog -Path C:\\temp\\perfmon.blg -Destination C:\\temp\\a\\b\\c -Raw\r\n\r\nCreates the temp, a, and b directories if needed, then generates c.tsv (tab separated) from C:\\temp\\perfmon.blg then \r\noutputs the raw results of the relog command.\r\n\r\n[Invoke-DbaPfRelog][21:21:35] relog \"C:\\temp\\perfmon.blg\" -f csv -o C:\\temp\\a\\b\\c\r\n\r\nInput\r\n----------------\r\nFile(s):\r\n C:\\temp\\perfmon.blg (Binary)\r\n\r\nBegin: 1/13/2018 5:13:23\r\nEnd: 1/13/2018 14:29:55\r\nSamples: 2227\r\n\r\n100.00%\r\n\r\nOutput\r\n----------------\r\nFile: C:\\temp\\a\\b\\c.csv\r\n\r\nBegin: 1/13/2018 5:13:23\r\nEnd: 1/13/2018 14:29:55\r\nSamples: 2227\r\n\r\nThe command completed successfully.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaPfRelog -Path \u0027C:\\temp\\perflog with spaces.blg\u0027 -Destination C:\\temp\\a\\b\\c -Type csv -BeginTime \r\n((Get-Date).AddDays(-30)) -EndTime ((Get-Date).AddDays(-1))\r\n\r\nCreates the temp, a, and b directories if needed, then generates c.csv (comma separated) from C:\\temp\\perflog with \r\nspaces.blg\u0027, starts 30 days ago and ends one day ago.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$servers | Get-DbaPfDataCollectorSet | Get-DbaPfDataCollector | Invoke-DbaPfRelog -Multithread -AllowClobber\r\n\r\nRelogs latest data files from all collectors within the servers listed in $servers.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollector -Collector DataCollector01 | Invoke-DbaPfRelog -AllowClobber -AllTime\r\n\r\nRelogs all the log files from the DataCollector01 on the local computer and allows overwrite.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaQuery [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject\u003e] [-Query] \r\n\u003cString\u003e [-QueryTimeout \u003cInt32\u003e] [-As \u003cString\u003e] [-SqlParameters \u003cIDictionary\u003e] [-AppendServerInstance] \r\n[-MessagesToOutput] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nInvoke-DbaQuery [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject\u003e] \r\n[-QueryTimeout \u003cInt32\u003e] -File \u003cObject[]\u003e [-As \u003cString\u003e] [-SqlParameters \u003cIDictionary\u003e] [-AppendServerInstance] \r\n[-MessagesToOutput] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nInvoke-DbaQuery [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject\u003e] \r\n[-QueryTimeout \u003cInt32\u003e] -SqlObject \u003cSqlSmoObject[]\u003e [-As \u003cString\u003e] [-SqlParameters \u003cIDictionary\u003e] \r\n[-AppendServerInstance] [-MessagesToOutput] [-InputObject \u003cDatabase[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "A command to run explicit T-SQL commands or files.", "Name": "Invoke-DbaQuery", "Links": "https://dbatools.io/Invoke-DbaQuery", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaQuery -SqlInstance server\\instance -Query \u0027SELECT foo FROM bar\u0027\r\n\r\nRuns the sql query \u0027SELECT foo FROM bar\u0027 against the instance \u0027server\\instance\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance [SERVERNAME] -Group [GROUPNAME] | Invoke-DbaQuery -Query \u0027SELECT foo FROM \r\nbar\u0027\r\n\r\nRuns the sql query \u0027SELECT foo FROM bar\u0027 against all instances in the group [GROUPNAME] on the CMS [SERVERNAME]\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e\"server1\", \"server1\\nordwind\", \"server2\" | Invoke-DbaQuery -File \"C:\\scripts\\sql\\rebuild.sql\"\r\n\r\nRuns the sql commands stored in rebuild.sql against the instances \"server1\", \"server1\\nordwind\" and \"server2\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance \"server1\", \"server1\\nordwind\", \"server2\" | Invoke-DbaQuery -File \r\n\"C:\\scripts\\sql\\rebuild.sql\"\r\n\r\nRuns the sql commands stored in rebuild.sql against all accessible databases of the instances \"server1\", \r\n\"server1\\nordwind\" and \"server2\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Invoke-DbatoolsRenameHelper", "Description": "Older dbatools command names have been changed. This script helps keep up.", "Syntax": "\r\nInvoke-DbatoolsRenameHelper [-InputObject] \u003cFileInfo[]\u003e [[-Encoding] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem C:\\temp\\ps\\*.ps1 -Recurse | Invoke-DbatoolsRenameHelper\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem C:\\temp\\ps\\*.ps1 -Recurse | Invoke-DbatoolsRenameHelper -Encoding Ascii -WhatIf\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaWhoIsActive [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject\u003e] \r\n[[-Filter] \u003cString\u003e] [[-FilterType] \u003cString\u003e] [[-NotFilter] \u003cString\u003e] [[-NotFilterType] \u003cString\u003e] [-ShowOwnSpid] \r\n[-ShowSystemSpids] [[-ShowSleepingSpids] \u003cInt32\u003e] [-GetFullInnerText] [[-GetPlans] \u003cInt32\u003e] [-GetOuterCommand] \r\n[-GetTransactionInfo] [[-GetTaskInfo] \u003cInt32\u003e] [-GetLocks] [-GetAverageTime] [-GetAdditonalInfo] [-FindBlockLeaders] \r\n[[-DeltaInterval] \u003cInt32\u003e] [[-OutputColumnList] \u003cString\u003e] [[-SortOrder] \u003cString\u003e] [[-FormatOutput] \u003cInt32\u003e] \r\n[[-DestinationTable] \u003cString\u003e] [-ReturnSchema] [[-Schema] \u003cString\u003e] [-Help] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a\r\n\r\nExecute sp_whoisactive on sqlserver2014a. This command expects sp_WhoIsActive to be in the master database. Logs into \r\nthe SQL Server with Windows credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a -SqlCredential $credential -Database dbatools\r\n\r\nExecute sp_whoisactive on sqlserver2014a. This command expects sp_WhoIsActive to be in the dbatools database. Logs into \r\nthe SQL Server with SQL Authentication.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a -GetAverageTime\r\n\r\nSimilar to running sp_WhoIsActive @get_avg_time\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaWhoIsActive -SqlInstance sqlserver2014a -GetOuterCommand -FindBlockLeaders\r\n\r\nSimilar to running sp_WhoIsActive @get_outer_command = 1, @find_block_leaders = 1\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nInvoke-DbaXeReplay [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString[]\u003e] \r\n[[-Event] \u003cString[]\u003e] [-InputObject] \u003cObject\u003e [-Raw] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "This command replays events from Read-DbaXEFile on one or more target servers", "Name": "Invoke-DbaXeReplay", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\sample.xel | Invoke-DbaXeReplay -SqlInstance sql2017\r\n\r\nRuns all batch_text for sql_batch_completed against tempdb on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\sample.xel | Invoke-DbaXeReplay -SqlInstance sql2017 -Database planning -Event \r\nsql_batch_completed\r\n\r\nSets the *initial* database to planning then runs only sql_batch_completed against sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\sample.xel | Invoke-DbaXeReplay -SqlInstance sql2017, sql2016\r\n\r\nRuns all batch_text for sql_batch_completed against tempdb on sql2017 and sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nInvoke-Sqlcmd2 [-ServerInstance] \u003cString[]\u003e [[-Database] \u003cString\u003e] [-Query] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] \r\n[[-Encrypt]] [[-QueryTimeout] \u003cInt32\u003e] [[-ConnectionTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \u003cIDictionary\u003e] \r\n[[-AppendServerInstance]] [[-ParseGO]] [\u003cCommonParameters\u003e]\r\n\r\nInvoke-Sqlcmd2 [-ServerInstance] \u003cString[]\u003e [[-Database] \u003cString\u003e] [-InputFile] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] \r\n[[-Encrypt]] [[-QueryTimeout] \u003cInt32\u003e] [[-ConnectionTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \u003cIDictionary\u003e] \r\n[[-AppendServerInstance]] [[-ParseGO]] [\u003cCommonParameters\u003e]\r\n\r\nInvoke-Sqlcmd2 [[-Database] \u003cString\u003e] [-Query] \u003cString\u003e [[-QueryTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] [[-SqlParameters] \r\n\u003cIDictionary\u003e] [[-AppendServerInstance]] [[-ParseGO]] [[-SQLConnection] \u003cSqlConnection\u003e] [\u003cCommonParameters\u003e]\r\n\r\nInvoke-Sqlcmd2 [[-Database] \u003cString\u003e] [-InputFile] \u003cString\u003e [[-QueryTimeout] \u003cInt32\u003e] [[-As] \u003cString\u003e] \r\n[[-SqlParameters] \u003cIDictionary\u003e] [[-AppendServerInstance]] [[-ParseGO]] [[-SQLConnection] \u003cSqlConnection\u003e] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Runs a T-SQL script.", "Name": "Invoke-Sqlcmd2", "Links": [ "https://github.com/sqlcollaborative/Invoke-SqlCmd2", "https://github.com/RamblingCookieMonster/PowerShell" ], "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance \"MyComputer\\MyInstance\" -Query \"SELECT login_time AS \u0027StartTime\u0027 FROM \r\nsysprocesses WHERE spid = 1\"\r\n\r\nConnects to a named instance of the Database Engine on a computer and runs a basic T-SQL query.\r\n\r\nStartTime\r\n-----------\r\n2010-08-12 21:21:03.593\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance \"MyComputer\\MyInstance\" -InputFile \"C:\\MyFolder\\tsqlscript.sql\" | Out-File \r\n-filePath \"C:\\MyFolder\\tsqlscript.rpt\"\r\n\r\nReads a file containing T-SQL statements, runs the file, and writes the output to another file.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance \"MyComputer\\MyInstance\" -Query \"PRINT \u0027hello world\u0027\" -Verbose\r\n\r\nUses the PowerShell -Verbose parameter to return the message output of the PRINT command.\r\nVERBOSE: hello world\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-Sqlcmd2 -ServerInstance MyServer\\MyInstance -Query \"SELECT ServerName, VCNumCPU FROM tblServerInfo\" -as \r\nPSObject | ?{$_.VCNumCPU -gt 8}\r\n\r\nInvoke-Sqlcmd2 -ServerInstance MyServer\\MyInstance -Query \"SELECT ServerName, VCNumCPU FROM tblServerInfo\" -as PSObject \r\n| ?{$_.VCNumCPU}\r\n\r\nThis example uses the PSObject output type to allow more flexibility when working with results.\r\n\r\nIf we used DataRow rather than PSObject, we would see the following behavior:\r\n Each row where VCNumCPU does not exist would produce an error in the first example\r\n Results would include rows where VCNumCPU has DBNull value in the second example\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e\u0027Instance1\u0027, \u0027Server1/Instance1\u0027, \u0027Server2\u0027 | Invoke-Sqlcmd2 -query \"Sp_databases\" -as psobject \r\n-AppendServerInstance\r\n\r\nThis example lists databases for each instance. It includes a column for the ServerInstance in question.\r\n DATABASE_NAME DATABASE_SIZE REMARKS ServerInstance\r\n ------------- ------------- ------- --------------\r\n REDACTED 88320 Instance1\r\n master 17920 Instance1\r\n ...\r\n msdb 618112 Server1/Instance1\r\n tempdb 563200 Server1/Instance1\r\n ...\r\n OperationsManager 20480000 Server2\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e#Construct a query using SQL parameters\r\n\r\n$Query = \"SELECT ServerName, VCServerClass, VCServerContact FROM tblServerInfo WHERE VCServerContact LIKE \r\n@VCServerContact AND VCServerClass LIKE @VCServerClass\"\r\n\r\n#Run the query, specifying values for SQL parameters\r\n Invoke-Sqlcmd2 -ServerInstance SomeServer\\NamedInstance -Database ServerDB -query $query -SqlParameters @{ \r\nVCServerContact=\"%cookiemonster%\"; VCServerClass=\"Prod\" }\r\n\r\n ServerName VCServerClass VCServerContact\r\n ---------- ------------- ---------------\r\n SomeServer1 Prod cookiemonster, blah\r\n SomeServer2 Prod cookiemonster\r\n SomeServer3 Prod blah, cookiemonster\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eInvoke-Sqlcmd2 -SQLConnection $Conn -Query \"SELECT login_time AS \u0027StartTime\u0027 FROM sysprocesses WHERE spid = 1\"\r\n\r\nUses an existing SQLConnection and runs a basic T-SQL query against it\r\n\r\nStartTime\r\n-----------\r\n2010-08-12 21:21:03.593\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eInvoke-SqlCmd -SQLConnection $Conn -Query \"SELECT ServerName FROM tblServerInfo WHERE ServerName LIKE \r\n@ServerName\" -SqlParameters @{\"ServerName = \"c-is-hyperv-1\"}\r\n\r\nExecutes a parameterized query against the existing SQLConnection, with a collection of one parameter to be passed to \r\nthe query when executed.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nMeasure-DbaBackupThroughput [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \r\n\u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-Since \u003cDateTime\u003e] [-Last] [-Type \u003cString\u003e] [-DeviceType \u003cString[]\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016\r\n\r\nParses every backup in msdb\u0027s backuphistory for stats on all databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016 -Database AdventureWorks2014\r\n\r\nParses every backup in msdb\u0027s backuphistory for stats on AdventureWorks2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2005 -Last\r\n\r\nProcesses the last full, diff and log backups every backup for all databases on sql2005.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2005 -Last -Type Log\r\n\r\nProcesses the last log backups every backup for all databases on sql2005.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016 -Since (Get-Date).AddDays(-7)\r\n\r\nGets backup calculations for the last week.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaBackupThroughput -SqlInstance sql2016 -Since (Get-Date).AddDays(-365) -Database bigoldb\r\n\r\nGets backup calculations, limited to the last year and only the bigoldb database\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nMeasure-DbaDiskSpaceRequirement [-Source] \u003cDbaInstanceParameter\u003e [-Database] \u003cString\u003e [[-SourceSqlCredential] \r\n\u003cPSCredential\u003e] [-Destination] \u003cDbaInstanceParameter\u003e [[-DestinationDatabase] \u003cString\u003e] [[-DestinationSqlCredential] \r\n\u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eMeasure-DbaDiskSpaceRequirement -Source INSTANCE1 -Database DB1 -Destination INSTANCE2\r\n\r\nCalculate space needed for a simple migration with one database with the same name at destination.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e@([PSCustomObject]@{Source=\u0027SQL1\u0027;Destination=\u0027SQL2\u0027;Database=\u0027DB1\u0027},\r\n\r\n[PSCustomObject]@{Source=\u0027SQL1\u0027;Destination=\u0027SQL2\u0027;Database=\u0027DB2\u0027}\r\n) | Measure-DbaDiskSpaceRequirement\r\n\r\nUsing a PSCustomObject with 2 databases to migrate on SQL2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eImport-Csv -Path .\\migration.csv -Delimiter \"`t\" | Measure-DbaDiskSpaceRequirement | Format-Table -AutoSize\r\n\r\nUsing a CSV file. You will need to use this header line \"Source\u003ctab\u003eDestination\u003ctab\u003eDatabase\u003ctab\u003eDestinationDatabase\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eInvoke-DbaCmd -SqlInstance DBA -Database Migrations -Query \u0027select Source, Destination, Database from \r\ndbo.Migrations\u0027 `\r\n\r\n| Measure-DbaDiskSpaceRequirement\r\n\r\nUsing a SQL table. We are DBA after all!\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Mount-DbaDatabase", "Description": "This command will attach a SQL Server database.", "Tags": "Database", "Syntax": "\r\nMount-DbaDatabase [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \u003cString[]\u003e \r\n[[-FileStructure] \u003cStringCollection\u003e] [[-DatabaseOwner] \u003cString\u003e] [[-AttachOption] \u003cString\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$fileStructure = New-Object System.Collections.Specialized.StringCollection\r\n\r\n$fileStructure.Add(\"E:\\archive\\example.mdf\")\r\n$filestructure.Add(\"E:\\archive\\example.ldf\")\r\n$filestructure.Add(\"E:\\archive\\example.ndf\")\r\nMount-DbaDatabase -SqlInstance sql2016 -Database example -FileStructure $fileStructure\r\n\r\nAttaches a database named \"example\" to sql2016 with the files \"E:\\archive\\example.mdf\", \"E:\\archive\\example.ldf\" and \r\n\"E:\\archive\\example.ndf\". The database owner will be set to sa and the attach option is None.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eMount-DbaDatabase -SqlInstance sql2016 -Database example\r\n\r\nSince the FileStructure was not provided, this command will attempt to determine it based on backup history. If found, \r\na database named example will be attached to sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eMount-DbaDatabase -SqlInstance sql2016 -Database example -WhatIf\r\n\r\nShows what would happen if the command were executed (without actually performing the command)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Move-DbaRegisteredServer", "Description": "Moves registered servers around SQL Server Central Management Server (CMS)", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nMove-DbaRegisteredServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \r\n\u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-NewGroup] \u003cString\u003e] [[-InputObject] \u003cRegisteredServer[]\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Moves registered servers around SQL Server Central Management Server (CMS)", "Name": "Move-DbaRegisteredServer", "Links": "https://dbatools.io/Move-DbaRegisteredServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eMove-DbaRegisteredServer -SqlInstance sql2012 -Name \u0027Web SQL Cluster\u0027 -NewGroup HR\\Prod\r\n\r\nMoves the registered server on sql2012 titled \u0027Web SQL Cluster\u0027 to the Prod group within the HR group\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eMove-DbaRegisteredServer -SqlInstance sql2012 -Group HR\\Development -NewGroup HR\\Prod\r\n\r\nMoves all servers from the HR and sub-group Development to HR Prod\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2017 -Name \u0027Web SQL Cluster\u0027 | Move-DbaRegisteredServer -NewGroup Web\r\n\r\nMoves the registered server \u0027Web SQL Cluster\u0027 on sql2017 to the Web group, also on sql2017\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Move-DbaRegisteredServerGroup", "Description": "Moves registered server groups around SQL Server Central Management Server (CMS).", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nMove-DbaRegisteredServerGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Group] \r\n\u003cString[]\u003e] [-NewGroup] \u003cString\u003e [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Moves registered server groups around SQL Server Central Management Server (CMS).", "Name": "Move-DbaRegisteredServerGroup", "Links": "https://dbatools.io/Move-DbaRegisteredServerGroup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eMove-DbaRegisteredServerGroup -SqlInstance sql2012 -Group HR\\Development -NewGroup AD\\Prod\r\n\r\nMoves the Development group within HR to the Prod group within AD\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServerGroup -SqlInstance sql2017 -Group HR\\Development| Move-DbaRegisteredServer -NewGroup Web\r\n\r\nMoves the Development group within HR to the Web group\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaAgentJob [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cString\u003e [[-Schedule] \r\n\u003cObject[]\u003e] [[-ScheduleId] \u003cInt32[]\u003e] [-Disabled] [[-Description] \u003cString\u003e] [[-StartStepId] \u003cInt32\u003e] [[-Category] \r\n\u003cString\u003e] [[-OwnerLogin] \u003cString\u003e] [[-EventLogLevel] \u003cObject\u003e] [[-EmailLevel] \u003cObject\u003e] [[-PageLevel] \u003cObject\u003e] \r\n[[-EmailOperator] \u003cString\u003e] [[-NetsendOperator] \u003cString\u003e] [[-PageOperator] \u003cString\u003e] [[-DeleteLevel] \u003cObject\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "New-DbaAgentJob creates a new job", "Name": "New-DbaAgentJob", "Links": "https://dbatools.io/New-DbaAgentJob", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -Description \u0027Just another job\u0027\r\n\r\nCreates a job with the name \"Job1\" and a small description\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -Disabled\r\n\r\nCreates the job but sets it to disabled\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -EventLogLevel OnSuccess\r\n\r\nCreates the job and sets the notification to write to the Windows Application event log on success\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance SSTAD-PC -Job \u0027Job One\u0027 -EmailLevel OnFailure -EmailOperator dba\r\n\r\nCreates the job and sets the notification to send an e-mail to the e-mail operator\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1 -Job \u0027Job One\u0027 -Description \u0027Just another job\u0027 -Whatif\r\n\r\nDoesn\u0027t create the job but shows what would happen.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job \u0027Job One\u0027\r\n\r\nCreates a job with the name \"Job One\" on multiple servers\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e\"sql1\", \"sql2\", \"sql3\" | New-DbaAgentJob -Job \u0027Job One\u0027\r\n\r\nCreates a job with the name \"Job One\" on multiple servers using the pipe line\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Category] \r\n\u003cString[]\u003e [[-CategoryType] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "New-DbaAgentJobCategory creates a new job category.", "Name": "New-DbaAgentJobCategory", "Links": "https://dbatools.io/New-DbaAgentJobCategory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 1\u0027\r\n\r\nCreates a new job category with the name \u0027Category 1\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 2\u0027 -CategoryType MultiServerJob\r\n\r\nCreates a new job category with the name \u0027Category 2\u0027 and assign the category type for a multi server job.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaAgentJobStep", "Description": "New-DbaAgentJobStep creates a new job in the SQL Server Agent for a specific job", "Tags": [ "Agent", "Job", "JobStep" ], "Syntax": "\r\nNew-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e \r\n[[-StepId] \u003cInt32\u003e] [-StepName] \u003cString\u003e [[-Subsystem] \u003cString\u003e] [[-Command] \u003cString\u003e] [[-CmdExecSuccessCode] \u003cInt32\u003e] \r\n[[-OnSuccessAction] \u003cString\u003e] [[-OnSuccessStepId] \u003cInt32\u003e] [[-OnFailAction] \u003cString\u003e] [[-OnFailStepId] \u003cInt32\u003e] \r\n[[-Database] \u003cObject\u003e] [[-DatabaseUser] \u003cString\u003e] [[-RetryAttempts] \u003cInt32\u003e] [[-RetryInterval] \u003cInt32\u003e] \r\n[[-OutputFileName] \u003cString\u003e] [[-Flag] \u003cString[]\u003e] [[-ProxyName] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1\r\n\r\nCreate a step in \"Job1\" with the name Step1 with the default subsystem TransactSql.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1 -Database msdb\r\n\r\nCreate a step in \"Job1\" with the name Step1 where the database will the msdb\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1 -StepName Step1 -Database msdb\r\n\r\nCreate a step in \"Job1\" with the name Step1 where the database will the \"msdb\" for multiple servers\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1, Job2, \u0027Job Three\u0027 -StepName Step1 -Database msdb\r\n\r\nCreate a step in \"Job1\" with the name Step1 where the database will the \"msdb\" for multiple servers for multiple jobs\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003esql1, sql2, sql3 | New-DbaAgentJobStep -Job Job1 -StepName Step1 -Database msdb\r\n\r\nCreate a step in \"Job1\" with the name Step1 where the database will the \"msdb\" for multiple servers using pipeline\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaAgentProxy", "Description": "Adds one or more proxies to SQL Server Agent", "Tags": [ "Agent", "Proxy" ], "Syntax": "\r\nNew-DbaAgentProxy [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString[]\u003e \r\n[-Credential] \u003cString[]\u003e [[-SubSystem] \u003cString[]\u003e] [[-Description] \u003cString\u003e] [[-Login] \u003cString[]\u003e] [[-ServerRole] \r\n\u003cString[]\u003e] [[-MsdbRole] \u003cString[]\u003e] [-Disabled] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Adds one or more proxies to SQL Server Agent", "Name": "New-DbaAgentProxy", "Links": "https://dbatools.io/New-DbaAgentProxy", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentProxy -SqlInstance sql2016 -Name STIG -Credential \u0027PowerShell Proxy\u0027\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentProxy -SqlInstance localhost\\sql2016 -Name STIG -Credential \u0027PowerShell Proxy\u0027 -Description \"Used \r\nfor auditing purposes\" -Login ad\\sqlstig -SubSystem CmdExec, PowerShell -ServerRole securtyadmin -MsdbRole \r\nServerGroupAdministratorRole\r\n\r\nCreates an Agent Proxy on sql2016 with the name STIG with the \u0027PowerShell Proxy\u0027 credential and the following \r\nprincipals:\r\n\r\nLogin: ad\\sqlstig\r\nServerRole: securtyadmin\r\nMsdbRole: ServerGroupAdministratorRole\r\n\r\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaAgentSchedule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] \r\n[[-Schedule] \u003cObject\u003e] [-Disabled] [[-FrequencyType] \u003cObject\u003e] [[-FrequencyInterval] \u003cObject[]\u003e] \r\n[[-FrequencySubdayType] \u003cObject\u003e] [[-FrequencySubdayInterval] \u003cInt32\u003e] [[-FrequencyRelativeInterval] \u003cObject\u003e] \r\n[[-FrequencyRecurrenceFactor] \u003cInt32\u003e] [[-StartDate] \u003cString\u003e] [[-EndDate] \u003cString\u003e] [[-StartTime] \u003cString\u003e] \r\n[[-EndTime] \u003cString\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentSchedule -SqlInstance localhost\\SQL2016 -Schedule daily -FrequencyType Daily -FrequencyInterval \r\nEveryday -Force\r\n\r\nCreates a schedule with a daily frequency every day. It assumes default values for the start date, start time, end date \r\nand end time due to -Force.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentSchedule -SqlInstance sstad-pc -Schedule MonthlyTest -FrequencyType Monthly -FrequencyInterval 10 \r\n-FrequencyRecurrenceFactor 1 -Force\r\n\r\nCreate a schedule with a monhtly frequency occuring every 10th of the month. It assumes default values for the start \r\ndate, start time, end date and end time due to -Force.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaClientAlias", "Description": "Creates/updates a SQL Server alias by altering HKLM:\\SOFTWARE\\Microsoft\\MSSQLServer\\Client", "Tags": "Alias", "Syntax": "\r\nNew-DbaClientAlias [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-ServerName] \r\n\u003cDbaInstanceParameter[]\u003e [-Alias] \u003cString\u003e [[-Protocol] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaClientAlias -ServerName sqlcluster\\sharepoint -Alias sp\r\n\r\nCreates a new TCP alias on the local workstation called sp, which points sqlcluster\\sharepoint\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaClientAlias -ServerName \u0027sqlcluster,14443\u0027 -Alias spinstance\r\n\r\nCreates a new TCP alias on the local workstation called spinstance, which points to sqlcluster, port 14443.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaClientAlias -ServerName sqlcluster\\sharepoint -Alias sp -Protocol NamedPipes\r\n\r\nCreates a new NamedPipes alias on the local workstation called sp, which points sqlcluster\\sharepoint\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] \r\n[-OverrideExplicitCredential] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] \r\n[-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] \r\n[-WindowsCredentialsAreBad] [-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nNew-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-UseWindowsCredentials] [-OverrideExplicitCredential] \r\n[-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] [-DisableBadCredentialCache] \r\n[-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] [-CimWinRMOptions \r\n\u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "Generates a connection object for use in remote computer management.", "Name": "New-DbaCmConnection", "Links": "https://dbatools.io/New-DbaCmConnection", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaCmConnection -ComputerName sql2014 -UseWindowsCredentials -OverrideExplicitCredential \r\n-DisabledConnectionTypes CimRM\r\n\r\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\r\n\r\nUnless caching is globally disabled, this is automatically stored in the connection cache and will be applied \r\nautomatically.\r\nIn that (the default) case, the output is for information purposes only and need not be used.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-Content computers.txt | New-DbaCmConnection -Credential $cred -CimWinRMOptions $options \r\n-DisableBadCredentialCache -OverrideExplicitCredential\r\n\r\nGathers a list of computers from a text file, then creates and registers connections for each of them, setting them to \r\n...\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\r\n\r\nEssentially, this configures all connections to those computers to prefer failure with the specified credentials over \r\nusing alternative credentials.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nNew-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CaServer] \r\n\u003cString\u003e] [[-CaName] \u003cString\u003e] [[-ClusterInstanceName] \u003cString\u003e] [[-Password] \u003cSecureString\u003e] [[-FriendlyName] \r\n\u003cString\u003e] [[-CertificateTemplate] \u003cString\u003e] [[-KeyLength] \u003cInt32\u003e] [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] [[-Dns] \r\n\u003cString[]\u003e] [-SelfSigned] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new computer certificate useful for Forcing Encryption", "Name": "New-DbaComputerCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaComputerCertificate\r\n\r\nCreates a computer certificate signed by the local domain CA for the local machine with the keylength of 1024.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaComputerCertificate -ComputerName Server1\r\n\r\nCreates a computer certificate signed by the local domain CA _on the local machine_ for server1 with the keylength of \r\n1024.\r\n\r\nThe certificate is then copied to the new machine over WinRM and imported.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaComputerCertificate -ComputerName sqla, sqlb -ClusterInstanceName sqlcluster -KeyLength 4096\r\n\r\nCreates a computer certificate for sqlcluster, signed by the local domain CA, with the keylength of 4096.\r\n\r\nThe certificate is then copied to sqla _and_ sqlb over WinRM and imported.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaComputerCertificate -ComputerName Server1 -WhatIf\r\n\r\nShows what would happen if the command were run\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaComputerCertificate -SelfSigned\r\n\r\nCreates a self-signed certificate\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaConnectionString [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [[-AccessToken] \r\n\u003cString\u003e] [[-ApplicationIntent] \u003cString\u003e] [[-BatchSeparator] \u003cString\u003e] [[-ClientName] \u003cString\u003e] [[-ConnectTimeout] \r\n\u003cInt32\u003e] [-EncryptConnection] [[-FailoverPartner] \u003cString\u003e] [-IsActiveDirectoryUniversalAuth] [[-LockTimeout] \u003cInt32\u003e] \r\n[[-MaxPoolSize] \u003cInt32\u003e] [[-MinPoolSize] \u003cInt32\u003e] [-MultipleActiveResultSets] [-MultiSubnetFailover] \r\n[[-NetworkProtocol] \u003cString\u003e] [-NonPooledConnection] [[-PacketSize] \u003cInt32\u003e] [[-PooledConnectionLifetime] \u003cInt32\u003e] \r\n[[-SqlExecutionModes] \u003cString\u003e] [[-StatementTimeout] \u003cInt32\u003e] [-TrustServerCertificate] [[-WorkstationId] \u003cString\u003e] \r\n[[-AppendConnectionString] \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaConnectionString -SqlInstance sql2014\r\n\r\nCreates a connection string that connects using Windows Authentication\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eConnect-DbaInstance -SqlInstance sql2016 | New-DbaConnectionString\r\n\r\nBuilds a connected SMO object using Connect-DbaInstance then extracts and displays the connection string\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$wincred = Get-Credential ad\\sqladmin\r\n\r\nNew-DbaConnectionString -SqlInstance sql2014 -Credential $wincred\r\n\r\nCreates a connection string that connects using alternative Windows credentials\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$sqlcred = Get-Credential sqladmin\r\n\r\n$server = New-DbaConnectionString -SqlInstance sql2014 -Credential $sqlcred\r\n\r\nLogin to sql2014 as SQL login sqladmin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$server = New-DbaConnectionString -SqlInstance sql2014 -ClientName \"mah connection\"\r\n\r\nCreates a connection string that connects using Windows Authentication and uses the client name \"mah connection\". So \r\nwhen you open up profiler or use extended events, you can search for \"mah connection\".\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$server = New-DbaConnectionString -SqlInstance sql2014 -AppendConnectionString \"Packet \r\nSize=4096;AttachDbFilename=C:\\MyFolder\\MyDataFile.mdf;User Instance=true;\"\r\n\r\nCreates a connection string that connects to sql2014 using Windows Authentication, then it sets the packet size (this \r\ncan also be done via -PacketSize) and other connection attributes.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e$server = New-DbaConnectionString -SqlInstance sql2014 -NetworkProtocol TcpIp -MultiSubnetFailover\r\n\r\nCreates a connection string with Windows Authentication that uses TCPIP and has MultiSubnetFailover enabled.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003e$connstring = New-DbaConnectionString sql2016 -ApplicationIntent ReadOnly\r\n\r\nCreates a connection string with ReadOnly ApplicationIntent.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaConnectionStringBuilder", "Description": "Creates a System.Data.SqlClient.SqlConnectionStringBuilder from a connection string.", "Tags": [ "SqlBuild", "ConnectionString", "Connection" ], "Syntax": "\r\nNew-DbaConnectionStringBuilder [[-ConnectionString] \u003cString[]\u003e] [[-ApplicationName] \u003cString\u003e] [[-DataSource] \u003cString\u003e] \r\n[[-InitialCatalog] \u003cString\u003e] [[-IntegratedSecurity] \u003cNullable`1\u003e] [[-UserName] \u003cString\u003e] [[-Password] \u003cString\u003e] \r\n[-MultipleActiveResultSets] [[-ColumnEncryptionSetting] {Disabled | Enabled}] [[-WorkstationId] \u003cString\u003e] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "zippy1981", "Synopsis": "Returns a System.Data.SqlClient.SqlConnectionStringBuilder with the string specified", "Name": "New-DbaConnectionStringBuilder", "Links": "https://dbatools.io/New-DbaConnectionStringBuilder", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaConnectionStringBuilder\r\n\r\nReturns an empty ConnectionStringBuilder\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\"Data Source=localhost,1433;Initial Catalog=AlwaysEncryptedSample;UID=sa;PWD=alwaysB3Encrypt1ng;Application \r\nName=Always Encrypted Sample MVC App;Column Encryption Setting=enabled\" | New-DbaConnectionStringBuilder\r\n\r\nReturns a connection string builder that can be used to connect to the local sql server instance on the default port.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaCredential", "Description": "Creates a new credential", "Tags": "Certificate", "Syntax": "\r\nNew-DbaCredential [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cObject[]\u003e] \r\n[-Identity] \u003cString[]\u003e [[-Password] \u003cSecureString\u003e] [[-MappedClassType] \u003cString\u003e] [[-ProviderName] \u003cString\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new SQL Server credential", "Name": "New-DbaCredential", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaCredential -SqlInstance Server1\r\n\r\nYou will be prompted to securely enter your password, then a credential will be created in the master database on \r\nserver1 if it does not exist.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaCredential -SqlInstance Server1 -Database db1 -Confirm:$false\r\n\r\nSuppresses all prompts to install but prompts to securely enter your password and creates a credential in the \u0027db1\u0027 \r\ndatabase\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nNew-DbaCredential -SqlInstance Server1 -Name AzureBackupBlobStore -Identity \u0027\u003cAzure Storage Account Name\u003e\u0027 -Password \r\n(ConvertTo-SecureString \u0027\u003cAzure Storage Account Access Key\u003e\u0027 -AsPlainText -Force)\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nNew-DbaCredential -SqlInstance Server1 -Name \u0027https://\u003cAzure Storage Account Name\u003e.blob.core.windows.net/\u003cBlob Store \r\nContainer Name\u003e\u0027 -Identity \u0027SHARED ACCESS SIGNATURE\u0027 -Password (ConvertTo-SecureString \u0027\u003cShared Access Token\u003e\u0027 \r\n-AsPlainText -Force)\r\n\r\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).\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaDacProfile", "Description": "The New-PublishProfile 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", "Syntax": "\r\nNew-DbaDacProfile [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \u003cString[]\u003e \r\n[[-Path] \u003cString\u003e] [[-ConnectionString] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Richie lee (@bzzzt_io)", "Synopsis": "Creates a new Publish Profile.", "Name": "New-DbaDacProfile", "Links": "https://dbatools.io/New-DbaDacProfile", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDacProfile -SqlInstance sql2017 -SqlCredential (Get-Credential) -Database WorldWideImporters -Path C:\\temp\r\n\r\nIn this example, a prompt will appear for alternative credentials, then a connection will be made to sql2017. Using \r\nthat connection,\r\nthe ConnectionString will be extracted and used within the Publish Profile XML file which will be created at \r\nC:\\temp\\sql2017-WorldWideImporters-publish.xml\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDacProfile -Database WorldWideImporters -Path C:\\temp -ConnectionString \r\n\"SERVER=(localdb)\\MSSQLLocalDB;Integrated Security=True;Database=master\"\r\n\r\nIn this example, no connections are made, and a Publish Profile XML would be created at \r\nC:\\temp\\localdb-MSSQLLocalDB-WorldWideImporters-publish.xml\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaDbCertificate", "Description": "Creates a new database certificate. If no database is specified, the certificate will be created in master.", "Tags": "Certificate", "Syntax": "\r\nNew-DbaDbCertificate [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \u003cString[]\u003e] \r\n[[-Database] \u003cObject[]\u003e] [[-Subject] \u003cString[]\u003e] [[-StartDate] \u003cDateTime\u003e] [[-ExpirationDate] \u003cDateTime\u003e] \r\n[-ActiveForServiceBrokerDialog] [[-Password] \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new database certificate", "Name": "New-DbaDbCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbCertificate -SqlInstance Server1\r\n\r\nYou will be prompted to securely enter your password, then a certificate will be created in the master database on \r\nserver1 if it does not exist.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbCertificate -SqlInstance Server1 -Database db1 -Confirm:$false\r\n\r\nSuppresses all prompts to install but prompts to securely enter your password and creates a certificate in the \u0027db1\u0027 \r\ndatabase\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nNew-DbaDbMasterKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[-Password] \u003cSecureString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new database master key", "Name": "New-DbaDbMasterKey", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbMasterKey -SqlInstance Server1\r\n\r\nYou will be prompted to securely enter your password, then a master key will be created in the master database on \r\nserver1 if it does not exist.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbMasterKey -SqlInstance Server1 -Database db1 -Confirm:$false\r\n\r\nSuppresses all prompts to install but prompts to securely enter your password and creates a master key in the \u0027db1\u0027 \r\ndatabase\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaDbSnapshot", "Description": "Creates database snapshots without hassles", "Tags": [ "Snapshot", "Restore", "Database" ], "Syntax": "\r\nNew-DbaDbSnapshot [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-AllDatabases] [[-Name] \u003cString\u003e] [[-NameSuffix] \u003cString\u003e] [[-Path] \u003cString\u003e] [-Force] \r\n[[-InputObject] \u003cDatabase[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Creates database snapshots", "Name": "New-DbaDbSnapshot", "Links": "https://dbatools.io/New-DbaDbSnapshot", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting\r\n\r\nCreates snapshot for HR and Accounting, returning a custom object displaying Server, Database, DatabaseCreated, \r\nSnapshotOf, SizeMB, DatabaseCreated, PrimaryFilePath, Status, Notes\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR -Name HR_snap\r\n\r\nCreates snapshot named \"HR_snap\" for HR\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR -NameSuffix \u0027fool_{0}_snap\u0027\r\n\r\nCreates snapshot named \"fool_HR_snap\" for HR\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbSnapshot -SqlInstance sqlserver2014a -Database HR, Accounting -Path F:\\snapshotpath\r\n\r\nCreates snapshots for HR and Accounting databases, storing files under the F:\\snapshotpath\\ dir\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2016 -Database df | New-DbaDbSnapshot\r\n\r\nCreates a snapshot for the database df on sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaDbUser", "Description": "Creates a new user for a specified database with provided specifications.", "Tags": [ "Database", "User" ], "Syntax": "\r\nNew-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-IncludeSystem] [-Username \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nNew-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-IncludeSystem] [-Login \u003cString[]\u003e] [-Username \u003cString[]\u003e] [-Force] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Frank Henninger (@osiris687)", "Synopsis": "Creates a new user for the specified database.", "Name": "New-DbaDbUser", "Links": "https://dbatools.io/New-DbaDbUser", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbUser -SqlInstance sqlserver2014 -Database DB1 -Login user1\r\n\r\nCreates a new sql user with login named user1 in the specified database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbUser -SqlInstance sqlserver2014 -Database DB1 -Username user1\r\n\r\nCreates a new sql user without login named user1 in the specified database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDbUser -SqlInstance sqlserver2014 -Database DB1 -Login Login1 -Username user1\r\n\r\nCreates a new sql user named user1 mapped to Login1 in the specified database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUser -SqlInstance sqlserver1 -Database DB1 | New-DbaDbUser -SqlInstance sqlserver2 -Database DB1\r\n\r\nCopies users from sqlserver1.DB1 to sqlserver2.DB1. Does not copy permissions!\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaDirectory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-Path] \u003cString\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stuart Moore", "Synopsis": "Creates new path as specified by the path variable", "Name": "New-DbaDirectory", "Links": "https://dbatools.io/New-DbaDirectory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDirectory -SqlInstance sqlcluster -Path L:\\MSAS12.MSSQLSERVER\\OLAP\r\n\r\nIf the SQL Server instance sqlcluster can create the path L:\\MSAS12.MSSQLSERVER\\OLAP it will do and return $true, if \r\nnot it will return $false.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$credential = Get-Credential\r\n\r\nNew-DbaDirectory -SqlInstance sqlcluster -SqlCredential $credential -Path L:\\MSAS12.MSSQLSERVER\\OLAP\r\n\r\nIf the SQL Server instance sqlcluster can create the path L:\\MSAS12.MSSQLSERVER\\OLAP it will do and return $true, if \r\nnot it will return $false. Uses a SqlCredential to connect\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaLogin", "Description": "Creates a new SQL Server login with provided specifications", "Tags": "Login", "Syntax": "\r\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] \r\n[-InputObject \u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [[-Password] \u003cSecureString\u003e] [-MapToCredential \u003cString\u003e] \r\n[-Sid \u003cObject\u003e] [-DefaultDatabase \u003cString\u003e] [-Language \u003cString\u003e] [-PasswordExpiration] [-PasswordPolicy] [-Disabled] \r\n[-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cString[]\u003e] [-InputObject \r\n\u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-MapToAsymmetricKey \u003cString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \r\n\u003cObject\u003e] [-Disabled] [-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cString[]\u003e] [-InputObject \r\n\u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-MapToCertificate \u003cString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \r\n\u003cObject\u003e] [-Disabled] [-NewSid] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nNew-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cString[]\u003e] [-InputObject \r\n\u003cObject[]\u003e] [-LoginRenameHashtable \u003cHashtable\u003e] [-HashedPassword \u003cString\u003e] [-MapToCredential \u003cString\u003e] [-Sid \u003cObject\u003e] \r\n[-DefaultDatabase \u003cString\u003e] [-Language \u003cString\u003e] [-PasswordExpiration] [-PasswordPolicy] [-Disabled] [-NewSid] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Creates a new SQL Server login", "Name": "New-DbaLogin", "Links": "https://dbatools.io/New-DbaLogin", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaLogin -SqlInstance Server1,Server2 -Login Newlogin\r\n\r\nYou will be prompted to securely enter the password for a login [Newlogin]. The login would be created on servers \r\nServer1 and Server2 with default parameters.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$securePassword = Read-Host \"Input password\" -AsSecureString\r\n\r\nNew-DbaLogin -SqlInstance Server1\\sql1 -Login Newlogin -Password $securePassword -PasswordPolicy -PasswordExpiration\r\n\r\nCreates a login on Server1\\sql1 with a predefined password. The login will have password and expiration policies \r\nenforced onto it.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql1 -Login Oldlogin | New-DbaLogin -SqlInstance sql1 -LoginRenameHashtable @{Oldlogin \r\n= \u0027Newlogin\u0027} -Force -NewSid -Disabled:$false\r\n\r\nCopies a login [Oldlogin] to the same instance sql1 with the same parameters (including password). New login will have \r\na new sid, a new name [Newlogin] and will not be disabled. Existing login [Newlogin] will be removed prior to creation.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance sql1 -Login Login1,Login2 | New-DbaLogin -SqlInstance sql2 -PasswordPolicy \r\n-PasswordExpiration -DefaultDatabase tempdb -Disabled\r\n\r\nCopies logins [Login1] and [Login2] from instance sql1 to instance sql2, but enforces password and expiration policies \r\nfor the new logins. New logins will also have a default database set to [tempdb] and will be created in a disabled \r\nstate.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaScriptingOption [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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\nhttps://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.scriptingoptions.aspx", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$options = New-DbaScriptingOption\r\n\r\n$options.ScriptDrops = $false\r\n$options.WithDependencies = $true\r\nGet-DbaAgentJob -SqlInstance sql2016 | Export-DbaScript -ScriptingOptionObject $options\r\n\r\nExports Agent Jobs with the Scripting Options ScriptDrops set to $false and WithDependencies set to true\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaServiceMasterKey", "Description": "Creates a new service master key in the master database", "Tags": "Certificate", "Syntax": "\r\nNew-DbaServiceMasterKey [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Password] \r\n\u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Creates a new service master key", "Name": "New-DbaServiceMasterKey", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaServiceMasterKey -SqlInstance Server1\r\n\r\nYou will be prompted to securely enter your Service Key Password twice, then a master key will be created in the master \r\ndatabase on server1 if it does not exist.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaSsisCatalog [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Password] \u003cSecureString\u003e \r\n[[-SsisCatalog] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$password = ConvertTo-SecureString MyVisiblePassWord -AsPlainText -Force\r\n\r\nNew-DbaSsisCatalog -SqlInstance sql2016 -Password $password\r\n\r\nCreates the SSIS Catalog on server DEV01 with the specified password.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$password = Read-Host -AsSecureString -Prompt \"Enter password\"\r\n\r\nNew-DbaSsisCatalog -SqlInstance DEV01 -Password $password\r\n\r\nCreates the SSIS Catalog on server DEV01 with the specified password.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nNew-DbatoolsSupportPackage [[-Path] \u003cString\u003e] [[-Variables] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbatoolsSupportPackage\r\n\r\nCreates a large support pack in order to help us troubleshoot stuff.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Name] \u003cString\u003e \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$session = New-DbaXESession -SqlInstance sql2017 -Name XeSession_Test\r\n\r\n$event = $session.AddEvent(\"sqlserver.file_written\")\r\n$event.AddAction(\"package0.callstack\")\r\n$session.Create()\r\n\r\nReturns a new XE Session object from sql2017 then adds an event, an action then creates it.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaXESmartCsvWriter", "Description": "This Response type is used to write Extended Events to a CSV file.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nNew-DbaXESmartCsvWriter [-OutputFile] \u003cString\u003e [-Overwrite] [[-Event] \u003cString[]\u003e] [[-OutputColumn] \u003cString[]\u003e] \r\n[[-Filter] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "This Response type is used to write Extended Events to a CSV file.", "Name": "New-DbaXESmartCsvWriter", "Links": "https://dbatools.io/New-DbaXESmartCsvWriter\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$columns = \"cpu_time\", \"duration\", \"physical_reads\", \"logical_reads\", \"writes\", \"row_count\"\r\n\r\n$response = New-DbaXESmartCsvWriter -OutputFile c:\\temp\\workload.csv -OutputColumn $columns -OverWrite -Event \r\n\"sql_batch_completed\"\r\nStart-DbaXESmartTarget -SqlInstance localhost\\sql2017 -Session \"Profiler Standard\" -Responder $response\r\n\r\nWrites Extended Events to the file \"C:\\temp\\workload.csv\".\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "New-DbaXESmartEmail", "Description": "This Response type can be used to send an email each time an event is captured.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nNew-DbaXESmartEmail [-SmtpServer] \u003cString\u003e [-Sender] \u003cString\u003e [-To] \u003cString[]\u003e [[-Cc] \u003cString[]\u003e] [[-Bcc] \u003cString[]\u003e] \r\n[[-Credential] \u003cPSCredential\u003e] [-Subject] \u003cString\u003e [-Body] \u003cString\u003e [[-Attachment] \u003cString\u003e] [[-AttachmentFileName] \r\n\u003cString\u003e] [[-PlainText] \u003cString\u003e] [[-Event] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "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\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$params = @{\r\n\r\nSmtpServer = \"smtp.ad.local\"\r\n To = \"admin@ad.local\"\r\n Sender = \"reports@ad.local\"\r\n Subject = \"Query executed\"\r\n Body = \"Query executed at {collection_time}\"\r\n Attachment = \"batch_text\"\r\n AttachmentFileName = \"query.sql\"\r\n}\r\n$emailresponse = New-DbaXESmartEmail @params\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session querytracker -Responder $emailresponse\r\n\r\nSends an email each time a querytracker event is captured.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaXESmartQueryExec [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cString\u003e] [[-Query] \u003cString\u003e] [-EnableException] [[-Event] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "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\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query \"update table set whatever = 1\"\r\n\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\r\n\r\nExecutes a T-SQL command against dbadb on sql2017 whenever a deadlock event is recorded.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaXESmartReplay [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] \r\n[[-Event] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [[-DelaySeconds] \u003cInt32\u003e] [-StopOnError] [[-ReplayIntervalSeconds] \u003cInt32\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "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\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$response = New-DbaXESmartReplay -SqlInstance sql2017 -Database planning\r\n\r\nStart-DbaXESmartTarget -SqlInstance sql2016 -Session loadrelay -Responder $response\r\n\r\nReplays events from sql2016 on sql2017 in the planning database. Returns a PowerShell job object.\r\n\r\nTo see a list of all SmartTarget job objects, use Get-DbaXESmartTarget.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$response = New-DbaXESmartReplay -SqlInstance sql2017 -Database planning\r\n\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session \u0027Profiler Standard\u0027 -Responder $response -NotAsJob\r\n\r\nReplays events from the \u0027Profiler Standard\u0027 session on sql2016 to sql2017\u0027s planning database. Does not run as a job so \r\nyou can see the raw output.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nNew-DbaXESmartTableWriter [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Database] \r\n\u003cString\u003e [-Table] \u003cString\u003e [-AutoCreateTargetTable] [[-UploadIntervalSeconds] \u003cInt32\u003e] [[-Event] \u003cString[]\u003e] \r\n[[-OutputColumn] \u003cString[]\u003e] [[-Filter] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "This Response type is used to write Extended Events to a database table.", "Name": "New-DbaXESmartTableWriter", "Links": "https://dbatools.io/New-DbaXESmartTableWriter\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$columns = \"cpu_time\", \"duration\", \"physical_reads\", \"logical_reads\", \"writes\", \"row_count\", \"batch_text\"\r\n\r\n$response = New-DbaXESmartTableWriter -SqlInstance sql2017 -Database dbadb -Table deadlocktracker -OutputColumn \r\n$columns -Filter \"duration \u003e 10000\"\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\r\n\r\nWrites Extended Events to the deadlocktracker table in dbadb on sql2017.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 and this uses that nuget package.", "Tags": [ "Migration", "Database", "Dacpac" ], "Syntax": "\r\nPublish-DbaDacPackage [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cString\u003e \r\n[-PublishXml] \u003cString\u003e [-Database] \u003cString[]\u003e [[-ConnectionString] \u003cString[]\u003e] [-GenerateDeploymentScript] \r\n[-GenerateDeploymentReport] [-ScriptOnly] [[-OutputPath] \u003cString\u003e] [-IncludeSqlCmdVars] [-EnableException] \r\n[[-DacFxPath] \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Richie lee (@bzzzt_io)", "Synopsis": "The Publish-Database 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003ePublish-DbaDacPackage -SqlInstance sql2017 -Database WideWorldImporters -Path \r\nC:\\temp\\sql2016-WideWorldImporters.dacpac -PublishXml C:\\temp\\sql2016-WideWorldImporters-publish.xml\r\n\r\nUpdates WideWorldImporters on sql2017 from the sql2016-WideWorldImporters.dacpac using the \r\nsql2016-WideWorldImporters-publish.xml publish profile\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaDacProfile -SqlInstance sql2016 -Database db2 -Path C:\\temp\r\n\r\nExport-DbaDacPackage -SqlInstance sql2016 -Database db2 | Publish-DbaDacPackage -PublishXml \r\nC:\\temp\\sql2016-db2-publish.xml -Database db1, db2 -SqlInstance sql2017\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$loc = \"C:\\Users\\bob\\source\\repos\\Microsoft.Data.Tools.Msbuild\\lib\\net46\\Microsoft.SqlServer.Dac.dll\"\r\n\r\nPublish-DbaDacPackage -SqlInstance \"local\" -Database WideWorldImporters -Path C:\\temp\\WideWorldImporters.dacpac \r\n-PublishXml C:\\temp\\WideWorldImporters.publish.xml -DacFxPath $loc\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Read-DbaAuditFile", "Description": "Read Audit details from a sqlaudit file.", "Tags": [ "ExtendedEvent", "Audit" ], "Syntax": "\r\nRead-DbaAuditFile [-Path] \u003cObject[]\u003e [-Exact] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Read Audit details from a sqlaudit file.", "Name": "Read-DbaAuditFile", "Links": "https://dbatools.io/Read-DbaAuditFile", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaAuditFile -Path C:\\temp\\logins.sqlaudit\r\n\r\nReturns events from C:\\temp\\logins.sqlaudit.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem C:\\temp\\audit\\*.sqlaudit | Read-DbaAuditFile\r\n\r\nReturns events from all .sqlaudit files in C:\\temp\\audit.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaServerAudit -SqlInstance sql2014 -Audit LoginTracker | Read-DbaAuditFile\r\n\r\nReads remote Audit details by accessing the file over the admin UNC share.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRead-DbaBackupHeader [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cObject[]\u003e \r\n[-Simple] [-FileList] [[-AzureCredential] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance sql2016 -Path S:\\backups\\mydb\\mydb.bak\r\n\r\nLogs into sql2016 using Windows authentication and reads the local file on sql2016, S:\\backups\\mydb\\mydb.bak.\r\n\r\nIf you are running this command on a workstation and connecting remotely, remember that sql2016 cannot access files on \r\nyour own workstation.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance sql2016 -Path \\\\nas\\sql\\backups\\mydb\\mydb.bak, \r\n\\\\nas\\sql\\backups\\otherdb\\otherdb.bak\r\n\r\nLogs into sql2016 and reads two backup files - mydb.bak and otherdb.bak. The SQL Server service account must have \r\nrights to read this file.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak -Simple\r\n\r\nLogs into the local workstation (or computer) and shows simplified output about C:\\temp\\myfile.bak. The SQL Server \r\nservice account must have rights to read this file.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$backupinfo = Read-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak\r\n\r\n$backupinfo.FileList\r\n\r\nDisplays detailed information about each of the datafiles contained in the backupset.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaBackupHeader -SqlInstance . -Path C:\\temp\\myfile.bak -FileList\r\n\r\nAlso returns detailed information about each of the datafiles contained in the backupset.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e\"C:\\temp\\myfile.bak\", \"\\backupserver\\backups\\myotherfile.bak\" | Read-DbaBackupHeader -SqlInstance sql2016\r\n\r\nSimilar to running Read-DbaBackupHeader -SqlInstance sql2016 -Path \"C:\\temp\\myfile.bak\", \r\n\"\\backupserver\\backups\\myotherfile.bak\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem \\\\nas\\sql\\*.bak | Read-DbaBackupHeader -SqlInstance sql2016\r\n\r\nGets a list of all .bak files on the \\\\nas\\sql share and reads the headers using the server named \"sql2016\". This means \r\nthat the server, sql2016, must have read access to the \\\\nas\\sql share.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaBackupHeader -Path \r\nhttps://dbatoolsaz.blob.core.windows.net/azbackups/restoretime/restoretime_201705131850.bak\r\n\r\n-AzureCredential AzureBackupUser\r\n\r\nGets the backup header information from the SQL Server backup file stored at \r\nhttps://dbatoolsaz.blob.core.windows.net/azbackups/restoretime/restoretime_201705131850.bak on Azure\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRead-DbaTraceFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Path \u003cString[]\u003e] [-Database \r\n\u003cString[]\u003e] [-Login \u003cString[]\u003e] [-Spid \u003cInt32[]\u003e] [-EventClass \u003cString[]\u003e] [-ObjectType \u003cString[]\u003e] [-Error \u003cInt32[]\u003e] \r\n[-EventSequence \u003cInt32[]\u003e] [-TextData \u003cString[]\u003e] [-ApplicationName \u003cString[]\u003e] [-ObjectName \u003cString[]\u003e] [-Where \r\n\u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Reads SQL Server trace files", "Name": "Read-DbaTraceFile", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaTraceFile -SqlInstance sql2016 -Database master, tempdb -Path C:\\traces\\big.trc\r\n\r\nReads the tracefile C:\\traces\\big.trc, stored on the sql2016 sql server. Filters only results that have master or \r\ntempdb as the DatabaseName.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaTraceFile -SqlInstance sql2016 -Database master, tempdb -Path C:\\traces\\big.trc -TextData \u0027EXEC \r\nSP_PROCOPTION\u0027\r\n\r\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 \r\ntext.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nRead-DbaTraceFile -SqlInstance sql2016 -Path C:\\traces\\big.trc -Where \"LinkedServerName = \u0027myls\u0027 and StartTime \r\n\u003e\u00275/30/2017 4:27:52 PM\u0027\"\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2014 | Read-DbaTraceFile\r\n\r\nReads every trace file on sql2014\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRead-DbaTransactionLog [-SqlInstance] \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject\u003e \r\n[-IgnoreLimit] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Reads the live Transaction log from specified SQL Server Database", "Name": "Read-DbaTransactionLog", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase\r\n\r\nWill read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell \r\nobject $Log\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$Log = Read-DbaTransactionLog -SqlInstance sql2016 -Database MyDatabase -IgnoreLimit\r\n\r\nWill read the contents of the transaction log of MyDatabase on SQL Server Instance sql2016 into the local PowerShell \r\nobject $Log, ignoring the recommendation of not returning more that 0.5GB of log\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Read-DbaXEFile", "Description": "Read XEvents from a xel or xem file.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nRead-DbaXEFile [-Path] \u003cObject[]\u003e [-Exact] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRead-DbaXEFile -Path C:\\temp\\deadocks.xel\r\n\r\nReturns events from C:\\temp\\deadocks.xel.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem C:\\temp\\xe\\*.xel | Read-DbaXEFile\r\n\r\nReturns events from all .xel files in C:\\temp\\xe.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2014 -Session deadlocks | Read-DbaXEFile\r\n\r\nReads remote XEvents by accessing the file over the admin UNC share.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRegister-DbatoolsConfig [[-Config] \u003cConfig[]\u003e] [[-FullName] \u003cString[]\u003e] [-Scope {UserDefault | UserMandatory | \r\nSystemDefault | SystemMandatory}] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nRegister-DbatoolsConfig [-Module] \u003cString\u003e [[-Name] \u003cString\u003e] [-Scope {UserDefault | UserMandatory | SystemDefault | \r\nSystemMandatory}] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Friedrich Weinmann", "Synopsis": "Registers an existing configuration object in registry.", "Name": "Register-DbatoolsConfig", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbatoolsConfig message.* | Register-DbatoolsConfig\r\n\r\nRetrieves all configuration items that that start with message. and registers them in registry for the current user.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRegister-DbatoolsConfig -FullName \"developer.mode.enable\" -Scope SystemDefault\r\n\r\nRetrieves the configuration item \"developer.mode.enable\" and registers it in registry as the default setting for all \r\nusers on this machine.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRegister-DbatoolsConfig -Module message -Scope SystemMandatory\r\n\r\nRetrieves all configuration items of the module MyModule, then registers them in registry to enforce them for all users \r\non the current system.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaAgentJob", "Description": "Remove-DbaAgentJob removes a a job in the SQL Server Agent.", "Tags": [ "Agent", "Job" ], "Syntax": "\r\nRemove-DbaAgentJob [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] \r\n[-KeepHistory] [-KeepUnusedSchedule] [[-Mode] {Strict | Lazy | Report}] [[-InputObject] \u003cJob[]\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Remove-DbaAgentJob removes a job.", "Name": "Remove-DbaAgentJob", "Links": "https://dbatools.io/Remove-DbaAgentJob", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJob -SqlInstance sql1 -Job Job1\r\n\r\nRemoves the job from the instance with the name Job1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGetDbaAgentJob -SqlInstance sql1 -Job Job1 | Remove-DbaAgentJob -KeepHistory\r\n\r\n\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJob -SqlInstance sql1 -Job Job1 -KeepUnusedSchedule\r\n\r\nRemoves the job but keeps the unused schedules\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job Job1\r\n\r\nRemoves the job from multiple servers\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRemove-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \r\n\u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Remove-DbaAgentJobCategory removes a job category.", "Name": "Remove-DbaAgentJobCategory", "Links": "https://dbatools.io/Remove-DbaAgentJobCategory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 1\u0027\r\n\r\nRemove the job category Category 1 from the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJobCategory -SqlInstance sql1 -Category Category1, Category2, Category3\r\n\r\nRemove multiple job categories from the instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJobCategory -SqlInstance sql1, sql2, sql3 -Category Category1, Category2, Category3\r\n\r\nRemove multiple job categories from the multiple instances.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaAgentJobStep", "Description": "Removes a job step from a SQL Server Agent job.", "Tags": [ "Agent", "Job", "JobStep" ], "Syntax": "\r\nRemove-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e \r\n[-StepName] \u003cString\u003e [[-Mode] {Strict | Lazy | Report}] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1\r\n\r\nRemove \u0027Step1\u0027 from job \u0027Job1\u0027 on sql1.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJobStep -SqlInstance sql1 -Job Job1, Job2, Job3 -StepName Step1\r\n\r\nRemove the job step from multiple jobs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1 -StepName Step1\r\n\r\nRemove the job step from the job on multiple servers.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003esql1, sql2, sql3 | Remove-DbaAgentJobStep -Job Job1 -StepName Step1\r\n\r\nRemove the job step from the job on multiple servers using pipeline.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaAgentSchedule", "Description": "Remove-DbaAgentJobSchedule removes a a job in the SQL Server Agent.", "Tags": [ "Agent", "Job", "Schedule" ], "Syntax": "\r\nRemove-DbaAgentSchedule -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Schedule \u003cObject[]\u003e \r\n[-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaAgentSchedule [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cScheduleBase[]\u003e [-EnableException] [-Force] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Remove-DbaAgentJobSchedule removes a job schedule.", "Name": "Remove-DbaAgentSchedule", "Links": "https://dbatools.io/Remove-DbaAgentJobSchedule", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1 -Schedule weekly\r\n\r\nRemove the schedule weekly\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1 -Schedule weekly -Force\r\n\r\nRemove the schedule weekly from the job even if the schedule is being used by another job.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1 -Schedule daily, weekly\r\n\r\nRemove multiple schedule\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -Schedule daily, weekly\r\n\r\nRemove the schedule on multiple servers for multiple schedules\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003esql1, sql2, sql3 | Remove-DbaAgentSchedule -Schedule daily, weekly\r\n\r\nRemove the schedule on multiple servers using pipe line\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentSchedule -SqlInstance sql1 -Schedule sched1, sched2, sched3 | Remove-DbaAgentSchedule\r\n\r\nRemove the schedules using a pipeline\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaBackup", "Description": "Provides 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" ], "Syntax": "\r\nRemove-DbaBackup [-Path] \u003cString\u003e [-BackupFileExtension] \u003cString\u003e [-RetentionPeriod] \u003cString\u003e [-CheckArchiveBit] \r\n[-RemoveEmptyBackupFolder] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chris Sommer, @cjsommer, www.cjsommer.com", "Synopsis": "Removes SQL Server backups from disk.", "Name": "Remove-DbaBackup", "Links": "https://dbatools.io/Remove-DbaBackup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\SQL Backup\\\u0027 -BackupFileExtension trn -RetentionPeriod 48h\r\n\r\n\u0027*.trn\u0027 files in \u0027C:\\MSSQL\\SQL Backup\\\u0027 and all subdirectories that are more than 48 hours old will be removed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\SQL Backup\\\u0027 -BackupFileExtension trn -RetentionPeriod 48h -WhatIf\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\Backup\\\u0027 -BackupFileExtension bak -RetentionPeriod 7d -CheckArchiveBit\r\n\r\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 \r\nthe files have been backed up to another location as verified by checking the Archive bit.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaBackup -Path \u0027C:\\MSSQL\\Backup\\\u0027 -BackupFileExtension bak -RetentionPeriod 1w -RemoveEmptyBackupFolder\r\n\r\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 \r\nleft empty will be removed as well.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaClientAlias", "Description": "Removes a SQL Server alias by altering HKLM:\\SOFTWARE\\Microsoft\\MSSQLServer\\Client", "Tags": "Alias", "Syntax": "\r\nRemove-DbaClientAlias [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Alias] \u003cString[]\u003e \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaClientAlias -ComputerName workstationx -Alias sqlps\r\n\r\nRemoves the sqlps SQL client alias on workstationx\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaClientAlias | Remove-DbaClientAlias\r\n\r\nRemoves all SQL Server client aliases on the local computer\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaCmConnection", "Description": "Removes connection objects from the connection cache used for remote computer management.", "Tags": [ "ComputerManagement", "CIM" ], "Syntax": "\r\nRemove-DbaCmConnection [-ComputerName] \u003cDbaCmConnectionParameter[]\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "Removes connection objects from the connection cache used for remote computer management.", "Name": "Remove-DbaCmConnection", "Links": "https://dbatools.io/Remove-DbaCmConnection", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaCmConnection -ComputerName sql2014\r\n\r\nRemoves the cached connection to the server sql2014 from the cache.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection | Remove-DbaCmConnection\r\n\r\nClears the entire connection cache.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaComputerCertificate", "Description": "Removes a computer certificate from a local or remote compuer", "Tags": "Certificate", "Syntax": "\r\nRemove-DbaComputerCertificate [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Thumbprint] \r\n\u003cString[]\u003e [[-Store] \u003cString\u003e] [[-Folder] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes a computer certificate - useful for removing easily certs from remote computers", "Name": "Remove-DbaComputerCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaComputerCertificate -ComputerName Server1 -Thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94\r\n\r\nRemoves certificate with thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94 in the LocalMachine store on Server1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaComputerCertificate | Where-Object Thumbprint -eq E0A071E387396723C45E92D42B2D497C6A182340 | \r\nRemove-DbaComputerCertificate\r\n\r\nRemoves certificate using the pipeline\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaComputerCertificate -ComputerName Server1 -Thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94 -Store \r\nUser -Folder My\r\n\r\nRemoves certificate with thumbprint C2BBE81A94FEE7A26FFF86C2DFDAF6BFD28C6C94 in the User\\My (Personal) store on Server1\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaDatabase", "Description": "Tries a bunch of different ways to remove a database or two or more.", "Tags": [ "Delete", "Databases" ], "Syntax": "\r\nRemove-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-IncludeSystemDb] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDatabase -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject[]\u003e \r\n[-IncludeSystemDb] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cDatabase[]\u003e [-IncludeSystemDb] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabase -SqlInstance sql2016 -Database containeddb\r\n\r\nPrompts then removes the database containeddb on SQL Server sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabase -SqlInstance sql2016 -Database containeddb, mydb\r\n\r\nPrompts then removes the databases containeddb and mydb on SQL Server sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabase -SqlInstance sql2016 -Database containeddb -Confirm:$false\r\n\r\nDoes not prompt and swiftly removes containeddb on SQL Server sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance server\\instance -ExcludeAllSystemDb | Remove-DbaDatabase\r\n\r\nRemoves all the user databases from server\\instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance server\\instance -ExcludeAllSystemDb | Remove-DbaDatabase -Confirm:$false\r\n\r\nRemoves all the user databases from server\\instance without any confirmation\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRemove-DbaDatabaseSafely [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-Destination] \u003cDbaInstanceParameter\u003e] [[-DestinationCredential] \u003cPSCredential\u003e] [-NoDbccCheckDb] \r\n[-BackupFolder] \u003cString\u003e [[-CategoryName] \u003cString\u003e] [[-JobOwner] \u003cString\u003e] [-AllDatabases] [[-BackupCompression] \r\n\u003cString\u003e] [-ReuseSourceFolderStructure] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance \u0027Fade2Black\u0027 -Database RideTheLightning -BackupFolder \r\n\u0027C:\\MSSQL\\Backup\\Rationalised - DO NOT DELETE\u0027\r\n\r\nPerforms a DBCC CHECKDB on database RideTheLightning on server Fade2Black. If there are no errors, the database is \r\nbackup to the folder C:\\MSSQL\\Backup\\Rationalised - DO NOT DELETE. Then, an Agent job to restore the database from that \r\nbackup is created. The database is then dropped, the Agent job to restore it run, a DBCC CHECKDB run against the \r\nrestored database, and then it is dropped again.\r\n\r\nAny DBCC errors will be written to your documents folder\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$Database = \u0027DemoNCIndex\u0027,\u0027RemoveTestDatabase\u0027\r\n\r\nRemove-DbaDatabaseSafely -SqlInstance \u0027Fade2Black\u0027 -Database $Database -BackupFolder \u0027C:\\MSSQL\\Backup\\Rationalised - DO \r\nNOT DELETE\u0027\r\n\r\nPerforms a DBCC CHECKDB on two databases, \u0027DemoNCIndex\u0027 and \u0027RemoveTestDatabase\u0027 on server Fade2Black. Then, an Agent \r\njob to restore each database from those backups is created. The databases are then dropped, the Agent jobs to restore \r\nthem run, a DBCC CHECKDB run against the restored databases, and then they are dropped again.\r\n\r\nAny DBCC errors will be written to your documents folder\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance \u0027Fade2Black\u0027 -DestinationServer JusticeForAll -Database RideTheLightning \r\n-BackupFolder \u0027\\\\BACKUPSERVER\\BACKUPSHARE\\MSSQL\\Rationalised - DO NOT DELETE\u0027\r\n\r\nPerforms a DBCC CHECKDB on database RideTheLightning on server Fade2Black. If there are no errors, the database is \r\nbackup to the folder \\\\BACKUPSERVER\\BACKUPSHARE\\MSSQL\\Rationalised - DO NOT DELETE . Then, an Agent job is created on \r\nserver JusticeForAll to restore the database from that backup is created. The database is then dropped on Fade2Black, \r\nthe Agent job to restore it on JusticeForAll is run, a DBCC CHECKDB run against the restored database, and then it is \r\ndropped from JusticeForAll.\r\n\r\nAny DBCC errors will be written to your documents folder\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance IronMaiden -Database $Database -DestinationServer TheWildHearts \r\n-BackupFolder Z:\\Backups -NoDbccCheckDb -UseDefaultFilePaths -JobOwner \u0027THEBEARD\\Rob\u0027\r\n\r\nFor the databases $Database on the server IronMaiden a DBCC CHECKDB will not be performed before backing up the \r\ndatabases to the folder Z:\\Backups. Then, an Agent job is created on server TheWildHearts with a Job Owner of \r\nTHEBEARD\\Rob to restore each database from that backup using the instance\u0027s default file paths. The database(s) is(are) \r\nthen dropped on IronMaiden, the Agent job(s) run, a DBCC CHECKDB run on the restored database(s), and then the \r\ndatabase(s) is(are) dropped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDatabaseSafely -SqlInstance IronMaiden -Database $Database -DestinationServer TheWildHearts \r\n-BackupFolder Z:\\Backups -UseDefaultFilePaths -ContinueAfterDbccError\r\n\r\nThe databases $Database on the server IronMaiden will be backed up the to the folder Z:\\Backups. Then, an Agent job is \r\ncreated on server TheWildHearts with a Job Owner of THEBEARD\\Rob to restore each database from that backup using the \r\ninstance\u0027s default file paths. The database(s) is(are) then dropped on IronMaiden, the Agent job(s) run, a DBCC CHECKDB \r\nrun on the restored database(s), and then the database(s) is(are) dropped.\r\n\r\nIf there is a DBCC Error, the function will continue to perform rest of the actions and will create an Agent job with \r\n\u0027DBCCERROR\u0027 in the name and a Backup file with \u0027DBCCError\u0027 in the name.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaDbCertificate", "Description": "Deletes specified database certificate", "Tags": "Certificate", "Syntax": "\r\nRemove-DbaDbCertificate [-SqlCredential \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDbCertificate -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject[]\u003e \r\n-Certificate \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDbCertificate [-SqlCredential \u003cPSCredential\u003e] [-InputObject \u003cCertificate[]\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Deletes specified database certificate", "Name": "Remove-DbaDbCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbCertificate -SqlInstance Server1\r\n\r\nThe certificate in the master database on server1 will be removed if it exists.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbCertificate -SqlInstance Server1 -Database db1 -Confirm:$false\r\n\r\nSuppresses all prompts to remove the certificate in the \u0027db1\u0027 database and drops the key.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaDbMasterKey", "Description": "Deletes specified database master key.", "Tags": "Certificate", "Syntax": "\r\nRemove-DbaDbMasterKey [-SqlCredential \u003cPSCredential\u003e] [-Mode {Strict | Lazy | Report}] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDbMasterKey -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-ExcludeDatabase \r\n\u003cObject[]\u003e] -All [-Mode {Strict | Lazy | Report}] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDbMasterKey -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Database \u003cObject[]\u003e [-Mode \r\n{Strict | Lazy | Report}] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDbMasterKey [-SqlCredential \u003cPSCredential\u003e] [-MasterKeyCollection \u003cMasterKey[]\u003e] [-Mode {Strict | Lazy | \r\nReport}] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Deletes specified database master key", "Name": "Remove-DbaDbMasterKey", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbMasterKey -SqlInstance Server1\r\n\r\nThe master key in the master database on server1 will be removed if it exists.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbMasterKey -SqlInstance Server1 -Database db1 -Confirm:$false\r\n\r\nSuppresses all prompts to remove the master key in the \u0027db1\u0027 database and drops the key.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaDbSnapshot", "Description": "Removes (drops) database snapshots from the server", "Tags": [ "Snapshot", "Database" ], "Syntax": "\r\nRemove-DbaDbSnapshot [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [[-Snapshot] \u003cString[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-AllSnapshots] \r\n[-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Removes database snapshots", "Name": "Remove-DbaDbSnapshot", "Links": "https://dbatools.io/Remove-DbaDbSnapshot", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, HR_snap_20161101\r\n\r\nRemoves database snapshots named HR_snap_20161201 and HR_snap_20161101\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting\r\n\r\nRemoves all database snapshots having HR and Accounting as base dbs\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting | Remove-DbaDbSnapshot\r\n\r\nRemoves all database snapshots having HR and Accounting as base dbs\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snapshot, Accounting_snapshot\r\n\r\nRemoves HR_snapshot and Accounting_snapshot\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 | Where SnapshotOf -like \u0027*dumpsterfire*\u0027 | Remove-DbaDbSnapshot\r\n\r\nRemoves all snapshots associated with databases that have dumpsterfire in the name\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -Passthru | Remove-DbaDbSnapshot\r\n\r\nAllows the selection of snapshots on sql2016 to remove\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots\r\n\r\nRemoves all database snapshots from sql2014\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbSnapshot -SqlInstance sql2014 -AllSnapshots -Confirm\r\n\r\nRemoves all database snapshots from sql2014 and prompts for each database\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRemove-DbaDbUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] -User \u003cObject[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaDbUser -InputObject \u003cUser[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Doug Meyers (@dgmyrs)", "Synopsis": "Drop database user", "Name": "Remove-DbaDbUser", "Links": "https://dbatools.io/Remove-DbaDbUser", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbUser -SqlInstance sqlserver2014 -User user1\r\n\r\nDrops user1 from all databases it exists in on server \u0027sqlserver2014\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbUser -SqlInstance sqlserver2014 -Database database1 -User user1\r\n\r\nDrops user1 from the database1 database on server \u0027sqlserver2014\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaDbUser -SqlInstance sqlserver2014 -ExcludeDatabase model -User user1\r\n\r\nDrops user1 from all databases it exists in on server \u0027sqlserver2014\u0027 except for the model database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbUser sqlserver2014 | Where-Object Name -In \"user1\" | Remove-DbaDbUser\r\n\r\nDrops user1 from all databases it exists in on server \u0027sqlserver2014\u0027.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaLogin", "Description": "Tries a bunch of different ways to remove a Login or two or more.", "Tags": [ "Delete", "Login" ], "Syntax": "\r\nRemove-DbaLogin [-SqlCredential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaLogin -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Login \u003cString[]\u003e [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaLogin [-SqlCredential \u003cPSCredential\u003e] -InputObject \u003cLogin[]\u003e [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Drops a Login", "Name": "Remove-DbaLogin", "Links": "https://dbatools.io/Remove-DbaLogin", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaLogin -SqlInstance sql2016 -Login mylogin\r\n\r\nPrompts then removes the Login mylogin on SQL Server sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaLogin -SqlInstance sql2016 -Login mylogin, yourlogin\r\n\r\nPrompts then removes the Logins mylogin and yourlogin on SQL Server sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaLogin -SqlInstance sql2016 -Login mylogin -Confirm:$false\r\n\r\nDoes not prompt and swiftly removes mylogin on SQL Server sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance server\\instance -Login yourlogin | Remove-DbaLogin\r\n\r\nremoves mylogin on SQL Server server\\instance\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaNetworkCertificate", "Description": "Removes the network certificate for SQL Server instance. This setting is found in Configuration Manager.", "Tags": "Certificate", "Syntax": "\r\nRemove-DbaNetworkCertificate [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes the network certificate for SQL Server instance", "Name": "Remove-DbaNetworkCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaNetworkCertificate\r\n\r\nRemoves the Network Certificate for the default instance (MSSQLSERVER) on localhost\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaNetworkCertificate -SqlInstance sql1\\SQL2008R2SP2\r\n\r\nRemoves the Network Certificate for the SQL2008R2SP2 instance on sql1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaNetworkCertificate -SqlInstance localhost\\SQL2008R2SP2 -WhatIf\r\n\r\nShows what would happen if the command were run\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRemove-DbaOrphanUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-User] \u003cObject[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Drop orphan users with no existing login to map", "Name": "Remove-DbaOrphanUser", "Links": "https://dbatools.io/Remove-DbaOrphanUser", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sql2005\r\n\r\nFinds and drops all orphan users without matching Logins in all databases present on server \u0027sql2005\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -SqlCredential $cred\r\n\r\nFinds and drops all orphan users without matching Logins in all databases present on server \u0027sqlserver2014a\u0027. SQL \r\nServer authentication will be used in connecting to the server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -Database db1, db2 -Force\r\n\r\nFinds and drops orphan users even if they have a matching Login on both db1 and db2 databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -ExcludeDatabase db1, db2 -Force\r\n\r\nFinds and drops orphan users even if they have a matching Login from all databases except db1 and db2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -User OrphanUser\r\n\r\nRemoves user OrphanUser from all databases only if there is no matching login.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaOrphanUser -SqlInstance sqlserver2014a -User OrphanUser -Force\r\n\r\nRemoves user OrphanUser from all databases even if they have a matching Login. Any schema that the user owns will \r\nchange ownership to dbo.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaPfDataCollectorCounter", "Description": "Removes a Performance Data Collector Counter.", "Tags": "PerfMon", "Syntax": "\r\nRemove-DbaPfDataCollectorCounter [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[[-CollectorSet] \u003cString[]\u003e] [[-Collector] \u003cString[]\u003e] [-Counter] \u003cObject[]\u003e [[-InputObject] \u003cObject[]\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes a Performance Data Collector Counter.", "Name": "Remove-DbaPfDataCollectorCounter", "Links": "https://dbatools.io/Remove-DbaPfDataCollectorCounter", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaPfDataCollectorCounter -ComputerName sql2017 -CollectorSet \u0027System Correlation\u0027 -Collector \r\nDataCollector01 -Counter \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027\r\n\r\nPrompts for confirmation then removes the \u0027\\LogicalDisk(*)\\Avg. Disk Queue Length\u0027 counter within the DataCollector01 \r\ncollector within the System Correlation collector set on sql2017.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorCounter | Out-GridView -PassThru | Remove-DbaPfDataCollectorCounter -Confirm:$false\r\n\r\nAllows you to select which counters you\u0027d like on localhost and does not prompt for confirmation.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nRemove-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \r\n\u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes a Performance Monitor Data Collector Set", "Name": "Remove-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Remove-DbaPfDataCollectorSet", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaPfDataCollectorSet\r\n\r\nPrompts for confirmation then removes all ready Collectors on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaPfDataCollectorSet -ComputerName sql2017 -Confirm:$false\r\n\r\nAttempts to remove all ready Collectors on localhost and does not prompt to confirm.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaPfDataCollectorSet -ComputerName sql2017, sql2016 -Credential (Get-Credential) -CollectorSet \u0027System \r\nCorrelation\u0027\r\n\r\nPrompts for confirmation then removes the \u0027System Correlation\u0027 Collector on sql2017 and sql2016 using alternative \r\ncredentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Remove-DbaPfDataCollectorSet\r\n\r\nRemoves the \u0027System Correlation\u0027 Collector.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Stop-DbaPfDataCollectorSet | \r\nRemove-DbaPfDataCollectorSet\r\n\r\nStops and removes the \u0027System Correlation\u0027 Collector.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaRegisteredServer", "Description": "Removes registered servers found in SQL Server Central Management Server (CMS).", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nRemove-DbaRegisteredServer [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \r\n\u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-Group] \u003cString[]\u003e] [[-InputObject] \u003cRegisteredServer[]\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes registered servers found in SQL Server Central Management Server (CMS).", "Name": "Remove-DbaRegisteredServer", "Links": "https://dbatools.io/Remove-DbaRegisteredServer", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaRegisteredServer -SqlInstance sql2012 -Group HR, Accounting\r\n\r\nRemoves all servers from the HR and Accounting groups on sql2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaRegisteredServer -SqlInstance sql2012 -Group HR\\Development\r\n\r\nRemoves all servers from the HR and sub-group Development from the CMS on sql2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaRegisteredServer -SqlInstance sql2012 -Confirm:$false\r\n\r\nRemoves all registered servers on sql2012 and turns off all prompting\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaRegisteredServerGroup", "Description": "Returns an array of Server Groups found in the CMS.", "Tags": [ "RegisteredServer", "CMS" ], "Syntax": "\r\nRemove-DbaRegisteredServerGroup [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Name] \r\n\u003cString[]\u003e] [[-InputObject] \u003cServerGroup[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Gets list of Server Groups objects stored in SQL Server Central Management Server (CMS).", "Name": "Remove-DbaRegisteredServerGroup", "Links": "https://dbatools.io/Remove-DbaRegisteredServerGroup", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaRegisteredServerGroup -SqlInstance sql2012 -Group HR, Accounting\r\n\r\nRemoves the HR and Accounting groups on sql2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaRegisteredServerGroup -SqlInstance sql2012 -Group HR\\Development -Confirm:$false\r\n\r\nRemoves the Development subgroup within the HR group on sql2012 and turns off all prompting\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.\n\nNote: This function supports -WhatIf", "Tags": "SPN", "Syntax": "\r\nRemove-DbaSpn [-SPN] \u003cString\u003e [-ServiceAccount] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account\r\n\r\nConnects to Active Directory and removes a provided SPN from the given account (and also the relative delegation)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -EnableException\r\n\r\nConnects to Active Directory and removes a provided SPN from the given account, suppressing all error messages and \r\nthrow exceptions that can be caught instead\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -Credential \r\n(Get-Credential)\r\n\r\nConnects to Active Directory and removes a provided SPN to the given account. Uses alternative account to connect to AD.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2005 | Where { $_.isSet -eq $true } | Remove-DbaSpn -WhatIf\r\n\r\nShows what would happen trying to remove all set SPNs for sql2005 and the relative delegations\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2005 | Where { $_.isSet -eq $true } | Remove-DbaSpn\r\n\r\nRemoves all set SPNs for sql2005 and the relative delegations\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaTrace", "Description": "Stops and closes the specified trace and deletes its definition from the server.", "Tags": [ "Security", "Trace" ], "Syntax": "\r\nRemove-DbaTrace [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Id] \u003cInt32[]\u003e] \r\n[[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaTrace -SqlInstance sql2008\r\n\r\nStops and removes all traces on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaTrace -SqlInstance sql2008 -Id 1\r\n\r\nStops and removes all trace with ID 1 on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2008 | Out-GridView -PassThru | Remove-DbaTrace\r\n\r\nStops and removes selected traces on sql2008\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaXESession", "Description": "This script removes Extended Events sessions on a SQL Server instance.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nRemove-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Session \u003cObject[]\u003e \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -AllSessions \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRemove-DbaXESession -InputObject \u003cSession[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes Extended Events sessions.", "Name": "Remove-DbaXESession", "Links": "https://dbatools.io/Remove-DbaXESession", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaXESession -SqlInstance sql2012 -AllSessions\r\n\r\nRemoves all Extended Event Session on the sqlserver2014 instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRemove-DbaXESession -SqlInstance sql2012 -Session xesession1,xesession2\r\n\r\nRemoves the xesession1 and xesession2 Extended Event sessions.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 | Remove-DbaXESession -Confirm:$false\r\n\r\nRemoves all sessions from sql2017, bypassing prompts.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2012 -Session xesession1 | Remove-DbaXESession\r\n\r\nRemoves the sessions returned from the Get-DbaXESession function.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Remove-DbaXESmartTarget", "Description": "Removes an XESmartTarget PowerShell Job.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nRemove-DbaXESmartTarget [-InputObject] \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Removes an XESmartTarget PowerShell Job.", "Name": "Remove-DbaXESmartTarget", "Links": "https://dbatools.io/Remove-DbaXESmartTarget\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESmartTarget | Remove-DbaXESmartTarget\r\n\r\nRemoves all XESmartTarget jobs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESmartTarget | Where-Object Id -eq 2 | Remove-DbaXESmartTarget\r\n\r\nRemoves a specific XESmartTarget job.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRename-DbaDatabase -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-DatabaseName \u003cString\u003e] [-FileGroupName \u003cString\u003e] [-LogicalName \r\n\u003cString\u003e] [-FileName \u003cString\u003e] [-ReplaceBefore] [-Force] [-Move] [-SetOffline] [-Preview] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRename-DbaDatabase [-SqlCredential \u003cPSCredential\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-DatabaseName \r\n\u003cString\u003e] [-FileGroupName \u003cString\u003e] [-LogicalName \u003cString\u003e] [-FileName \u003cString\u003e] [-ReplaceBefore] [-Force] [-Move] \r\n[-SetOffline] [-Preview] -InputObject \u003cDatabase[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName HR2 | select *\r\n\r\nShows the detailed resultset you\u0027ll get renaming the HR database to HR2 without doing anything\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName HR2\r\n\r\nRenames the HR database to HR2\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sqlserver2014a -Database HR | Rename-DbaDatabase -DatabaseName HR2\r\n\r\nSame as before, but with a piped database (renames the HR database to HR2)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\"\r\n\r\nRenames the HR database to dbatools_HR\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e_\u003cDATE\u003e\"\r\n\r\nRenames the HR database to dbatools_HR_20170807 (if today is 07th Aug 2017)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -FileGroupName \"dbatools_\u003cFGN\u003e\"\r\n\r\nRenames every FileGroup within HR to \"dbatools_[the original FileGroup name]\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileGroupName \"\u003cDBN\u003e_\u003cFGN\u003e\"\r\n\r\nRenames the HR database to \"dbatools_HR\", then renames every FileGroup within to \"dbatools_HR_[the original FileGroup \r\nname]\"\r\nNote the \"default recursive behaviour\" here: for all intents and purposes the result of the former can be obtained with \r\ntwo distinct calls:\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -FileGroupName \"dbatools_\u003cDBN\u003e_\u003cFGN\u003e\"\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileName \"\u003cDBN\u003e_\u003cFGN\u003e_\u003cFNN\u003e\"\r\n\r\nRenames the HR database to \"dbatools_HR\" and then all filenames as \"dbatools_HR_[Name of the \r\nFileGroup]_[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 \r\nonline again to finish the rename process\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileName \r\n\"\u003cDBN\u003e_\u003cFGN\u003e_\u003cFNN\u003e\" -SetOffline\r\n\r\nRenames the HR database to \"dbatools_HR\" and then all filenames as \"dbatools_HR_[Name of the \r\nFileGroup]_[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 \r\nonline again to finish the rename process\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nRename-DbaDatabase -SqlInstance sqlserver2014a -Database HR -DatabaseName \"dbatools_\u003cDBN\u003e\" -FileName \r\n\"\u003cDBN\u003e_\u003cFGN\u003e_\u003cFNN\u003e\" -Move\r\n\r\nRenames the HR database to \"dbatools_HR\" and then all filenames as \"dbatools_HR_[Name of the \r\nFileGroup]_[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 \r\nfinish the rename process\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nRename-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Login] \u003cString\u003e [-NewLogin] \r\n\u003cString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRename-DbaLogin -SqlInstance localhost -Login DbaToolsUser -NewLogin captain\r\n\r\nSQL Login Example\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRename-DbaLogin -SqlInstance localhost -Login domain\\oldname -NewLogin domain\\newname\r\n\r\nChange the windowsuser login name.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRename-DbaLogin -SqlInstance localhost -Login dbatoolsuser -NewLogin captain -WhatIf\r\n\r\nWhatIf Example\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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:\n Enabled\n Not a system object\n Not locked\n Have the same name that user\n\nYou can drop users that does not have their matching login by specifying the parameter -RemoveNotExisting.", "Tags": "Orphan", "Syntax": "\r\nRepair-DbaOrphanUser [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-Users] \u003cObject[]\u003e] [-RemoveNotExisting] [-Force] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Finds orphan users with existing login and remaps them.", "Name": "Repair-DbaOrphanUser", "Links": "https://dbatools.io/Repair-DbaOrphanUser", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sql2005\r\n\r\nFinds and repairs all orphan users of all databases present on server \u0027sql2005\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -SqlCredential $cred\r\n\r\nFinds and repair all orphan users in all databases present on server \u0027sqlserver2014a\u0027. SQL credentials are used to \r\nauthenticate to the server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -Database db1, db2\r\n\r\nFinds and repairs all orphan users in both db1 and db2 databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -Database db1 -Users OrphanUser\r\n\r\nFinds and repairs user \u0027OrphanUser\u0027 in \u0027db1\u0027 database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -Users OrphanUser\r\n\r\nFinds and repairs user \u0027OrphanUser\u0027 on all databases\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaOrphanUser -SqlInstance sqlserver2014a -RemoveNotExisting\r\n\r\nFinds all orphan users of all databases present on server \u0027sqlserver2014a\u0027. Removes all users that do not have \r\nmatching Logins.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nRepair-DbaServerName [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-AutoFix] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaServerName -SqlInstance sql2014\r\n\r\nChecks to see if the server name is updatable and changes the name with a number of prompts.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaServerName -SqlInstance sql2014 -AutoFix\r\n\r\nChecks to see if the server name is updatable and automatically performs the change. Replication or mirroring will be \r\nbroken if necessary.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRepair-DbaServerName -SqlInstance sql2014 -AutoFix -Force\r\n\r\nChecks to see if the server name is updatable and automatically performs the change, bypassing most prompts and \r\nconfirmations. Replication or mirroring will be broken if necessary.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nReset-DbaAdmin [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-Login] \u003cString\u003e] [[-SecurePassword] \u003cSecureString\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eReset-DbaAdmin -SqlInstance sqlcluster\r\n\r\nPrompts for password, then resets the \"sa\" account password on sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eReset-DbaAdmin -SqlInstance sqlserver\\sqlexpress -Login ad\\administrator\r\n\r\nPrompts user to confirm that they understand the SQL Service will be restarted.\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eReset-DbaAdmin -SqlInstance sqlserver\\sqlexpress -Login sqladmin -Force\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.\n There 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,\n and it matches the \"DNSHostName\" property of the computer object stored in AD.\n This means that the notation of FQDN that matches \"ComputerName dot Domain\" is incorrect\n in those scenarios.\n In other words, the \"suffix\" of the FQDN CAN be different from the AD Domain.\n\n This cmdlet has been providing good results since its inception but for lack of useful\n names some doubts may arise.\n Let 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" ], "Syntax": "\r\nResolve-DbaNetworkName [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Turbo] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Klaas Vandenberghe ( @PowerDBAKlaas )", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eResolve-DbaNetworkName -ComputerName ServerA\r\n\r\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, \r\nFQDN, DNSHostEntry for ServerA\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eResolve-DbaNetworkName -SqlInstance sql2016\\sqlexpress\r\n\r\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, \r\nFQDN, DNSHostEntry for the SQL instance sql2016\\sqlexpress\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eResolve-DbaNetworkName -SqlInstance sql2016\\sqlexpress, sql2014\r\n\r\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, DNSDomain, Domain, DNSHostEntry, \r\nFQDN, DNSHostEntry for the SQL instance sql2016\\sqlexpress and sql2014\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2014 | Resolve-DbaNetworkName\r\n\r\nReturns a custom object displaying InputName, ComputerName, IPAddress, DNSHostName, Domain, FQDN for all SQL Servers \r\nreturned by Get-DbaRegisteredServer\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "SqlServer", "Instance", "Connect" ], "Syntax": "\r\nRestart-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-Timeout \r\n\u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRestart-DbaService [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-Timeout \u003cInt32\u003e] \r\n[-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Kirill Kravtsov( @nvarscar )", "Synopsis": "Restarts SQL Server services on a computer.", "Name": "Restart-DbaService", "Links": "https://dbatools.io/Restart-DbaService", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRestart-DbaService -ComputerName sqlserver2014a\r\n\r\nRestarts the SQL Server related services on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027| Get-DbaService | Restart-DbaService\r\n\r\nGets the SQL Server related services on computers sql1, sql2 and sql3 and restarts them.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eRestart-DbaService -ComputerName sql1,sql2 -Instance MSSQLSERVER\r\n\r\nRestarts the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eRestart-DbaService -ComputerName $MyServers -Type SSRS\r\n\r\nRestarts the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRestart-DbaService -ComputerName sql1 -Type Engine -Force\r\n\r\nRestarts SQL Server database engine services on sql1 forcing dependent SQL Server Agent services to restart as well.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Restore-DbaBackupFromDirectory", "Description": "Many SQL Server database administrators use Ola Hallengren\u0027s SQL Server Maintenance Solution which can be found at http://ola.hallengren.com\n\nHallengren uses a predictable backup structure which made it relatively easy to create a script that can restore an entire SQL Server database instance, down to the master database (next version), to a new server. This script is intended to be used in the event that the originating SQL Server becomes unavailable, thus rendering my other SQL restore script (http://goo.gl/QmfQ6s) ineffective.", "Tags": [ "DisasterRecovery", "Backup", "Restore" ], "Syntax": "\r\nRestore-DbaBackupFromDirectory [-SqlInstance] \u003cDbaInstanceParameter\u003e [-Path] \u003cString\u003e [-NoRecovery] \r\n[-ReuseSourceFolderStructure] [[-SqlCredential] \u003cPSCredential\u003e] [-Force] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Restores SQL Server databases from the backup directory structure created by Ola Hallengren\u0027s database maintenance scripts. Different structures coming soon.", "Name": "Restore-DbaBackupFromDirectory", "Links": "https://dbatools.io/Restore-SqlBackupFromDirectory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRestore-SqlBackupFromDirectory -SqlInstance sqlcluster -Path \\\\fileserver\\share\\sqlbackups\\SQLSERVER2014A\r\n\r\nAll user databases contained within \\\\fileserver\\share\\sqlbackups\\SQLSERVERA will be restored to sqlcluster, down the \r\nmost recent full/differential/logs.\r\n\r\n\r\nRequires -Version 3.0\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\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" ], "Syntax": "\r\nRestore-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] -Path \u003cObject[]\u003e [-DatabaseName \r\n\u003cObject[]\u003e] [-DestinationDataDirectory \u003cString\u003e] [-DestinationLogDirectory \u003cString\u003e] [-DestinationFileStreamDirectory \r\n\u003cString\u003e] [-RestoreTime \u003cDateTime\u003e] [-NoRecovery] [-WithReplace] [-XpDirTree] [-OutputScriptOnly] [-VerifyOnly] \r\n[-MaintenanceSolutionBackup] [-FileMapping \u003cHashtable\u003e] [-IgnoreLogBackup] [-useDestinationDefaultDirectories] \r\n[-ReuseSourceFolderStructure] [-DestinationFilePrefix \u003cString\u003e] [-RestoredDatabaseNamePrefix \u003cString\u003e] \r\n[-TrustDbBackupHistory] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \u003cInt32\u003e] [-DirectoryRecurse] \r\n[-EnableException] [-StandbyDirectory \u003cString\u003e] [-Continue] [-AzureCredential \u003cString\u003e] [-ReplaceDbNameInFile] \r\n[-DestinationFileSuffix \u003cString\u003e] [-KeepCDC] [-AllowContinue] [-GetBackupInformation \u003cString\u003e] \r\n[-StopAfterGetBackupInformation] [-SelectBackupInformation \u003cString\u003e] [-StopAfterSelectBackupInformation] \r\n[-FormatBackupInformation \u003cString\u003e] [-StopAfterFormatBackupInformation] [-TestBackupInformation \u003cString\u003e] \r\n[-StopAfterTestBackupInformation] [-StatementTimeout \u003cInt32\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRestore-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] -Path \u003cObject[]\u003e [-DatabaseName \r\n\u003cObject[]\u003e] [-OutputScriptOnly] [-TrustDbBackupHistory] [-MaxTransferSize \u003cInt32\u003e] [-BlockSize \u003cInt32\u003e] [-BufferCount \r\n\u003cInt32\u003e] [-EnableException] [-AzureCredential \u003cString\u003e] [-AllowContinue] [-GetBackupInformation \u003cString\u003e] \r\n[-StopAfterGetBackupInformation] [-SelectBackupInformation \u003cString\u003e] [-StopAfterSelectBackupInformation] \r\n[-FormatBackupInformation \u003cString\u003e] [-StopAfterFormatBackupInformation] [-TestBackupInformation \u003cString\u003e] \r\n[-StopAfterTestBackupInformation] -PageRestore \u003cObject\u003e -PageRestoreTailFolder \u003cString\u003e [-StatementTimeout \u003cInt32\u003e] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nRestore-DbaDatabase -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-DatabaseName \u003cObject[]\u003e] \r\n[-OutputScriptOnly] [-EnableException] [-AzureCredential \u003cString\u003e] [-Recover] [-AllowContinue] [-GetBackupInformation \r\n\u003cString\u003e] [-StopAfterGetBackupInformation] [-SelectBackupInformation \u003cString\u003e] [-StopAfterSelectBackupInformation] \r\n[-FormatBackupInformation \u003cString\u003e] [-StopAfterFormatBackupInformation] [-TestBackupInformation \u003cString\u003e] \r\n[-StopAfterTestBackupInformation] [-StatementTimeout \u003cInt32\u003e] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Restores a SQL Server Database from a set of backupfiles", "Name": "Restore-DbaDatabase", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups\r\n\r\nScans all the backup files in \\\\server2\\backups, filters them and restores the database to server1\\instance1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups -MaintenanceSolutionBackup \r\n-DestinationDataDirectory c:\\restores\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-ChildItem c:\\SQLbackups1\\, \\\\server\\sqlbackups2 | Restore-DbaDatabase -SqlInstance server1\\instance1\r\n\r\nTakes the provided files from multiple directories and restores them on server1\\instance1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$RestoreTime = Get-Date(\u002711:19 23/12/2016\u0027)\r\n\r\nRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups -MaintenanceSolutionBackup \r\n-DestinationDataDirectory c:\\restores -RestoreTime $RestoreTime\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \\\\server2\\backups -DestinationDataDirectory c:\\restores \r\n-OutputScriptOnly | Select-Object -ExpandProperty Tsql | Out-File -Filepath c:\\scripts\\restore.sql\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path c:\\backups -DestinationDataDirectory c:\\DataFiles \r\n-DestinationLogDirectory c:\\LogFile\r\n\r\nScans all the files in c:\\backups and then restores them onto the SQL Server Instance server1\\instance1, placing data \r\nfiles\r\nc:\\DataFiles and all the log files into c:\\LogFiles\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path http://demo.blob.core.windows.net/backups/dbbackup.bak \r\n-AzureCredential MyAzureCredential\r\n\r\nWill restore the backup held at http://demo.blob.core.windows.net/backups/dbbackup.bak to server1\\instance1. The \r\nconnection to Azure will be made using the\r\ncredential MyAzureCredential held on instance Server1\\instance1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003e$File = Get-ChildItem c:\\backups, \\\\server1\\backups -recurse\r\n\r\n$File | Restore-DbaDatabase -SqlInstance Server1\\Instance -useDestinationDefaultDirectories\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003e$files = Get-ChildItem C:\\dbatools\\db1\r\n\r\n#Restore database to a point in time\r\n$files | Restore-DbaDatabase -SqlInstance server\\instance1 `\r\n -DestinationFilePrefix prefix -DatabaseName Restored `\r\n -RestoreTime (get-date \"14:58:30 22/05/2017\") `\r\n -NoRecovery -WithReplace -StandbyDirectory C:\\dbatools\\standby\r\n\r\n#It\u0027s in standby so we can peek at it\r\nInvoke-Sqlcmd2 -ServerInstance server\\instance1 -Query \"select top 1 * from Restored.dbo.steps order by dt desc\"\r\n\r\n#Not quite there so let\u0027s roll on a bit:\r\n$files | Restore-DbaDatabase -SqlInstance server\\instance1 `\r\n -DestinationFilePrefix prefix -DatabaseName Restored `\r\n -continue -WithReplace -RestoreTime (get-date \"15:09:30 22/05/2017\") `\r\n -StandbyDirectory C:\\dbatools\\standby\r\n\r\nInvoke-Sqlcmd2 -ServerInstance server\\instance1 -Query \"select top 1 * from restored.dbo.steps order by dt desc\"\r\n\r\nRestore-DbaDatabase -SqlInstance server\\instance1 `\r\n -DestinationFilePrefix prefix -DatabaseName Restored `\r\n -continue -WithReplace\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server\\instance1 -Path c:\\backups -DatabaseName example1 -WithNoRecovery\r\n\r\nRestore-DbaDatabase -SqlInstance server\\instance1 -Recover -DatabaseName example1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 11 --------------------------\r\n\r\nPS C:\\\u003e$SuspectPage = Get-DbaSuspectPage -SqlInstance server\\instance1 -Database ProdFinance\r\n\r\nGet-DbaBackupHistory - SqlInstance server\\instance1 -Database -ProdFinance -Last | Restore-DbaDatabase -PageRestore \r\n$SuspectPage -PageRestoreTailFolder c:\\temp -TrustDbBackupHistory -AllowContinues\r\n\r\nGets a list of Suspect Pages using Get-DbaSuspectPage. The uses Get-DbaBackupHistory and Restore-DbaDatabase to perform \r\na 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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 12 --------------------------\r\n\r\nPS C:\\\u003eDue to SQL Server 2000 not returning all the backup headers we cannot restore directly. As this is an issues \r\nwith the SQL engine all we can offer is the following workaround\r\n\r\nThis will use a SQL Server instance \u003e 2000 to read the headers, and then pass them in to Restore-DbaDatabase as a \r\nBacukupHistory object:\r\n\r\n$BackupHistory = Get-DbaBackupInformation -SqlInstance sql2005 -Path \\\\backups\\sql2000\\ProdDb\r\n$BackupHistory | Restore-DbaDatabse -SqlInstance sql2000 -TrustDbBackupHistory\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 13 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDatabase -SqlInstance server1\\instance1 -Path \"C:\\Temp\\devops_prod_full.bak\" -DatabaseName \r\n\"DevOps_DEV\" -ReplaceDbNameInFile\r\n\r\nRename-DbaDatabase -SqlInstance server1\\instance1 -Database \"DevOps_DEV\" -LogicalName \"\u003cDBN\u003e_\u003cFT\u003e\"\r\n\r\nThis will restore the database from the \"C:\\Temp\\devops_prod_full.bak\" file, with the new name \"DevOps_DEV\" and store \r\nthe different physical files with the new name. It will use the system default configured 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 \r\n\"DevOps_DEV_LOG\" for LDF\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Restore-DbaDbCertificate", "Description": "Imports certificates from.cer files using SMO.", "Tags": [ "Migration", "Certificate" ], "Syntax": "\r\nRestore-DbaDbCertificate [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cObject[]\u003e \r\n[[-Database] \u003cObject\u003e] [[-Password] \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Jess Pomfret (@jpomfret)", "Synopsis": "Imports certificates from .cer files using SMO.", "Name": "Restore-DbaDbCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDbCertificate -SqlInstance Server1 -Path \\\\Server1\\Certificates -password (ConvertTo-SecureString \r\n-force -AsPlainText GoodPass1234!!)\r\n\r\nImports all the certificates in the specified path.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nRestore-DbaDbSnapshot [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Snapshot] \u003cObject[]\u003e] [[-InputObject] \u003cDatabase[]\u003e] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Restores databases from snapshots", "Name": "Restore-DbaDbSnapshot", "Links": "https://dbatools.io/Restore-DbaDbSnapshot", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDbSnapshot -SqlInstance sql2014 -Database HR, Accounting\r\n\r\nRestores HR and Accounting databases using the latest snapshot available\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDbSnapshot -SqlInstance sql2014 -Database HR -Force\r\n\r\nRestores HR database from latest snapshot and kills any active connections in the database on sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 -Database HR | Restore-DbaDbSnapshot -Force\r\n\r\nRestores HR database from latest snapshot and kills any active connections in the database on sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbSnapshot -SqlInstance sql2016 | Out-GridView -Passthru | Restore-DbaDbSnapshot\r\n\r\nAllows the selection of snapshots on sql2016 to restore\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eRestore-DbaDbSnapshot -SqlInstance sql2014 -Snapshot HR_snap_20161201, Accounting_snap_20161101\r\n\r\nRestores databases from snapshots named HR_snap_20161201 and Accounting_snap_20161101\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSave-DbaDiagnosticQueryScript [[-Path] \u003cFileInfo\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "André 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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSave-DbaDiagnosticQueryScript -Path c:\\temp\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Select-DbaBackupInformation", "Description": "Select-DbaBackupInformation filters out a subset of backups from the dbatools backup history object with parameters supplied.", "Tags": [ "Backup", "Restore" ], "Syntax": "\r\nSelect-DbaBackupInformation [-BackupHistory] \u003cObject\u003e [[-RestoreTime] \u003cDateTime\u003e] [-IgnoreLogs] [-IgnoreDiffs] \r\n[[-DatabaseName] \u003cString[]\u003e] [[-ServerName] \u003cString[]\u003e] [[-ContinuePoints] \u003cObject\u003e] [[-LastRestoreType] \u003cObject\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\r\n\r\n$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1)\r\n\r\nReturns all backups needed to restore all the backups in \\\\server1\\backups$ to 1 hour ago\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\r\n\r\n$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -DatabaseName ProdFinance\r\n\r\nReturns all the backups needed to restore Database ProdFinance to an hour ago\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\r\n\r\n$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreLogs\r\n\r\nReturns all the backups in \\\\server1\\backups$ to restore to as close prior to 1 hour ago as can be managed with only \r\nfull and differential backups\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\\\server1\\backups$\r\n\r\n$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreDiffs\r\n\r\nReturns all the backups in \\\\server1\\backups$ to restore to 1 hour ago using only Full and Diff backups.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaAgentAlert", "Description": "Set-DbaAgentAlert updates an alert in the SQL Server Agent with parameters supplied.", "Tags": [ "Agent", "Alert" ], "Syntax": "\r\nSet-DbaAgentAlert [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Alert] \u003cObject[]\u003e] \r\n[[-NewName] \u003cString\u003e] [-Enabled] [-Disabled] [-Force] [[-InputObject] \u003cAlert[]\u003e] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1 -Alert \u0027Severity 025: Fatal Error\u0027 -Disabled\r\n\r\nChanges the alert to disabled.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1 -Alert \u0027Severity 025: Fatal Error\u0027, \u0027Error Number 825\u0027, \u0027Error Number 824\u0027 \r\n-Enabled\r\n\r\nChanges multiple alerts to enabled.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1, sql2, sql3 -Alert \u0027Severity 025: Fatal Error\u0027, \u0027Error Number 825\u0027, \u0027Error \r\nNumber 824\u0027 -Enabled\r\n\r\nChanges multiple alerts to enabled on multiple servers.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentAlert -SqlInstance sql1 -Alert \u0027Severity 025: Fatal Error\u0027 -Disabled -Whatif\r\n\r\nDoesn\u0027t Change the alert but shows what would happen.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaAgentJob", "Description": "Set-DbaAgentJob updates a job in the SQL Server Agent with parameters supplied.", "Tags": [ "Agent", "Job" ], "Syntax": "\r\nSet-DbaAgentJob [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] \r\n[[-Schedule] \u003cObject[]\u003e] [[-ScheduleId] \u003cInt32[]\u003e] [[-NewName] \u003cString\u003e] [-Enabled] [-Disabled] [[-Description] \r\n\u003cString\u003e] [[-StartStepId] \u003cInt32\u003e] [[-Category] \u003cString\u003e] [[-OwnerLogin] \u003cString\u003e] [[-EventLogLevel] \u003cObject\u003e] \r\n[[-EmailLevel] \u003cObject\u003e] [[-NetsendLevel] \u003cObject\u003e] [[-PageLevel] \u003cObject\u003e] [[-EmailOperator] \u003cString\u003e] \r\n[[-NetsendOperator] \u003cString\u003e] [[-PageOperator] \u003cString\u003e] [[-DeleteLevel] \u003cObject\u003e] [-Force] [[-InputObject] \u003cJob[]\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Set-DbaAgentJob updates a job.", "Name": "Set-DbaAgentJob", "Links": "https://dbatools.io/Set-DbaAgentJob", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob sql1 -Job Job1 -Disabled\r\n\r\nChanges the job to disabled\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob sql1 -Job Job1 -OwnerLogin user1\r\n\r\nChanges the owner of the job\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1 -EventLogLevel OnSuccess\r\n\r\nChanges the job and sets the notification to write to the Windows Application event log on success\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1 -EmailLevel OnFailure -EmailOperator dba\r\n\r\nChanges the job and sets the notification to send an e-mail to the e-mail operator\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1, Job2, Job3 -Enabled\r\n\r\nChanges multiple jobs to enabled\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job Job1, Job2, Job3 -Enabled\r\n\r\nChanges multiple jobs to enabled on multiple servers\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1 -Job Job1 -Description \u0027Just another job\u0027 -Whatif\r\n\r\nDoesn\u0027t Change the job but shows what would happen.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJob -SqlInstance sql1, sql2, sql3 -Job \u0027Job One\u0027 -Description \u0027Job One\u0027\r\n\r\nChanges a job with the name \"Job1\" on multiple servers to have another description\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003esql1, sql2, sql3 | Set-DbaAgentJob -Job Job1 -Description \u0027Job One\u0027\r\n\r\nChanges a job with the name \"Job1\" on multiple servers to have another description using pipe line\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaAgentJobCategory", "Description": "Set-DbaAgentJobCategory makes it possible to change a job category.", "Tags": [ "Agent", "Job", "JobCategory" ], "Syntax": "\r\nSet-DbaAgentJobCategory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Category] \r\n\u003cString[]\u003e] [[-NewName] \u003cString[]\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Set-DbaAgentJobCategory changes a job category.", "Name": "Set-DbaAgentJobCategory", "Links": "https://dbatools.io/Set-DbaAgentJobCategory", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaAgentJobCategory -SqlInstance sql1 -Category \u0027Category 1\u0027 -NewName \u0027Category 2\u0027\r\n\r\nChange the name of the category from \u0027Category 1\u0027 to \u0027Category 2\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobCategory -SqlInstance sql1, sql2 -Category Category1, Category2 -NewName cat1, cat2\r\n\r\nRename multiple jobs in one go on multiple servers.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaAgentJobOutputFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cObject[]\u003e] \r\n[-Step \u003cObject[]\u003e] -OutputFile \u003cString\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Rob Sewell (https://sqldbawithabeard.com)", "Synopsis": "Set the output file for a step within an Agent job.", "Name": "Set-DbaAgentJobOutputFile", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobOutputFile -SqlInstance SERVERNAME -JobName \u0027The Agent Job\u0027 -OutPutFile \r\nE:\\Logs\\AgentJobStepOutput.txt\r\n\r\nSets the Job step for The Agent job on SERVERNAME to E:\\Logs\\AgentJobStepOutput.txt\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaAgentJobStep", "Description": "Set-DbaAgentJobStep updates a job step in the SQL Server Agent with parameters supplied.", "Tags": [ "Agent", "Job", "JobStep" ], "Syntax": "\r\nSet-DbaAgentJobStep [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e \r\n[-StepName] \u003cString\u003e [[-NewName] \u003cString\u003e] [[-Subsystem] \u003cString\u003e] [[-Command] \u003cString\u003e] [[-CmdExecSuccessCode] \r\n\u003cInt32\u003e] [[-OnSuccessAction] \u003cString\u003e] [[-OnSuccessStepId] \u003cInt32\u003e] [[-OnFailAction] \u003cString\u003e] [[-OnFailStepId] \r\n\u003cInt32\u003e] [[-Database] \u003cString\u003e] [[-DatabaseUser] \u003cString\u003e] [[-RetryAttempts] \u003cInt32\u003e] [[-RetryInterval] \u003cInt32\u003e] \r\n[[-OutputFileName] \u003cString\u003e] [[-Flag] \u003cString[]\u003e] [[-ProxyName] \u003cString\u003e] [-EnableException] [-Force] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Set-DbaAgentJobStep updates a job step.", "Name": "Set-DbaAgentJobStep", "Links": "https://dbatools.io/Set-DbaAgentJobStep", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1 -NewName Step2\r\n\r\nChanges the name of the step in \"Job1\" with the name Step1 to Step2\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1 -Job Job1 -StepName Step1 -Database msdb\r\n\r\nChanges the database of the step in \"Job1\" with the name Step1 to msdb\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1 -Job Job1, Job2 -StepName Step1 -Database msdb\r\n\r\nChanges job steps in multiple jobs with the name Step1 to msdb\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1, Job2 -StepName Step1 -Database msdb\r\n\r\nChanges job steps in multiple jobs on multiple servers with the name Step1 to msdb\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentJobStep -SqlInstance sql1, sql2, sql3 -Job Job1 -StepName Step1 -Database msdb\r\n\r\nChanges the database of the step in \"Job1\" with the name Step1 to msdb for multiple servers\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003esql1, sql2, sql3 | Set-DbaAgentJobStep -Job Job1 -StepName Step1 -Database msdb\r\n\r\nChanges the database of the step in \"Job1\" with the name Step1 to msdb for multiple servers using pipeline\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaAgentSchedule [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Job] \u003cObject[]\u003e \r\n[-ScheduleName] \u003cString\u003e [[-NewName] \u003cString\u003e] [-Enabled] [-Disabled] [[-FrequencyType] \u003cObject\u003e] [[-FrequencyInterval] \r\n\u003cObject[]\u003e] [[-FrequencySubdayType] \u003cObject\u003e] [[-FrequencySubdayInterval] \u003cInt32\u003e] [[-FrequencyRelativeInterval] \r\n\u003cObject\u003e] [[-FrequencyRecurrenceFactor] \u003cInt32\u003e] [[-StartDate] \u003cString\u003e] [[-EndDate] \u003cString\u003e] [[-StartTime] \u003cString\u003e] \r\n[[-EndTime] \u003cString\u003e] [-EnableException] [-Force] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1 -Job Job1 -ScheduleName daily -Enabled\r\n\r\nChanges the schedule for Job1 with the name \u0027daily\u0027 to enabled\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1 -Job Job1 -ScheduleName daily -NewName weekly -FrequencyType Weekly \r\n-FrequencyInterval Monday, Wednesday, Friday\r\n\r\nChanges the schedule for Job1 with the name daily to have a new name weekly\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1 -Job Job1, Job2, Job3 -ScheduleName daily -StartTime \u0027230000\u0027\r\n\r\nChanges the start time of the schedule for Job1 to 11 PM for multiple jobs\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaAgentSchedule -SqlInstance sql1, sql2, sql3 -Job Job1 -ScheduleName daily -Enabled\r\n\r\nChanges the schedule for Job1 with the name daily to enabled on multiple servers\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003esql1, sql2, sql3 | Set-DbaAgentSchedule -Job Job1 -ScheduleName \u0027daily\u0027 -Enabled\r\n\r\nChanges the schedule for Job1 with the name \u0027daily\u0027 to enabled on multiple servers using pipe line\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-Credential \u003cPSCredential\u003e] \r\n[-OverrideExplicitCredential] [-OverrideConnectionPolicy] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | \r\nPowerShellRemoting}] [-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] \r\n[-EnableCredentialFailover] [-WindowsCredentialsAreBad] [-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \r\n\u003cDComSessionOptions\u003e] [-AddBadCredential \u003cPSCredential[]\u003e] [-RemoveBadCredential \u003cPSCredential[]\u003e] \r\n[-ClearBadCredential] [-ClearCredential] [-ResetCredential] [-ResetConnectionStatus] [-ResetConfiguration] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nSet-DbaCmConnection [-ComputerName \u003cDbaCmConnectionParameter[]\u003e] [-UseWindowsCredentials] [-OverrideExplicitCredential] \r\n[-OverrideConnectionPolicy] [-DisabledConnectionTypes {None | CimRM | CimDCOM | Wmi | PowerShellRemoting}] \r\n[-DisableBadCredentialCache] [-DisableCimPersistence] [-DisableCredentialAutoRegister] [-EnableCredentialFailover] \r\n[-CimWinRMOptions \u003cWSManSessionOptions\u003e] [-CimDCOMOptions \u003cDComSessionOptions\u003e] [-AddBadCredential \u003cPSCredential[]\u003e] \r\n[-RemoveBadCredential \u003cPSCredential[]\u003e] [-ClearBadCredential] [-ClearCredential] [-ResetCredential] \r\n[-ResetConnectionStatus] [-ResetConfiguration] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "Configures a connection object for use in remote computer management.", "Name": "Set-DbaCmConnection", "Links": "https://dbatools.io/set-DbaCmConnection", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection sql2014 | Set-DbaCmConnection -ClearBadCredential -UseWindowsCredentials\r\n\r\nRetrieves the already existing connection to sql2014, removes the list of not working credentials and configures it to \r\ndefault to the credentials of the logged on user.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection | Set-DbaCmConnection -RemoveBadCredential $cred\r\n\r\nRemoves the credentials stored in $cred from all connections\u0027 list of \"known to not work\" credentials.\r\nHandy to update changes in privilege.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaCmConnection | Export-Clixml .\\connections.xml\r\n\r\nImport-Clixml .\\connections.xml | Set-DbaCmConnection -ResetConfiguration\r\n\r\nAt first, the current cached connections are stored in an xml file. At a later time - possibly in the profile when \r\nstarting the console again - those connections are imported again and applied again to the connection cache.\r\n\r\nIn this example, the configuration settings will also be reset, since after reimport those will be set to explicit, \r\nrather 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 \r\nprofile in order to explicitly configure a connection.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaDbCompression [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-CompressionType] \u003cObject\u003e] [[-MaxRunTime] \u003cInt32\u003e] [[-PercentCompression] \u003cInt32\u003e] \r\n[[-InputObject] \u003cObject\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbCompression -SqlInstance localhost -MaxRunTime 60 -PercentCompression 25\r\n\r\nSet the compression run time to 60 minutes and will start the compression of tables/indexes that have a difference of \r\n25% or higher between current and recommended.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbCompression -SqlInstance ServerA -Database DBName -CompressionType Page\r\n\r\nUtilizes Page compression for all objects in DBName on ServerA with no time limit.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbCompression -SqlInstance ServerA -Database DBName -PercentCompression 25 | Out-GridView\r\n\r\nWill compress tables/indexes within the specified database that would show any % improvement with compression and with \r\nno time limit. The results will be piped into a nicely formatted GridView.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$testCompression = Test-DbaDbCompression -SqlInstance ServerA -Database DBName\r\n\r\nSet-DbaDbCompression -SqlInstance ServerA -Database DBName -InputObject $testCompression\r\n\r\nGets the compression suggestions from Test-DbaDbCompression into a variable, this can then be reviewed and passed into \r\nSet-DbaDbCompression.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nSet-DbaDbCompression -SqlInstance ServerA -ExcludeDatabase Database -SqlCredential $cred -MaxRunTime 60 \r\n-PercentCompression 25\r\n\r\nSet the compression run time to 60 minutes and will start the compression of tables/indexes for all databases except \r\nthe specified excluded database. Only objects that have a difference of 25% or higher between current and recommended \r\nwill be compressed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$servers = \u0027Server1\u0027,\u0027Server2\u0027\r\n\r\nforeach ($svr in $servers)\r\n{\r\n Set-DbaDbCompression -SqlInstance $svr -MaxRunTime 60 -PercentCompression 25 | Export-Csv -Path \r\nC:\\temp\\CompressionAnalysisPAC.csv -Append\r\n}\r\n\r\nSet the compression run time to 60 minutes and will start the compression of tables/indexes across all listed servers \r\nthat have a difference of 25% or higher between current and recommended. Output of command is exported to a csv.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaDbOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-TargetLogin] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbOwner -SqlInstance localhost\r\n\r\nSets database owner to \u0027sa\u0027 on all databases where the owner does not match \u0027sa\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbOwner -SqlInstance localhost -TargetLogin DOMAIN\\account\r\n\r\nSets the database owner to DOMAIN\\account on all databases where the owner does not match DOMAIN\\account.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbOwner -SqlInstance sqlserver -Database db1, db2\r\n\r\nSets database owner to \u0027sa\u0027 on the db1 and db2 databases if their current owner does not match \u0027sa\u0027.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaDbQueryStoreOption", "Description": "Configure Query Store settings for a specific or multiple databases.", "Tags": "QueryStore", "Syntax": "\r\nSet-DbaDbQueryStoreOption [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-AllDatabases] [[-State] \u003cString[]\u003e] [[-FlushInterval] \u003cInt64\u003e] \r\n[[-CollectionInterval] \u003cInt64\u003e] [[-MaxSize] \u003cInt64\u003e] [[-CaptureMode] \u003cString[]\u003e] [[-CleanupMode] \u003cString[]\u003e] \r\n[[-StaleQueryThreshold] \u003cInt64\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -State ReadWrite -FlushInterval 600 -CollectionInterval 10 \r\n-MaxSize 100 -CaptureMode All -CleanupMode Auto -StaleQueryThreshold 100 -AllDatabases\r\n\r\nConfigure the Query Store settings for all user databases in the ServerA\\SQL Instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -FlushInterval 600\r\n\r\nOnly configure the FlushInterval setting for all Query Store databases in the ServerA\\SQL Instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -Database AdventureWorks -State ReadWrite -FlushInterval 600 \r\n-CollectionInterval 10 -MaxSize 100 -CaptureMode all -CleanupMode Auto -StaleQueryThreshold 100\r\n\r\nConfigure the Query Store settings for the AdventureWorks database in the ServerA\\SQL Instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbQueryStoreOption -SqlInstance ServerA\\SQL -Exclude AdventureWorks -State ReadWrite -FlushInterval 600 \r\n-CollectionInterval 10 -MaxSize 100 -CaptureMode all -CleanupMode Auto -StaleQueryThreshold 100\r\n\r\nConfigure the Query Store settings for all user databases except the AdventureWorks database in the ServerA\\SQL \r\nInstance.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaDbRecoveryModel", "Description": "Set-DbaDbRecoveryModel sets the Recovery Model for user databases.", "Tags": [ "Recovery", "RecoveryModel", "Simple", "Full", "Bulk", "BulkLogged" ], "Syntax": "\r\nSet-DbaDbRecoveryModel [-SqlCredential \u003cPSCredential\u003e] -RecoveryModel \u003cString\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \r\n\u003cObject[]\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nSet-DbaDbRecoveryModel -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -RecoveryModel \u003cString\u003e \r\n[-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nSet-DbaDbRecoveryModel [-SqlCredential \u003cPSCredential\u003e] -RecoveryModel \u003cString\u003e [-Database \u003cObject[]\u003e] [-ExcludeDatabase \r\n\u003cObject[]\u003e] [-AllDatabases] [-EnableException] -InputObject \u003cDatabase[]\u003e [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Database model -Confirm:$true -Verbose\r\n\r\nSets the Recovery Model to BulkLogged for database [model] on SQL Server instance sql2014. User is requested to confirm \r\nthe action.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sql2014 -Database TestDB | Set-DbaDbRecoveryModel -RecoveryModel Simple \r\n-Confirm:$false\r\n\r\nSets the Recovery Model to Simple for database [TestDB] on SQL Server instance sql2014. Confirmation is not required.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel Simple -Database TestDB -Confirm:$false\r\n\r\nSets the Recovery Model to Simple for database [TestDB] on SQL Server instance sql2014. Confirmation is not required.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel Simple -AllDatabases -Confirm:$false\r\n\r\nSets the Recovery Model to Simple for ALL uses databases MODEL database on SQL Server instance sql2014. Runs without \r\nasking for confirmation.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Database TestDB1, TestDB2 -Confirm:$false \r\n-Verbose\r\n\r\nSets the Recovery Model to BulkLogged for [TestDB1] and [TestDB2] databases on SQL Server instance sql2014. Runs \r\nwithout asking for confirmation.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaDbState [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] \r\n[-ReadOnly] [-ReadWrite] [-Online] [-Offline] [-Emergency] [-Detached] [-SingleUser] [-RestrictedUser] [-MultiUser] \r\n[-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nSet-DbaDbState -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] [-ReadOnly] [-ReadWrite] [-Online] [-Offline] [-Emergency] [-Detached] \r\n[-SingleUser] [-RestrictedUser] [-MultiUser] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nSet-DbaDbState [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] [-ExcludeDatabase \u003cObject[]\u003e] [-AllDatabases] \r\n[-ReadOnly] [-ReadWrite] [-Online] [-Offline] [-Emergency] [-Detached] [-SingleUser] [-RestrictedUser] [-MultiUser] \r\n[-Force] [-EnableException] -InputObject \u003cPSObject[]\u003e [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Sets various options for databases, hereby called \"states\"", "Name": "Set-DbaDbState", "Links": "https://dbatools.io/Set-DbaDbState", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -Database HR -Offline\r\n\r\nSets the HR database as OFFLINE\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -AllDatabases -Exclude HR -Readonly -Force\r\n\r\nSets all databases of the sqlserver2014a instance, except for HR, as READ_ONLY\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDbState -SqlInstance sql2016 | Where-Object Status -eq \u0027Offline\u0027 | Set-DbaDbState -Online\r\n\r\nFinds all offline databases and sets them to online\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -Database HR -SingleUser\r\n\r\nSets the HR database as SINGLE_USER\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaDbState -SqlInstance sqlserver2014a -Database HR -SingleUser -Force\r\n\r\nSets the HR database as SINGLE_USER, dropping all other connections (and rolling back open transactions)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaDatabase -SqlInstance sqlserver2014a -Database HR | Set-DbaDbState -SingleUser -Force\r\n\r\nGets the databases from Get-DbaDatabase, and sets them as SINGLE_USER, dropping all other connections (and rolling back \r\nopen transactions)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaErrorLogConfig [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-LogCount] \u003cInt32\u003e] \r\n[[-LogSize] \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Shawn Melton (@wsmelton)", "Synopsis": "Set the configuration for the ErrorLog on a given SQL Server instance", "Name": "Set-DbaErrorLogConfig", "Links": "https://dbatools.io/Set-DbaErrorLogConfig", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaErrorLogConfig -SqlInstance sql2017,sql2014 -LogCount 25\r\n\r\nSets the number of error log files to 25 on sql2017 and sql2014\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaErrorLogConfig -SqlInstance sql2014 -LogSize 102400\r\n\r\nSets the size of the error log file, before it rolls over, to 102400 KB (100 MB) on sql2014\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaErrorLogConfig -SqlInstance sql2012 -LogCount 25 -LogSize 500\r\n\r\nSets the number of error log files to 25 and size before it will roll over to 500 KB on sql2012\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaJobOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] \r\n[[-ExcludeJob] \u003cObject[]\u003e] [[-Login] \u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaJobOwner -SqlInstance localhost\r\n\r\nSets SQL Agent Job owner to sa on all jobs where the owner does not match sa.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaJobOwner -SqlInstance localhost -Login DOMAIN\\account\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaJobOwner -SqlInstance localhost -Job job1, job2\r\n\r\nSets SQL Agent Job owner to \u0027sa\u0027 on the job1 and job2 jobs if their current owner does not match \u0027sa\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e\u0027sqlserver\u0027,\u0027sql2016\u0027 | Set-DbaJobOwner\r\n\r\nSets SQL Agent Job owner to sa on all jobs where the owner does not match sa on both sqlserver and sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.\nIt\u0027s also possible to add or remove server roles from the login.", "Tags": "Login", "Syntax": "\r\nSet-DbaLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Login] \u003cString[]\u003e [[-Password] \r\n\u003cSecureString\u003e] [-Unlock] [-MustChange] [[-NewName] \u003cString\u003e] [-Disable] [-Enable] [-DenyLogin] [-GrantLogin] \r\n[-PasswordPolicyEnforced] [[-AddRole] \u003cString[]\u003e] [[-RemoveRole] \u003cString[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Set-DbaLogin makes it possible to make changes to one or more logins.", "Name": "Set-DbaLogin", "Links": "https://dbatools.io/Set-DbaLogin", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$password = ConvertTo-SecureString \"PlainTextPassword\" -AsPlainText -Force\r\n\r\n$cred = New-Object System.Management.Automation.PSCredential (\"username\", $password)\r\nSet-DbaLogin -SqlInstance sql1 -Login login1 -Password $cred -Unlock -MustChange\r\n\r\nSet the new password for login1 using a credential, unlock the account and set the option\r\nthat the usermust change password at next logon.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -Enable\r\n\r\nEnable the login\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1, login2, login3, login4 -Enable\r\n\r\nEnable multiple logins\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1, sql2, sql3 -Login login1, login2, login3, login4 -Enable\r\n\r\nEnable multiple logins on multiple instances\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -Disable\r\n\r\nDisable the login\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -DenyLogin\r\n\r\nDeny the login to connect to the instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -GrantLogin\r\n\r\nGrant the login to connect to the instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -PasswordPolicyEnforced\r\n\r\nEnforces the password policy on a login\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login login1 -PasswordPolicyEnforced:$false\r\n\r\nDisables enforcement of the password policy on a login\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login test -AddRole serveradmin\r\n\r\nAdd the server role \"serveradmin\" to the login\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 11 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaLogin -SqlInstance sql1 -Login test -RemoveRole bulkadmin\r\n\r\nRemove the server role \"bulkadmin\" to the login\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaMaxDop [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-MaxDop \u003cInt32\u003e] [-Collection \u003cObject\u003e] [-AllDatabases] [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2008, sql2012\r\n\r\nSets Max DOP to the recommended value for servers sql2008 and sql2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2014 -MaxDop 4\r\n\r\nSets Max DOP to 4 for server sql2014.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sql2008 | Set-DbaMaxDop\r\n\r\nGets the recommended Max DOP from Test-DbaMaxDop and applies it to to sql2008.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2016 -Database db1\r\n\r\nSet recommended Max DOP for database db1 on server sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaMaxDop -SqlInstance sql2016 -AllDatabases\r\n\r\nSet recommended Max DOP for all databases on server sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaMaxMemory [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [-SqlCredential \u003cPSCredential\u003e] [[-MaxMB] \u003cInt32\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaMaxMemory sqlserver1\r\n\r\nSet max memory to the recommended MB on just one server named \"sqlserver1\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaMaxMemory -SqlInstance sqlserver1 -MaxMB 2048\r\n\r\nExplicitly max memory to 2048 MB on just one server, \"sqlserver1\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver | Test-DbaMaxMemory | Where-Object { $_.SqlMaxMB -gt $_.TotalMB } \r\n| Set-DbaMaxMemory\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nSet-DbaNetworkCertificate [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nSet-DbaNetworkCertificate [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] -Certificate \r\n\u003cX509Certificate2\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nSet-DbaNetworkCertificate [-SqlInstance \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] -Thumbprint \u003cString\u003e \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Sets the network certificate for SQL Server instance", "Name": "Set-DbaNetworkCertificate", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eNew-DbaComputerCertificate | Set-DbaNetworkCertificate -SqlInstance localhost\\SQL2008R2SP2\r\n\r\nCreates and imports a new certificate signed by an Active Directory CA on localhost then sets the network certificate \r\nfor the SQL2008R2SP2 to that newly created certificate.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaNetworkCertificate -SqlInstance sql1\\SQL2008R2SP2 -Thumbprint 1223FB1ACBCA44D3EE9640F81B6BA14A92F3D6E2\r\n\r\nSets the network certificate for the SQL2008R2SP2 instance to the certificate with the thumbprint of \r\n1223FB1ACBCA44D3EE9640F81B6BA14A92F3D6E2 in LocalMachine\\My on sql1\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaPowerPlan [-ComputerName] \u003cObject[]\u003e [[-PowerPlan] \u003cString\u003e] [[-CustomPowerPlan] \u003cString\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaPowerPlan -ComputerName sqlserver2014a\r\n\r\nSets the Power Plan to High Performance. Skips it if its already set.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaPowerPlan -ComputerName sqlcluster -CustomPowerPlan \u0027Maximum Performance\u0027\r\n\r\nSets the Power Plan to the custom power plan called \"Maximum Performance\". Skips it if its already set.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nSet-DbaPrivilege [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-Type] \u003cString[]\u003e \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaPrivilege -ComputerName sqlserver2014a -Type LPIM,IFI\r\n\r\nAdds the SQL Service account(s) on computer sqlserver2014a to the local privileges \u0027SeManageVolumePrivilege\u0027 and \r\n\u0027SeLockMemoryPrivilege\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027 | Set-DbaPrivilege -Type IFI\r\n\r\nAdds the SQL Service account(s) on computers sql1, sql2 and sql3 to the local privilege \u0027SeManageVolumePrivilege\u0027.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nSet-DbaSpConfigure [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Value] \u003cInt32\u003e] \r\n[[-Name] \u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaSpConfigure -SqlInstance localhost -Name ScanForStartupProcedures -Value 1\r\n\r\nAdjusts the Scan for startup stored procedures configuration value to 1 and notifies the user that this requires a SQL \r\nrestart to take effect\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaSpConfigure -SqlInstance sql2017, sql2014 -Name XPCmdShellEnabled, IsSqlClrEnabled | Set-DbaSpConfigure \r\n-Value $false\r\n\r\nSets the values for XPCmdShellEnabled and IsSqlClrEnabled on sql2017 and sql2014 to False\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaSpConfigure -SqlInstance localhost -Name XPCmdShellEnabled -Value 1\r\n\r\nAdjusts the xp_cmdshell configuration value to 1.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaSpConfigure -SqlInstance localhost -Name XPCmdShellEnabled -Value 1 -WhatIf\r\n\r\nReturns information on the action that would be performed. No actual change will be made.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\nis 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\naccess to Active Directory.\n\nNote: This function supports -WhatIf", "Tags": "SPN", "Syntax": "\r\nSet-DbaSpn [-SPN] \u003cString\u003e [-ServiceAccount] \u003cString\u003e [[-Credential] \u003cPSCredential\u003e] [-NoDelegation] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account\r\n\r\nConnects to Active Directory and adds a provided SPN to the given account.\r\n\r\nSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -EnableException\r\n\r\nConnects to Active Directory and adds a provided SPN to the given account, suppressing all error messages and throw \r\nexceptions that can be caught instead\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -Credential (Get-Credential)\r\n\r\nConnects to Active Directory and adds a provided SPN to the given account. Uses alternative account to connect to AD.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaSpn -SPN MSSQLSvc\\SQLSERVERA.domain.something -ServiceAccount domain\\account -NoDelegation\r\n\r\nConnects to Active Directory and adds a provided SPN to the given account, without the delegation.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2016 | Where { $_.isSet -eq $false } | Set-DbaSpn\r\n\r\nSets all missing SPNs for sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName sql2016 | Where { $_.isSet -eq $false } | Set-DbaSpn -WhatIf\r\n\r\nDisplays what would happen trying to set all missing SPNs for sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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": [ "Service", "Startup", "Parameter", "Configure" ], "Syntax": "\r\nSet-DbaStartupParameter [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [[-MasterData] \u003cString\u003e] [[-MasterLog] \u003cString\u003e] [[-ErrorLog] \u003cString\u003e] [[-TraceFlags] \u003cString[]\u003e] \r\n[-CommandPromptStart] [-MinimalStart] [[-MemoryToReserve] \u003cInt32\u003e] [-SingleUser] [[-SingleUserDetails] \u003cString\u003e] \r\n[-NoLoggingToWinEvents] [-StartAsNamedInstance] [-DisableMonitoring] [-IncreasedExtents] [-TraceFlagsOverride] \r\n[[-StartUpConfig] \u003cObject\u003e] [-Offline] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stuart Moore (@napalmgram), stuart-moore.com", "Synopsis": "Sets the Startup Parameters for a SQL Server instance", "Name": "Set-DbaStartupParameter", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser\r\n\r\nWill configure the SQL Instance server1\\instance1 to startup up in Single User mode at next startup\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents\r\n\r\nWill configure the SQL Instance sql2016 to IncreasedExtents = True (-E)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents:$false -WhatIf\r\n\r\nShows what would happen if you attempted to configure the SQL Instance sql2016 to IncreasedExtents = False (no -E)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -TraceFlags 8032,8048\r\n\r\nThis will append Trace Flags 8032 and 8048 to the startup parameters\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagsOverride\r\n\r\nThis will remove all trace flags and set SingleUser to false\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -TraceFlags 8032,8048 -TraceFlagsOverride\r\n\r\nThis will set Trace Flags 8032 and 8048 to the startup parameters, removing any existing Trace Flags\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagsOverride -Offline\r\n\r\nThis will remove all trace flags and set SingleUser to false from an offline instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline\r\n\r\nThis will attempt to change the ErrorLog path to c:\\sql\\. However, with the offline switch this will not happen. To \r\nforce it, use the -Force switch like so:\r\n\r\nSet-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline -Force\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003e$StartupConfig = Get-DbaStartupParameter -SqlInstance server1\\instance1\r\n\r\nSet-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -NoLoggingToWinEvents\r\n#Restart your SQL instance with the tool of choice\r\n#Do Some work\r\nSet-DbaStartupParameter -SqlInstance server1\\instance1 -StartUpConfig $StartUpConfig\r\n#Restart your SQL instance with the tool of choice and you\u0027re back to normal\r\n\r\nIn this example we take a copy of the existing startup configuration of server1\\instance1\r\n\r\nWe then change the startup parameters ahead of some work\r\n\r\nAfter the work has been completed, we can push the original startup parameters back to server1\\instance1 and resume \r\nnormal operation\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Set-DbaTcpPort", "Description": "This function changes the TCP port used by the specified SQL Server.", "Tags": [ "Service", "Port", "TCP", "Configure" ], "Syntax": "\r\nSet-DbaTcpPort [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \u003cPSCredential\u003e] \r\n[-Port] \u003cInt32\u003e [[-IpAddress] \u003cIPAddress[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Hansson7707@gmail.com, @H0s0n77", "Synopsis": "Changes the TCP port used by the specified SQL Server.", "Name": "Set-DbaTcpPort", "Links": "https://dbatools.io/Set-DbaTcpPort", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTcpPort -SqlInstance SqlInstance2014a -Port 1433\r\n\r\nSets the port number 1433 for all IP Addresses on the default instance on SqlInstance2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTcpPort -SqlInstance winserver\\sqlexpress -IpAddress 192.168.1.22 -Port 1433\r\n\r\nSets the port number 1433 for IP 192.168.1.22 on the sqlexpress instance on winserver\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTcpPort -SqlInstance \u0027SQLDB2014A\u0027 ,\u0027SQLDB2016B\u0027 -port 1337\r\n\r\nSets the port number 1337 for all IP Addresses on SqlInstance SQLDB2014A and SQLDB2016B\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbaTempdbConfig [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-DataFileCount] \u003cInt32\u003e] \r\n[-DataFileSizeMB] \u003cInt32\u003e [[-LogFileSizeMB] \u003cInt32\u003e] [[-DataFileGrowthMB] \u003cInt32\u003e] [[-LogFileGrowthMB] \u003cInt32\u003e] \r\n[[-DataPath] \u003cString\u003e] [[-LogPath] \u003cString\u003e] [[-OutFile] \u003cString\u003e] [-OutputScriptOnly] [-DisableGrowth] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000\r\n\r\nCreates tempdb with a number of data files equal to the logical cores where each file is equal to 1000MB divided by the \r\nnumber of logical cores, with a log file of 250MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -DataFileCount 8\r\n\r\nCreates tempdb with 8 data files, each one sized at 125MB, with a log file of 250MB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -OutputScriptOnly\r\n\r\nProvides a SQL script output to configure tempdb according to the passed parameters.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -DisableGrowth\r\n\r\nDisables the growth for the data and log files.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eSet-DbaTempdbConfig -SqlInstance localhost -DataFileSizeMB 1000 -OutputScriptOnly\r\n\r\nReturns the T-SQL script representing tempdb configuration.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSet-DbatoolsConfig [-FullName] \u003cString\u003e [[-Value] \u003cObject\u003e] [-Description \u003cString\u003e] [-Validation \u003cString\u003e] [-Handler \r\n\u003cScriptBlock\u003e] [-Hidden] [-Default] [-Initialize] [-DisableValidation] [-DisableHandler] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\nSet-DbatoolsConfig [-Name] \u003cString\u003e [[-Module] \u003cString\u003e] [[-Value] \u003cObject\u003e] [-Description \u003cString\u003e] [-Validation \r\n\u003cString\u003e] [-Handler \u003cScriptBlock\u003e] [-Hidden] [-Default] [-Initialize] [-DisableValidation] [-DisableHandler] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Friedrich Weinmann", "Synopsis": "Sets configuration entries.", "Name": "Set-DbatoolsConfig", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSet-DbatoolsConfig -Name \u0027User\u0027 -Value \"Friedrich\" -Description \"The user under which the show must go on.\"\r\n\r\nCreates a configuration entry named \"User\" with the value \"Friedrich\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSet-DbatoolsConfig -Name \u0027mymodule.User\u0027 -Value \"Friedrich\" -Description \"The user under which the show must go \r\non.\" -Handler $scriptBlock -Initialize -Validation String\r\n\r\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 \r\nignored.\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 \r\nplanning to add it.\r\nOnly then will the system validate previous settings (such as what a user might have placed in his user profile)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSet-DbatoolsConfig \u0027ConfigLink\u0027 \u0027https://www.example.com/config.xml\u0027 \u0027Company\u0027 -Hidden\r\n\r\nCreates a configuration entry named \"ConfigLink\" in the \"Company\" module with the value \r\n\u0027https://www.example.com/config.xml\u0027.\r\nThis entry is hidden from casual discovery using Get-Config.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eSet-DbatoolsConfig \u0027Network.Firewall\u0027 \u002710.0.0.2\u0027 -Default\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nShow-DbaDbList [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Title] \u003cString\u003e] [[-Header] \r\n\u003cString\u003e] [[-DefaultDb] \u003cString\u003e] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eShow-DbaDbList -SqlInstance sqlserver2014a\r\n\r\nShows a GUI list of databases using Windows Authentication to connect to the SQL Server. Returns a string of the \r\nselected database.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eShow-DbaDbList -Source sqlserver2014a -SqlCredential $cred\r\n\r\nShows a GUI list of databases using SQL credentials to connect to the SQL Server. Returns a string of the selected \r\ndatabase.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nShow-DbaServerFileSystem [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cObject\u003e] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eShow-DbaServerFileSystem -SqlInstance sqlserver2014a\r\n\r\nShows a list of databases using Windows Authentication to connect to the SQL Server. Returns a string of the selected \r\npath.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eShow-DbaServerFileSystem -Source sqlserver2014a -SqlCredential $cred\r\n\r\nShows a list of databases using SQL credentials to connect to the SQL Server. Returns a string of the selected path.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nStart-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] [-AllJobs] [-Wait] \r\n[-WaitPeriod \u003cInt32\u003e] [-SleepPeriod \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStart-DbaAgentJob -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \r\n\u003cString[]\u003e] [-AllJobs] [-Wait] [-WaitPeriod \u003cInt32\u003e] [-SleepPeriod \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nStart-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] -InputObject \u003cJob[]\u003e \r\n[-AllJobs] [-Wait] [-WaitPeriod \u003cInt32\u003e] [-SleepPeriod \u003cInt32\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Starts a running SQL Server Agent Job.", "Name": "Start-DbaAgentJob", "Links": "https://dbatools.io/Start-DbaAgentJob", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaAgentJob -SqlInstance localhost\r\n\r\nStarts all running SQL Agent Jobs on the local SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture | Start-DbaAgentJob\r\n\r\nStarts the cdc.DBWithCDC_capture SQL Agent Job on sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture\r\n\r\nStarts the cdc.DBWithCDC_capture SQL Agent Job on sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$servers | Find-DbaAgentJob -IsFailed | Start-DbaAgentJob\r\n\r\nRestarts all failed jobs on all servers in the $servers collection\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaAgentJob -SqlInstance sql2016 -AllJobs\r\n\r\nStart all the jobs\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 -NoDatabases to skip.\nAll logins. Use -NoLogins to skip.\nAll database mail objects. Use -NoDatabaseMail\nAll credentials. Use -NoCredentials to skip.\nAll objects within the Job Server (SQL Agent). Use -NoAgentServer to skip.\nAll linked servers. Use -NoLinkedServers to skip.\nAll groups and servers within Central Management Server. Use -NoCentralManagementServer to skip.\nAll SQL Server configuration objects (everything in sp_configure). Use -NoSpConfigure to skip.\nAll user objects in system databases. Use -NoSysDbUserObjects to skip.\nAll system triggers. Use -NoSystemTriggers to skip.\nAll system backup devices. Use -NoBackupDevices to skip.\nAll Audits. Use -NoAudits to skip.\nAll Endpoints. Use -NoEndpoints to skip.\nAll Extended Events. Use -NoExtendedEvents to skip.\nAll Policy Management objects. Use -NoPolicyManagement to skip.\nAll Resource Governor objects. Use -NoResourceGovernor to skip.\nAll Server Audit Specifications. Use -NoServerAuditSpecifications to skip.\nAll Custom Errors (User Defined Messages). Use -NoCustomErrors to skip.\nCopies All Data Collector collection sets. Does not configure the server. Use -NoDataCollector 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", "Syntax": "\r\nStart-DbaMigration [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [[-SourceSqlCredential] \r\n\u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-NoDatabases] [-NoLogins] [-NoAgentServer] \r\n[-NoCredentials] [-NoLinkedServers] [-NoSpConfigure] [-NoCentralManagementServer] [-NoDatabaseMail] \r\n[-NoSysDbUserObjects] [-NoSystemTriggers] [-NoBackupDevices] [-NoAudits] [-NoEndpoints] [-NoExtendedEvents] \r\n[-NoPolicyManagement] [-NoResourceGovernor] [-NoServerAuditSpecifications] [-NoCustomErrors] [-NoDataCollector] \r\n[-DisableJobsOnDestination] [-DisableJobsOnSource] [-NoSaRename] [-UseLastBackups] [-Continue] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStart-DbaMigration [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [-DetachAttach] \r\n[[-Reattach]] [[-SetSourceReadOnly]] [[-ReuseSourceFolderStructure]] [[-IncludeSupportDbs]] [[-SourceSqlCredential] \r\n\u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] [-NoDatabases] [-NoLogins] [-NoAgentServer] \r\n[-NoCredentials] [-NoLinkedServers] [-NoSpConfigure] [-NoCentralManagementServer] [-NoDatabaseMail] \r\n[-NoSysDbUserObjects] [-NoSystemTriggers] [-NoBackupDevices] [-NoAudits] [-NoEndpoints] [-NoExtendedEvents] \r\n[-NoPolicyManagement] [-NoResourceGovernor] [-NoServerAuditSpecifications] [-NoCustomErrors] [-NoDataCollector] \r\n[-DisableJobsOnDestination] [-DisableJobsOnSource] [-NoSaRename] [-UseLastBackups] [-Continue] [-Force] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStart-DbaMigration [-Source] \u003cDbaInstanceParameter\u003e [-Destination] \u003cDbaInstanceParameter[]\u003e [-BackupRestore] \r\n[[-NetworkShare] \u003cString\u003e] [[-WithReplace]] [[-NoRecovery]] [[-SetSourceReadOnly]] [[-ReuseSourceFolderStructure]] \r\n[[-IncludeSupportDbs]] [[-SourceSqlCredential] \u003cPSCredential\u003e] [[-DestinationSqlCredential] \u003cPSCredential\u003e] \r\n[-NoDatabases] [-NoLogins] [-NoAgentServer] [-NoCredentials] [-NoLinkedServers] [-NoSpConfigure] \r\n[-NoCentralManagementServer] [-NoDatabaseMail] [-NoSysDbUserObjects] [-NoSystemTriggers] [-NoBackupDevices] [-NoAudits] \r\n[-NoEndpoints] [-NoExtendedEvents] [-NoPolicyManagement] [-NoResourceGovernor] [-NoServerAuditSpecifications] \r\n[-NoCustomErrors] [-NoDataCollector] [-DisableJobsOnDestination] [-DisableJobsOnSource] [-NoSaRename] [-UseLastBackups] \r\n[-Continue] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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 one of the -No parameters and use the other functions available within the dbatools module.", "Name": "Start-DbaMigration", "Links": "https://dbatools.io/Start-DbaMigration", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaMigration -Source sqlserver\\instance -Destination sqlcluster -DetachAttach\r\n\r\nAll databases, logins, job objects and sp_configure options will be migrated from sqlserver\\instance to sqlcluster. \r\nDatabases will be migrated using the detach/copy files/attach method. Dbowner will be updated. User passwords, SIDs, \r\ndatabase roles and server roles will be migrated along with the login.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaMigration -Verbose -Source sqlcluster -Destination sql2016 -SourceSqlCredential $scred \r\n-ReuseSourceFolderStructure -DestinationSqlCredential $cred -Force -NetworkShare \r\n\\\\fileserver\\share\\sqlbackups\\Migration -BackupRestore\r\n\r\nMigrate databases uses backup/restore. Also migrate logins, database mail, credentials, SQL Agent, Central Management \r\nServer, SQL global configuration.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaMigration -Verbose -Source sqlcluster -Destination sql2016 -NoDatabases -NoLogins\r\n\r\nMigrates everything but logins and databases.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaMigration -Verbose -Source sqlcluster -Destination sql2016 -DetachAttach -Reattach -SetSourceReadonly\r\n\r\nMigrate databases using detach/copy/attach. Reattach at source and set source databases read-only. Also migrates \r\neverything else.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Start-DbaPfDataCollectorSet", "Description": "Starts Performance Monitor Data Collector Set.", "Tags": "PerfMon", "Syntax": "\r\nStart-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \r\n\u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-NoWait] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Starts Performance Monitor Data Collector Set.", "Name": "Start-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Start-DbaPfDataCollectorSet", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaPfDataCollectorSet\r\n\r\nAttempts to start all ready Collectors on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaPfDataCollectorSet -ComputerName sql2017\r\n\r\nAttempts to start all ready Collectors on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaPfDataCollectorSet -ComputerName sql2017, sql2016 -Credential (Get-Credential) -CollectorSet \u0027System \r\nCorrelation\u0027\r\n\r\nStarts the \u0027System Correlation\u0027 Collector on sql2017 and sql2016 using alternative credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Start-DbaPfDataCollectorSet\r\n\r\nStarts the \u0027System Correlation\u0027 Collector.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nStart-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-Timeout \r\n\u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStart-DbaService [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-Timeout \u003cInt32\u003e] [-Credential \r\n\u003cPSCredential\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Kirill Kravtsov( @nvarscar )", "Synopsis": "Starts SQL Server services on a computer.", "Name": "Start-DbaService", "Links": "https://dbatools.io/Start-DbaService", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaService -ComputerName sqlserver2014a\r\n\r\nStarts the SQL Server related services on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027| Get-DbaService | Start-DbaService\r\n\r\nGets the SQL Server related services on computers sql1, sql2 and sql3 and starts them.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaService -ComputerName sql1,sql2 -Instance MSSQLSERVER\r\n\r\nStarts the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaService -ComputerName $MyServers -Type SSRS\r\n\r\nStarts the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Start-DbaTrace", "Description": "Starts SQL Server traces", "Tags": [ "Security", "Trace" ], "Syntax": "\r\nStart-DbaTrace [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Id] \u003cInt32[]\u003e] \r\n[[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Starts SQL Server traces", "Name": "Start-DbaTrace", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaTrace -SqlInstance sql2008\r\n\r\nStarts all traces on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaTrace -SqlInstance sql2008 -Id 1\r\n\r\nStarts all trace with ID 1 on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2008 | Out-GridView -PassThru | Start-DbaTrace\r\n\r\nStarts selected traces on sql2008\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Start-DbaXESession", "Description": "This script starts Extended Events sessions on a SQL Server instance.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nStart-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Session \u003cObject[]\u003e [-StopAt \r\n\u003cDateTime\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nStart-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-StopAt \u003cDateTime\u003e] \r\n-AllSessions [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nStart-DbaXESession [-StopAt \u003cDateTime\u003e] -InputObject \u003cSession[]\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Doug Meyers", "Synopsis": "Starts Extended Events sessions.", "Name": "Start-DbaXESession", "Links": "https://dbatools.io/Start-DbaXESession", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaXESession -SqlInstance sqlserver2012 -AllSessions\r\n\r\nStarts all Extended Event Session on the sqlserver2014 instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaXESession -SqlInstance sqlserver2012 -Session xesession1,xesession2\r\n\r\nStarts the xesession1 and xesession2 Extended Event sessions.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStart-DbaXESession -SqlInstance sqlserver2012 -Session xesession1,xesession2 -StopAt (Get-Date).AddMinutes(30)\r\n\r\nStarts the xesession1 and xesession2 Extended Event sessions and stops them in 30 minutes.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sqlserver2012 -Session xesession1 | Start-DbaXESession\r\n\r\nStarts the sessions returned from the Get-DbaXESession function.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nStart-DbaXESmartTarget [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cString\u003e] \r\n[-Session] \u003cString\u003e [-FailOnProcessingError] [[-Responder] \u003cObject[]\u003e] [[-Template] \u003cString[]\u003e] [-NotAsJob] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "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\nhttps://github.com/spaghettidba/XESmartTarget/wiki", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query \"update table set whatever = 1\"\r\n\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\r\n\r\nExecutes a T-SQL command against dbadb on sql2017 whenever a deadlock event is recorded.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$response = New-DbaXESmartQueryExec -SqlInstance sql2017 -Database dbadb -Query \"update table set whatever = 1\"\r\n\r\n$params = @{\r\n SmtpServer = \"smtp.ad.local\"\r\n To = \"admin@ad.local\"\r\n Sender = \"reports@ad.local\"\r\n Subject = \"Query executed\"\r\n Body = \"Query executed at {collection_time}\"\r\n Attachment = \"batch_text\"\r\n AttachmentFileName = \"query.sql\"\r\n}\r\n$emailresponse = New-DbaXESmartEmail @params\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session querytracker -Responder $response, $emailresponse\r\n\r\nExecutes a T-SQL command against dbadb on sql2017 and sends an email whenever a querytracker event is recorded.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$columns = \"cpu_time\", \"duration\", \"physical_reads\", \"logical_reads\", \"writes\", \"row_count\", \"batch_text\"\r\n\r\n$response = New-DbaXESmartTableWriter -SqlInstance sql2017 -Database dbadb -Table deadlocktracker -OutputColumns \r\n$columns -Filter \"duration \u003e 10000\"\r\nStart-DbaXESmartTarget -SqlInstance sql2017 -Session deadlock_tracker -Responder $response\r\n\r\nWrites Extended Events to the deadlocktracker table in dbadb on sql2017.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nStop-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] [-Wait] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStop-DbaAgentJob -SqlInstance \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \r\n\u003cString[]\u003e] [-Wait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStop-DbaAgentJob [-SqlCredential \u003cPSCredential\u003e] [-Job \u003cString[]\u003e] [-ExcludeJob \u003cString[]\u003e] -InputObject \u003cJob[]\u003e \r\n[-Wait] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops a running SQL Server Agent Job.", "Name": "Stop-DbaAgentJob", "Links": "https://dbatools.io/Stop-DbaAgentJob", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaAgentJob -SqlInstance localhost\r\n\r\nStops all running SQL Agent Jobs on the local SQL Server instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture | Stop-DbaAgentJob\r\n\r\nStops the cdc.DBWithCDC_capture SQL Agent Job on sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaAgentJob -SqlInstance sql2016 -Job cdc.DBWithCDC_capture\r\n\r\nStops the cdc.DBWithCDC_capture SQL Agent Job on sql2016\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Stop-DbaPfDataCollectorSet", "Description": "Stops Performance Monitor Data Collector Set.", "Tags": "PerfMon", "Syntax": "\r\nStop-DbaPfDataCollectorSet [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CollectorSet] \r\n\u003cString[]\u003e] [[-InputObject] \u003cObject[]\u003e] [-NoWait] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops Performance Monitor Data Collector Set.", "Name": "Stop-DbaPfDataCollectorSet", "Links": "https://dbatools.io/Stop-DbaPfDataCollectorSet", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaPfDataCollectorSet\r\n\r\nAttempts to stop all ready Collectors on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaPfDataCollectorSet -ComputerName sql2017\r\n\r\nAttempts to stop all ready Collectors on localhost.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaPfDataCollectorSet -ComputerName sql2017, sql2016 -Credential (Get-Credential) -CollectorSet \u0027System \r\nCorrelation\u0027\r\n\r\nStops the \u0027System Correlation\u0027 Collector on sql2017 and sql2016 using alternative credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaPfDataCollectorSet -CollectorSet \u0027System Correlation\u0027 | Stop-DbaPfDataCollectorSet\r\n\r\nStops the \u0027System Correlation\u0027 Collector.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nStop-DbaProcess [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cInt32[]\u003e] [-ExcludeSpid \u003cInt32[]\u003e] [-Database \u003cString[]\u003e] \r\n[-Login \u003cString[]\u003e] [-Hostname \u003cString[]\u003e] [-Program \u003cString[]\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\nStop-DbaProcess -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cInt32[]\u003e] [-ExcludeSpid \r\n\u003cInt32[]\u003e] [-Database \u003cString[]\u003e] [-Login \u003cString[]\u003e] [-Hostname \u003cString[]\u003e] [-Program \u003cString[]\u003e] [-EnableException] \r\n[-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStop-DbaProcess [-SqlCredential \u003cPSCredential\u003e] [-Spid \u003cInt32[]\u003e] [-ExcludeSpid \u003cInt32[]\u003e] [-Database \u003cString[]\u003e] \r\n[-Login \u003cString[]\u003e] [-Hostname \u003cString[]\u003e] [-Program \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-EnableException] [-WhatIf] \r\n[-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -Login base\\ctrlb, sa\r\n\r\nFinds all processes for base\\ctrlb and sa on sqlserver2014a, then kills them. Uses Windows Authentication to login to \r\nsqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -SqlCredential $credential -Spids 56, 77\r\n\r\nFinds processes for spid 56 and 57, then kills them. Uses alternative (SQL or Windows) credentials to login to \r\nsqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -Programs \u0027Microsoft SQL Server Management Studio\u0027\r\n\r\nFinds processes that were created in Microsoft SQL Server Management Studio, then kills them.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014a -Hosts workstationx, server100\r\n\r\nFinds processes that were initiated by hosts (computers/clients) workstationx and server 1000, then kills them.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaProcess -SqlInstance sqlserver2014 -Database tempdb -WhatIf\r\n\r\nShows what would happen if the command were executed.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaProcess -SqlInstance sql2016 -Programs \u0027dbatools PowerShell module - dbatools.io\u0027 | Stop-DbaProcess\r\n\r\nFinds processes that were created with dbatools, then kills them.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "SqlServer", "Instance", "Connect" ], "Syntax": "\r\nStop-DbaService [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] [-Timeout \r\n\u003cInt32\u003e] [-Credential \u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nStop-DbaService [-InstanceName \u003cString[]\u003e] [-Type \u003cString[]\u003e] -InputObject \u003cObject[]\u003e [-Timeout \u003cInt32\u003e] [-Credential \r\n\u003cPSCredential\u003e] [-Force] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Kirill Kravtsov( @nvarscar )", "Synopsis": "Stops SQL Server services on a computer.", "Name": "Stop-DbaService", "Links": "https://dbatools.io/Stop-DbaService", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaService -ComputerName sqlserver2014a\r\n\r\nStops the SQL Server related services on computer sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e\u0027sql1\u0027,\u0027sql2\u0027,\u0027sql3\u0027| Get-DbaService | Stop-DbaService\r\n\r\nGets the SQL Server related services on computers sql1, sql2 and sql3 and stops them.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaService -ComputerName sql1,sql2 -Instance MSSQLSERVER\r\n\r\nStops the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaService -ComputerName $MyServers -Type SSRS\r\n\r\nStops the SQL Server related services of type \"SSRS\" (Reporting Services) on computers in the variable MyServers.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaService -ComputerName sql1 -Type Engine -Force\r\n\r\nStops SQL Server database engine services on sql1 forcing dependent SQL Server Agent services to stop as well.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Stop-DbaTrace", "Description": "Stops SQL Server traces", "Tags": [ "Security", "Trace" ], "Syntax": "\r\nStop-DbaTrace [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Id] \u003cInt32[]\u003e] \r\n[[-InputObject] \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Stops SQL Server traces", "Name": "Stop-DbaTrace", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaTrace -SqlInstance sql2008\r\n\r\nStops all traces on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaTrace -SqlInstance sql2008 -Id 1\r\n\r\nStops all trace with ID 1 on sql2008\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaTrace -SqlInstance sql2008 | Out-GridView -PassThru | Stop-DbaTrace\r\n\r\nStops selected traces on sql2008\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Stop-DbaXESession", "Description": "This script stops Extended Events sessions on a SQL Server instance.", "Tags": [ "ExtendedEvent", "XE", "XEvent" ], "Syntax": "\r\nStop-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -Session \u003cObject[]\u003e \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nStop-DbaXESession [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] -AllSessions \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nStop-DbaXESession -InputObject \u003cSession[]\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Doug Meyers", "Synopsis": "Stops Extended Events sessions.", "Name": "Stop-DbaXESession", "Links": "https://dbatools.io/Stop-DbaXESession", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaXESession -SqlInstance sqlserver2012 -AllSessions\r\n\r\nStops all Extended Event Session on the sqlserver2014 instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eStop-DbaXESession -SqlInstance sqlserver2012 -Session xesession1,xesession2\r\n\r\nStops the xesession1 and xesession2 Extended Event sessions.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sqlserver2012 -Session xesession1 | Stop-DbaXESession\r\n\r\nStops the sessions returned from the Get-DbaXESession function.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nStop-DbaXESmartTarget [-InputObject] \u003cObject[]\u003e [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESmartTarget | Stop-DbaXESmartTarget\r\n\r\nStops all XESmartTarget jobs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESmartTarget | Where-Object Id -eq 2 | Stop-DbaXESmartTarget\r\n\r\nStops a specific XESmartTarget job.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nSync-DbaLoginPermission [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cObject[]\u003e] [[-ExcludeLogin] \u003cObject[]\u003e] \r\n[-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eSync-DbaLoginPermission -Source sqlserver2014a -Destination sqlcluster\r\n\r\nSyncs only SQL Server login permissions, roles, etc. Does not add or drop logins or users. To copy logins and their \r\npermissions, use Copy-SqlLogin.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eSync-DbaLoginPermission -Source sqlserver2014a -Destination sqlcluster -Exclude realcajun -SourceSqlCredential \r\n$scred -DestinationSqlCredential $dcred\r\n\r\nCopies all login permissions except for realcajun using SQL Authentication to connect to each server. If a login \r\nalready exists on the destination, the permissions will not be migrated.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eSync-DbaLoginPermission -Source sqlserver2014a -Destination sqlcluster -Login realcajun, netnerds\r\n\r\nCopies permissions ONLY for logins netnerds and realcajun.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaBackupInformation", "Description": "Normally takes in a backup history object from Format-DbaBackupInformation\n\nThis 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\nif no errors are found then the objects for that database will me marked as Verified.", "Tags": [ "Backup", "Restore", "DisasterRecovery" ], "Syntax": "\r\nTest-DbaBackupInformation [-BackupHistory] \u003cObject[]\u003e [[-SqlInstance] \u003cDbaInstanceParameter\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [-WithReplace] [-Continue] [-VerifyOnly] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$BackupHistory | Test-DbaBackupInformation -SqlInstance MyInstance\r\n\r\n$PassedDbs = $BackupHistory | Where-Object {$_.IsVerified -eq $True}\r\n$FailedDbs = $BackupHistory | Where-Object {$_.IsVerified -ne $True}\r\n\r\nPass in a BackupHistory object to be tested against MyInstance.\r\n\r\nThose records that pass are marked as verified. We can then use the IsVerified property to divide the failures and \r\nsuccesses\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaBuild", "Description": "It answers the question \"is this build up to date ?\"\nReturns info about the specific build of a SQL instance, including the SP, the CU and the reference KB, End Of Support, wherever possible.\nIt adds a Compliance property as true/false, and adds details about the \"targeted compliance\"", "Tags": "SqlBuild", "Syntax": "\r\nTest-DbaBuild [[-Build] \u003cVersion[]\u003e] [[-MinimumBuild] \u003cVersion\u003e] [[-MaxBehind] \u003cString\u003e] [-Latest] [[-SqlInstance] \r\n\u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [-Update] [-Quiet] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "niphlod", "Synopsis": "Returns SQL Server Build \"compliance\" level on a build", "Name": "Test-DbaBuild", "Links": "https://dbatools.io/Test-DbaBuild", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MinimumBuild \"12.0.5557\"\r\n\r\nReturns information about a build identified by \"12.0.5540\" (which is SQL 2014 with SP2 and CU4), which is not \r\ncompliant as the minimum required\r\nbuild is \"12.0.5557\" (which is SQL 2014 with SP2 and CU8)\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MaxBehind \"1SP\"\r\n\r\nReturns information about a build identified by \"12.0.5540\", making sure it is AT MOST 1 Service Pack \"behind\". For \r\nthat version,\r\nthat identifies an SP2, means accepting as the lowest compliance version as \"12.0.4110\", that identifies 2014 with SP1\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MaxBehind \"1SP 1CU\"\r\n\r\nReturns information about a build identified by \"12.0.5540\", making sure it is AT MOST 1 Service Pack \"behind\", plus 1 \r\nCU \"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, \r\nthe target \"compliant\" build\r\nwill be \"12.0.4511\", which is 2014 with SP1 and CU12\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -MaxBehind \"0CU\"\r\n\r\nReturns information about a build identified by \"12.0.5540\", making sure it is the latest CU release.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.5540\" -Latest\r\n\r\nSame as previous, returns information about a build identified by \"12.0.5540\", making sure it is the latest build \r\navailable.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.00.4502\" -MinimumBuild \"12.0.4511\" -Update\r\n\r\nSame as before, but tries to fetch the most up to date index online. When the online version is newer, the local one \r\ngets overwritten\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaBuild -Build \"12.0.4502\",\"10.50.4260\" -MinimumBuild \"12.0.4511\"\r\n\r\nReturns information builds identified by these versions strings\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sqlserver2014a | Test-DbaBuild -MinimumBuild \"12.0.4511\"\r\n\r\nIntegrate with other commandlets to have builds checked for all your registered servers on sqlserver2014a\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaCmConnection [[-ComputerName] \u003cDbaCmConnectionParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-Type] {None | \r\nCimRM | CimDCOM | Wmi | PowerShellRemoting}] [-Force] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Fred Winmann (@FredWeinmann)", "Synopsis": "Tests over which paths a computer can be managed.", "Name": "Test-DbaCmConnection", "Links": "https://dbatools.io/Test-DbaCmConnection", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaCmConnection -ComputerName sql2014\r\n\r\nPerforms a full-spectrum connection test against the computer sql2014. The results will be reported and registered. \r\nFuture calls from Get-DbaCmObject will recognize the results and optimize the query.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaCmConnection -ComputerName sql2014 -Credential $null -Type CimDCOM, CimRM\r\n\r\nThis test will run a connectivity test of CIM over DCOM and CIM over WinRM against the computer sql2014 using Windows \r\nAuthentication.\r\n\r\nThe results will be reported and registered. Future calls from Get-DbaCmObject will recognize the results and optimize \r\nthe query.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaConnection [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tests the connection to a single instance.", "Name": "Test-DbaConnection", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaConnection SQL2016\r\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\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaConnectionAuthScheme [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Kerberos] \r\n[-Ntlm] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaConnectionAuthScheme -SqlInstance sqlserver2014a, sql2016\r\n\r\nReturns ConnectName, ServerName, Transport and AuthScheme for sqlserver2014a and sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaConnectionAuthScheme -SqlInstance sqlserver2014a -Kerberos\r\n\r\nReturns $true or $false depending on if the connection is Kerberos or not.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaConnectionAuthScheme -SqlInstance sqlserver2014a | Select-Object *\r\n\r\nReturns the results of \"SELECT * from sys.dm_exec_connections WHERE session_id = @@SPID\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaDbCollation", "Description": "Compares Database Collations to Server Collation", "Tags": [ "Database", "Collation" ], "Syntax": "\r\nTest-DbaDbCollation [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Compares Database Collations to Server Collation", "Name": "Test-DbaDbCollation", "Links": "https://dbatools.io/Test-DbaDbCollation", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCollation -SqlInstance sqlserver2014a\r\n\r\nReturns server name, database name and true/false if the collations match for all databases on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCollation -SqlInstance sqlserver2014a -Database db1, db2\r\n\r\nReturns information for the db1 and db2 databases on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCollation -SqlInstance sqlserver2014a, sql2016 -Exclude db1\r\n\r\nReturns information for database and server collations for all databases except db1 on sqlserver2014a and sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2016 | Test-DbaDbCollation\r\n\r\nReturns db/server collation information for every database on every server listed in the Central Management Server on \r\nsql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaDbCompatibility", "Description": "Compares Database Compatibility level to Server Compatibility", "Tags": [ "Database", "Compatibility" ], "Syntax": "\r\nTest-DbaDbCompatibility [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Compares Database Compatibility level to Server Compatibility", "Name": "Test-DbaDbCompatibility", "Links": "https://dbatools.io/Test-DbaDbCompatibility", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompatibility -SqlInstance sqlserver2014a\r\n\r\nReturns server name, database name and true/false if the compatibility level match for all databases on sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompatibility -SqlInstance sqlserver2014a -Database db1, db2\r\n\r\nReturns detailed information for database and server compatibility level for the db1 and db2 databases on \r\nsqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompatibility -SqlInstance sqlserver2014a, sql2016 -Exclude db1\r\n\r\nReturns detailed information for database and server compatibility level for all databases except db1 on sqlserver2014a \r\nand sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaRegisteredServer -SqlInstance sql2014 | Test-DbaDbCompatibility\r\n\r\nReturns db/server compatibility information for every database on every server listed in the Central Management Server \r\non sql2016.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaDbCompression", "Description": "This function returns the results of a full table/index compression analysis.\nThis function returns the estimated best option to date for either NONE, Page, or Row Compression.\nRemember Uptime is critical, 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\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:\nColumn Percent_Update shows the percentage of update operations on a specific table, index, or partition,\nrelative to total operations on that object. The lower the percentage of Updates\n(that is, the table, index, or partition is infrequently updated), the better candidate it is for page compression.\nColumn Percent_Scan shows the percentage of scan operations on a table, index, or partition, relative to total\noperations on that object. The higher the value of Scan (that is, the table, index, or partition is mostly scanned),\nthe better candidate it is for page compression.\nColumn Compression_Type_Recommendation can have four possible outputs indicating where there is most gain,\nif any: \u0027PAGE\u0027, \u0027ROW\u0027, \u0027NO_GAIN\u0027 or \u0027?\u0027. When the output is \u0027?\u0027 this approach could not give a recommendation,\nso as a rule of thumb I would lean to ROW if the object suffers mainly UPDATES, or PAGE if mainly INSERTS,\nbut this is where knowing your workload is essential. When the output is \u0027NO_GAIN\u0027 well, that means that according\nto sp_estimate_data_compression_savings no space gains will be attained when compressing, as in the above output example,\nwhere compressing would grow the affected object.\n\nNote: This 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" ], "Syntax": "\r\nTest-DbaDbCompression [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [[-Schema] \u003cString[]\u003e] [[-Table] \u003cString[]\u003e] [[-ResultSize] \u003cInt32\u003e] \r\n[[-Rank] \u003cString\u003e] [[-FilterBy] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance localhost\r\n\r\nReturns results of all potential compression options for all databases for the default instance on the local host. \r\nReturns a recommendation of either Page, Row or NO_GAIN\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA\r\n\r\nReturns results of all potential compression options for all databases on the instance ServerA\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA -Database DBName | Out-GridView\r\n\r\nReturns results of all potential compression options for a single database DBName with the recommendation of either \r\nPage or Row or NO_GAIN in a nicely formatted GridView\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nTest-DbaDbCompression -SqlInstance ServerA -ExcludeDatabase MyDatabase -SqlCredential $cred\r\n\r\nReturns results of all potential compression options for all databases except MyDatabase on instance ServerA using SQL \r\ncredentials to authentication to ServerA.\r\nReturns the recommendation of either Page, Row or NO_GAIN\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA -Schema Test -Table MyTable\r\n\r\nReturns results of all potential compression options for the Table Test.MyTable in instance ServerA on ServerA and \r\nServerB.\r\nReturns the recommendation of either Page, Row or NO_GAIN.\r\nReturns a result for each partiton of any Heap, Clustered or NonClustered index.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbCompression -SqlInstance ServerA, ServerB -ResultSize 10\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eServerA | Test-DbaDbCompression -Schema Test -ResultSize 10 -Rank UsedPages -FilterBy Table\r\n\r\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.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 8 --------------------------\r\n\r\nPS C:\\\u003e$servers = \u0027Server1\u0027,\u0027Server2\u0027\r\n\r\n$servers | Test-DbaDbCompression -Database DBName | Out-GridView\r\n\r\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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 9 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential sqladmin\r\n\r\nTest-DbaDbCompression -SqlInstance ServerA -Database MyDB -SqlCredential $cred -Schema Test -Table Test1, Test2\r\n\r\nReturns results of all potential compression options for objects in Database MyDb on instance ServerA using SQL \r\ncredentials 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\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 10 --------------------------\r\n\r\nPS C:\\\u003e$servers = \u0027Server1\u0027,\u0027Server2\u0027\r\n\r\nforeach ($svr in $servers)\r\n{\r\n Test-DbaDbCompression -SqlInstance $svr | Export-Csv -Path C:\\temp\\CompressionAnalysisPAC.csv -Append\r\n}\r\n\r\nThis produces a full analysis of all your servers listed and is pushed to a csv for you to analyze.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaDbOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-TargetLogin] \u003cString\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbOwner -SqlInstance localhost\r\n\r\nReturns all databases where the owner does not match \u0027sa\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbOwner -SqlInstance localhost -TargetLogin \u0027DOMAIN\\account\u0027\r\n\r\nReturns all databases where the owner does not match \u0027DOMAIN\\account\u0027.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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:\n http://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/\n http://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" ], "Syntax": "\r\nTest-DbaDbVirtualLogFile [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] [-IncludeSystemDBs] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbVirtualLogFile -SqlInstance sqlcluster\r\n\r\nReturns all user database virtual log file counts for the sqlcluster instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbVirtualLogFile -SqlInstance sqlserver | Where-Object {$_.Count -ge 50}\r\n\r\nReturns user databases that have 50 or more VLFs.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e@(\u0027sqlserver\u0027,\u0027sqlcluster\u0027) | Test-DbaDbVirtualLogFile\r\n\r\nReturns all VLF information for the sqlserver and sqlcluster SQL Server instances. Processes data via the pipeline.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDbVirtualLogFile -SqlInstance sqlcluster -Database db1, db2\r\n\r\nReturns VLF counts for the db1 and db2 databases on sqlcluster.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nTest-DbaDiskAlignment [-ComputerName] \u003cObject[]\u003e [-Detailed] [[-Credential] \u003cPSCredential\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [-NoSqlCheck] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Constantine Kokkinos (https://constantinekokkinos.com, @mobileck)", "Synopsis": "Verifies that your non-dynamic disks are aligned according to physical constraints.", "Name": "Test-DbaDiskAlignment", "Links": "https://dbatools.io/Test-DbaDiskAlignment", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskAlignment -ComputerName sqlserver2014a\r\n\r\nTests the disk alignment of a single server named sqlserver2014a\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskAlignment -ComputerName sqlserver2014a, sqlserver2014b, sqlserver2014c\r\n\r\nTests the disk alignment of multiple servers\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\nSpecify -Detailed for details.\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.\"\n\nhttp://tk.azurewebsites.net/2012/08/", "Tags": [ "CIM", "Storage" ], "Syntax": "\r\nTest-DbaDiskAllocation [-ComputerName] \u003cObject[]\u003e [-NoSqlCheck] [[-SqlCredential] \u003cPSCredential\u003e] [[-Credential] \r\n\u003cPSCredential\u003e] [-Detailed] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskAllocation -ComputerName sqlserver2014a\r\n\r\nScans all disks on server sqlserver2014a for best practice allocation unit size.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskAllocation -ComputerName sqlserver2014 | Select-Output *\r\n\r\nScans all disks on server sqlserver2014a for allocation unit size and returns detailed results for each.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskAllocation -ComputerName sqlserver2014a -NoSqlCheck\r\n\r\nScans all disks not hosting SQL Server data or log files on server sqlserver2014a for best practice allocation unit \r\nsize.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nTest-DbaDiskSpeed [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Tests how disks are performing.", "Name": "Test-DbaDiskSpeed", "Links": "https://dbatools.io/Test-DbaDiskSpeed", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskSpeed -SqlInstance sql2008, sqlserver2012\r\n\r\nTests how disks are performing on sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaDiskSpeed -SqlInstance sql2008 -Database tempdb\r\n\r\nTests how disks storing tempdb files on sql2008 are performing.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaIdentityUsage [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Database \u003cObject[]\u003e] \r\n[-ExcludeDatabase \u003cObject[]\u003e] [[-Threshold] \u003cInt32\u003e] [[-ExcludeSystemDb]] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaIdentityUsage -SqlInstance sql2008, sqlserver2012\r\n\r\nCheck identity seeds for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaIdentityUsage -SqlInstance sql2008 -Database TestDB\r\n\r\nCheck identity seeds on server sql2008 for only the TestDB database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaIdentityUsage -SqlInstance sql2008 -Database TestDB -Threshold 20\r\n\r\nCheck identity seeds on server sql2008 for only the TestDB database, limiting results to 20% utilization of seed range \r\nor higher\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.\n\nBy 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.\n\nBest practice reference: http://sqlmag.com/blog/sql-server-tip-assign-ownership-jobs-sysadmin-account", "Tags": [ "Agent", "Job", "Owner" ], "Syntax": "\r\nTest-DbaJobOwner [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Job] \u003cObject[]\u003e] \r\n[[-ExcludeJob] \u003cObject[]\u003e] [[-Login] \u003cString\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaJobOwner -SqlInstance localhost\r\n\r\nReturns all SQL Agent Jobs where the owner does not match \u0027sa\u0027.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaJobOwner -SqlInstance localhost -ExcludeJob \u0027syspolicy_purge_history\u0027\r\n\r\nReturns SQL Agent Jobs except for the syspolicy_purge_history job\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaJobOwner -SqlInstance localhost -Login DOMAIN\\account\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 SqlServer 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" ], "Syntax": "\r\nTest-DbaLastBackup [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] \r\n[[-ExcludeDatabase] \u003cObject[]\u003e] [[-Destination] \u003cDbaInstanceParameter\u003e] [[-DestinationCredential] \u003cObject\u003e] \r\n[[-DataDirectory] \u003cString\u003e] [[-LogDirectory] \u003cString\u003e] [[-Prefix] \u003cString\u003e] [-VerifyOnly] [-NoCheck] [-NoDrop] \r\n[-CopyFile] [[-CopyPath] \u003cString\u003e] [[-MaxMB] \u003cInt32\u003e] [-IncludeCopyOnly] [-IgnoreLogBackup] [[-AzureCredential] \r\n\u003cString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016\r\n\r\nDetermines the last full backup for ALL databases, attempts to restore all databases (with a different name and file \r\nstructure), then performs a DBCC CHECKDB.\r\n\r\nOnce the test is complete, the test restore will be dropped.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -Database master\r\n\r\nDetermines the last full backup for master, attempts to restore it, then performs a DBCC CHECKDB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -Database model, master -VerifyOnly\r\n\r\n\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -NoCheck -NoDrop\r\n\r\nSkips the DBCC CHECKDB check. This can help speed up the tests but makes it less tested. The test restores will remain \r\non the server.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2016 -DataDirectory E:\\bigdrive -LogDirectory L:\\bigdrive -MaxMB 10240\r\n\r\nRestores data and log files to alternative locations and only restores databases that are smaller than 10 GB.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2014 -Destination sql2016 -CopyFile\r\n\r\nCopies the backup files for sql2014 databases to sql2016 default backup locations and then attempts restore from there.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLastBackup -SqlInstance sql2014 -Destination sql2016 -CopyFile -CopyPath \"\\\\BackupShare\\TestRestore\\\"\r\n\r\nCopies the backup files for sql2014 databases to sql2016 default backup locations and then attempts restore from there.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaLinkedServerConnection", "Description": "Test each linked server on the instance", "Tags": "LinkedServer", "Syntax": "\r\nTest-DbaLinkedServerConnection [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLinkedServerConnection -SqlInstance DEV01\r\n\r\nTest all Linked Servers for the SQL Server instance DEV01\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLinkedServerConnection -SqlInstance sql2016 | Out-File C:\\temp\\results.txt\r\n\r\nTest all Linked Servers for the SQL Server instance sql2016 and output results to file\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLinkedServerConnection -SqlInstance sql2016, sql2014, sql2012\r\n\r\nTest all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$servers = \"sql2016\",\"sql2014\",\"sql2012\"\r\n\r\n$servers | Test-DbaLinkedServerConnection -SqlCredential (Get-Credential sqladmin)\r\n\r\nTest all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012 using SQL login credentials\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$servers | Get-DbaLinkedServer | Test-DbaLinkedServerConnection\r\n\r\nTest all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.", "Syntax": "\r\nTest-DbaLoginPassword [[-SqlInstance] \u003cDbaInstanceParameter[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] [[-Login] \u003cString[]\u003e] \r\n[[-Dictionary] \u003cString[]\u003e] [[-InputObject] \u003cLogin[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLoginPassword -SqlInstance Dev01\r\n\r\nTest all SQL logins that the password is null or same as username on SQL server instance Dev01\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLoginPassword -SqlInstance Dev01 -Login sqladmin\r\n\r\nTest the \u0027sqladmin\u0027 SQL login that the password is null or same as username on SQL server instance Dev01\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLoginPassword -SqlInstance Dev01 -Dictionary Test1,test2\r\n\r\nTest all SQL logins that the password is null, same as username or Test1,Test2 on SQL server instance Dev0\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaLogin -SqlInstance \"sql2017\",\"sql2016\" | Test-DbaLoginPassword\r\n\r\nTest all logins on sql2017 and sql2016\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$servers | Get-DbaLogin | Out-GridView -Passthru | Test-DbaLoginPassword\r\n\r\nTest selected logins on all servers in the $servers variable\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaLogShippingStatus", "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", "Syntax": "\r\nTest-DbaLogShippingStatus [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \r\n\u003cString[]\u003e] [[-ExcludeDatabase] \u003cString[]\u003e] [-Simple] [-Primary] [-Secondary] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Sander Stad (@sqlstad, sqlstad.nl)", "Synopsis": "Test-DbaLogShippingStatus returns the status of your log shipping databases", "Name": "Test-DbaLogShippingStatus", "Links": "https://dbatools.io/Test-DbaLogShippingStatus", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLogShippingStatus -SqlInstance sql1\r\n\r\nRetrieves the log ship information from sql1 and displays all the information present including the status.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLogShippingStatus -SqlInstance sql1 -Database AdventureWorks2014\r\n\r\nRetrieves the log ship information for just the database AdventureWorks.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLogShippingStatus -SqlInstance sql1 -Primary\r\n\r\nRetrieves the log ship information and only returns the information for the databases on the primary instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLogShippingStatus -SqlInstance sql1 -Secondary\r\n\r\nRetrieves the log ship information and only returns the information for the databases on the secondary instance.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaLogShippingStatus -SqlInstance sql1 -Simple\r\n\r\nRetrieves the log ship information and only returns the columns SQL Instance, Database, Instance Type and Status\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nTest-DbaManagementObject [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [-VersionNumber] \r\n\u003cInt32[]\u003e [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaManagementObject -VersionNumber 13\r\n\r\nReturns True if the version exists, if it does not exist it will return False\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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:\n https://support.microsoft.com/en-us/kb/2806535\n https://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" ], "Syntax": "\r\nTest-DbaMaxDop [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Detailed] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sql2008, sqlserver2012\r\n\r\nGet Max DOP setting for servers sql2008 and sqlserver2012 and also the recommended one.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sql2014 | Select-Object *\r\n\r\nShows Max DOP setting for server sql2014 with the recommended value. Piping the output to Select-Object * will also \r\nshow the \u0027NUMANodes\u0027 and \u0027NumberOfCores\u0027 of each instance\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMaxDop -SqlInstance sqlserver2016 | Select-Object *\r\n\r\nGet Max DOP setting for servers sql2016 with the recommended value. Piping the output to Select-Object * will also show \r\nthe \u0027NUMANodes\u0027 and \u0027NumberOfCores\u0027 of each instance. Because it is an 2016 instance will be shown \u0027InstanceVersion\u0027, \r\n\u0027Database\u0027 and \u0027DatabaseMaxDop\u0027 columns.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaMaxMemory [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Credential \u003cPSCredential\u003e] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMaxMemory -SqlInstance sqlcluster,sqlserver2012\r\n\r\nCalculate the \u0027Max Server Memory\u0027 settings for all servers within the SQL Server Central Management Server \"sqlcluster\"\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMaxMemory -SqlInstance sqlcluster | Where-Object { $_.SqlMaxMB -gt $_.TotalMB } | Set-DbaMaxMemory\r\n\r\nFind all servers in CMS that have Max SQL memory set to higher than the total memory of the server (think 2147483647) \r\nand set it to recommended value.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nTest-DbaMigrationConstraint [-Source] \u003cDbaInstanceParameter\u003e [[-SourceSqlCredential] \u003cPSCredential\u003e] [-Destination] \r\n\u003cDbaInstanceParameter\u003e [[-DestinationSqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \r\n\u003cObject[]\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMigrationConstraint -Source sqlserver2014a -Destination sqlcluster\r\n\r\nAll databases on sqlserver2014a will be verified for features in use that can\u0027t be supported on sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMigrationConstraint -Source sqlserver2014a -Destination sqlcluster -SqlCredential $cred\r\n\r\nAll databases will be verified for features in use that can\u0027t be supported on the destination server. SQL credentials \r\nare used to authenticate against sqlserver2014 and Windows Authentication is used for sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaMigrationConstraint -Source sqlserver2014a -Destination sqlcluster -Database db1\r\n\r\nOnly db1 database will be verified for features in use that can\u0027t be supported on the destination server.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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.\n\nIt 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" ], "Syntax": "\r\nTest-DbaNetworkLatency [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Query] \u003cString\u003e] \r\n[[-Count] \u003cInt32\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaNetworkLatency -SqlInstance sqlserver2014a, sqlcluster\r\n\r\nTests the roundtrip return of \"SELECT TOP 100 * FROM INFORMATION_SCHEMA.TABLES\" on sqlserver2014a and sqlcluster using \r\nWindows credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaNetworkLatency -SqlInstance sqlserver2014a -SqlCredential $cred\r\n\r\nTests the execution results return of \"SELECT TOP 100 * FROM INFORMATION_SCHEMA.TABLES\" on sqlserver2014a using SQL \r\ncredentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaNetworkLatency -SqlInstance sqlserver2014a, sqlcluster, sqlserver -Query \"select top 10 * from \r\notherdb.dbo.table\" -Count 10\r\n\r\nTests the execution results return of \"select top 10 * from otherdb.dbo.table\" 10 times on sqlserver2014a, sqlcluster, \r\nand sqlserver using Windows credentials.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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 adhoc workloads\" option.", "Tags": [ "Configure", "SPConfigure" ], "Syntax": "\r\nTest-DbaOptimizeForAdHoc [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaOptimizeForAdHoc -SqlInstance sql2008, sqlserver2012\r\n\r\nValidates whether Optimize for AdHoc Workloads setting is enabled for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaPath", "Description": "Uses master.dbo.xp_fileexist to determine if a file or directory exists.", "Tags": [ "Path", "ServiceAccount" ], "Syntax": "\r\nTest-DbaPath [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Path] \u003cObject\u003e \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaPath -SqlInstance sqlcluster -Path L:\\MSAS12.MSSQLSERVER\\OLAP\r\n\r\nTests whether the service account running the \"sqlcluster\" SQL Server instance can access L:\\MSAS12.MSSQLSERVER\\OLAP. \r\nLogs into sqlcluster using Windows credentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$credential = Get-Credential\r\n\r\nTest-DbaPath -SqlInstance sqlcluster -SqlCredential $credential -Path L:\\MSAS12.MSSQLSERVER\\OLAP\r\n\r\nTests whether the service account running the \"sqlcluster\" SQL Server instance can access L:\\MSAS12.MSSQLSERVER\\OLAP. \r\nLogs into sqlcluster using SQL authentication.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nTest-DbaPowerPlan [[-ComputerName] \u003cDbaInstanceParameter[]\u003e] [[-Credential] \u003cPSCredential\u003e] [[-CustomPowerPlan] \r\n\u003cString\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaPowerPlan -ComputerName sqlserver2014a\r\n\r\nChecks the Power Plan settings for sqlserver2014a and indicates whether or not it complies with best practices.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaPowerPlan -ComputerName sqlserver2014a -CustomPowerPlan \u0027Maximum Performance\u0027\r\n\r\nChecks the Power Plan settings for sqlserver2014a and indicates whether or not it is set to the custom plan \"Maximum \r\nPerformance\".\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Test-DbaRecoveryModel", "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" ], "Syntax": "\r\nTest-DbaRecoveryModel [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Database] \u003cObject[]\u003e] [[-ExcludeDatabase] \u003cObject[]\u003e] \r\n[[-SqlCredential] \u003cPSCredential\u003e] [[-RecoveryModel] \u003cObject\u003e] [-Detailed] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Claudio Silva (@ClaudioESSilva)", "Synopsis": "Find if database is really a specific recovery model or not.", "Name": "Test-DbaRecoveryModel", "Links": "https://dbatools.io/Test-DbaRecoveryModel", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRecoveryModel -SqlInstance sql2005\r\n\r\nShows all databases where the configured recovery model is FULL and indicates whether or not they are really in FULL \r\nrecovery model.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRecoveryModel -SqlInstance . | Where-Object {$_.ActualRecoveryModel -ne \"FULL\"}\r\n\r\nOnly shows the databases that are functionally in \u0027simple\u0027 mode.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRecoveryModel -SqlInstance sql2008 -RecoveryModel Bulk_Logged | Sort-Object Server -Descending\r\n\r\nShows all databases where the configured recovery model is BULK_LOGGED and sort them by server name descending\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRecoveryModel -SqlInstance localhost | Select-Object -Property *\r\n\r\nShows all of the properties for the databases that have Full Recovery Model\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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", "Syntax": "\r\nTest-DbaRepLatency [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-Database] \u003cObject[]\u003e] [[-SqlCredential] \u003cPSCredential\u003e] \r\n[[-PublicationName] \u003cObject[]\u003e] [[-TimeToLive] \u003cInt32\u003e] [-RetainToken] [-DisplayTokenHistory] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRepLatency -SqlInstance sql2008, sqlserver2012\r\n\r\nReturn replication latency for all transactional publications for servers sql2008 and sqlserver2012.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRepLatency -SqlInstance sql2008 -Database TestDB\r\n\r\nReturn replication latency for all transactional publications on server sql2008 for only the TestDB database\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaRepLatency -SqlInstance sql2008 -Database TestDB -PublicationName TestDB_Pub\r\n\r\nReturn replication latency for the TestDB_Pub publication for the TestDB database located on the server sql2008.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaServerName [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Detailed] [-ExcludeSsrs] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a\r\n\r\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a, sql2016\r\n\r\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a, sql2016 -ExcludeSsrs\r\n\r\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016, but skips \r\nvalidating if SSRS is installed on both instances.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaServerName -SqlInstance sqlserver2014a, sql2016 | Select-Object *\r\n\r\nReturns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.\r\n\r\nIf a Rename is required, it will also show Updatable, and Reasons if the servername is not updatable.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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)\nbroken functionality of the Microsoft Kerberos Configuration manager and SQL Server 2016. The functon will connect to a remote server and,\nthrough WMI, discover all running intances of SQL Server. For any instances with TCP/IP enabled, the script will determine which port(s)\nthe instances are listening on and generate the required SPNs. For named instances NOT using dynamic ports, the script will generate a port-\nbased SPN for those instances as well. 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\nset.\n\nThe function will return a custom object(s) that contains the server name checked, the instance name discovered, the account the service is\nrunning under, and what the \"required\" SPN should be. It will also return a boolean property indicating if the SPN is set in Active Directory\nor not.", "Tags": "SPN", "Syntax": "\r\nTest-DbaSpn [-ComputerName] \u003cDbaInstanceParameter[]\u003e [[-Credential] \u003cPSCredential\u003e] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Drew Furgiuele (@pittfurg), http://www.port1433.com", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName SQLSERVERA -Credential (Get-Credential)\r\n\r\nConnects to a computer (SQLSERVERA) and queries WMI for all SQL instances and return \"required\" SPNs. It will then take \r\neach SPN it generates\r\nand query Active Directory to make sure the SPNs are set.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName SQLSERVERA,SQLSERVERB -Credential (Get-Credential)\r\n\r\nConnects to multiple computers (SQLSERVERA, SQLSERVERB) and queries WMI for all SQL instances and return \"required\" \r\nSPNs.\r\nIt will then take each SPN it generates and query Active Directory to make sure the SPNs are set.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaSpn -ComputerName SQLSERVERC -Credential (Get-Credential)\r\n\r\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 \r\ncredential you pass must have be a valid login with appropriate rights on the domain\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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\nOther rules can be added at a future date.", "Tags": [ "tempdb", "configuration" ], "Syntax": "\r\nTest-DbaTempdbConfig [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [[-SqlCredential] \u003cPSCredential\u003e] [-Detailed] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaTempdbConfig -SqlInstance localhost\r\n\r\nChecks tempdb on the localhost machine.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaTempdbConfig -SqlInstance localhost | Select-Object *\r\n\r\nChecks tempdb on the localhost machine. All rest results are shown.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nTest-DbaWindowsLogin [-SqlInstance] \u003cDbaInstanceParameter[]\u003e [-SqlCredential \u003cPSCredential\u003e] [-Login \u003cObject[]\u003e] \r\n[-ExcludeLogin \u003cObject[]\u003e] [-FilterBy \u003cString\u003e] [-IgnoreDomains \u003cString[]\u003e] [-Detailed] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Stephen Bennett: https://sqlnotesfromtheunderground.wordpress.com/", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaWindowsLogin -SqlInstance Dev01\r\n\r\nTests all logins in the current Active Directory domain that are either disabled or do not exist on the SQL Server \r\ninstance Dev01\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaWindowsLogin -SqlInstance Dev01 -FilterBy GroupsOnly | Select-Object -Property *\r\n\r\nTests all Active Directory groups that have logins on Dev01, and shows all information for those logins\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eTest-DbaWindowsLogin -SqlInstance Dev01 -IgnoreDomains testdomain\r\n\r\nTests all Domain logins excluding any that are from the testdomain\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nUninstall-DbaWatchUpdate [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eUninstall-DbaWatchUpdate\r\n\r\nRemoves the scheduled task created by Install-DbaWatchUpdate.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nUpdate-DbaServiceAccount [-ComputerName \u003cDbaInstanceParameter[]\u003e] [-Credential \u003cPSCredential\u003e] [-ServiceName] \r\n\u003cString[]\u003e [-Username \u003cString\u003e] [-ServiceCredential \u003cPSCredential\u003e] [-OldPassword \u003cSecureString\u003e] [-NewPassword \r\n\u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\nUpdate-DbaServiceAccount [-Credential \u003cPSCredential\u003e] -InputObject \u003cObject[]\u003e [-Username \u003cString\u003e] [-ServiceCredential \r\n\u003cPSCredential\u003e] [-OldPassword \u003cSecureString\u003e] [-NewPassword \u003cSecureString\u003e] [-EnableException] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Kirill Kravtsov (@nvarscar)", "Synopsis": "Changes service account (or just its password) of the SQL Server service.", "Name": "Update-DbaServiceAccount", "Links": null, "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$NewPassword = ConvertTo-SecureString \u0027Qwerty1234\u0027 -AsPlainText -Force\r\n\r\nUpdate-DbaServiceAccount -ComputerName sql1 -ServiceName \u0027MSSQL$MYINSTANCE\u0027 -Password $NewPassword\r\n\r\nChanges the current service account\u0027s password of the service MSSQL$MYINSTANCE to \u0027Qwerty1234\u0027\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$cred = Get-Credential\r\n\r\nGet-DbaService sql1 -Type Engine,Agent -Instance MYINSTANCE | Update-DbaServiceAccount -ServiceCredential $cred\r\n\r\nRequests credentials from the user and configures them as a service account for the SQL Server engine and agent \r\nservices of the instance sql1\\MYINSTANCE\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eUpdate-DbaServiceAccount -ComputerName sql1,sql2 -ServiceName \u0027MSSQLSERVER\u0027,\u0027SQLSERVERAGENT\u0027 -Username \r\nNETWORKSERVICE\r\n\r\nConfigures SQL Server engine and agent services on the machines sql1 and sql2 to run under Network Service system user.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaService sql1 -Type Engine -Instance MSSQLSERVER | Update-DbaServiceAccount -Username \u0027MyDomain\\sqluser1\u0027\r\n\r\nConfigures SQL Server engine service on the machine sql1 to run under \u0027MyDomain\\sqluser1\u0027. Will request user to input \r\nthe account password.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Update-Dbatools", "Description": "Exported function. Updates dbatools. Deletes current copy and replaces it with freshest copy.", "Tags": "Module", "Syntax": "\r\nUpdate-Dbatools [-Development] [-EnableException] [-WhatIf] [-Confirm] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eUpdate-Dbatools\r\n\r\nUpdates dbatools. Deletes current copy and replaces it with freshest copy.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eUpdate-Dbatools -dev\r\n\r\nUpdates dbatools to the current development branch. Deletes current copy and replaces it with latest from github.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Watch-DbaDbLogin", "Description": "Watch-DbaDbLogin uses SQL Server DMVs 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", "Syntax": "\r\nWatch-DbaDbLogin [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-Database] \u003cObject\u003e] [[-Table] \u003cString\u003e] [[-SqlCredential] \r\n\u003cPSCredential\u003e] [[-SqlCms] \u003cString\u003e] [[-ServersFromFile] \u003cString\u003e] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eWatch-DbaDbLogin -SqlInstance sqlserver -SqlCms SqlCms1\r\n\r\nA list of all database instances within the Central Management Server SqlCms1 is generated. Using this list, the script \r\nenumerates all the processes and gathers login information and saves it to the table Dblogins in the DatabaseLogins \r\ndatabase on SQL Server sqlserver.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eWatch-DbaDbLogin -SqlInstance sqlcluster -Database CentralAudit -ServersFromFile .\\sqlservers.txt\r\n\r\nA list of servers is gathered from the file sqlservers.txt in the current directory. Using this list, the script \r\nenumerates all the processes and gathers login information and saves it to the table Dblogins in the CentralAudit \r\ndatabase on SQL Server sqlcluster.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eWatch-DbaDbLogin -SqlInstance sqlserver -SqlCms SqlCms1 -SqlCredential $cred\r\n\r\nA list of servers is generated using database instance names within the SQL2014Clusters group on the Central Management \r\nServer SqlCms1. Using this list, the script enumerates all the processes and gathers login information and saves it to \r\nthe table Dblogins in the DatabaseLogins database on sqlserver.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nWatch-DbaUpdate [\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "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": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eWatch-DbaUpdate\r\n\r\nWatches the gallery for updates to dbatools.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "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" ], "Syntax": "\r\nWatch-DbaXESession [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString\u003e] [-Raw] [-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nWatch-DbaXESession -SqlInstance \u003cDbaInstanceParameter\u003e [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString\u003e] [-Raw] \r\n[-EnableException] [\u003cCommonParameters\u003e]\r\n\r\nWatch-DbaXESession [-SqlCredential \u003cPSCredential\u003e] [-Session \u003cString\u003e] -InputObject \u003cSession\u003e [-Raw] [-EnableException] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Author": "Chrissy LeMaire (@cl), netnerds.net", "Synopsis": "Watch live XEvent Data as it happens", "Name": "Watch-DbaXESession", "Links": "https://dbatools.io/Watch-DbaXESession", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003eWatch-DbaXESession -SqlInstance sql2017 -Session system_health\r\n\r\nShows events for the system_health session as it happens.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003eWatch-DbaXESession -SqlInstance sql2017 -Session system_health | Export-Csv -NoTypeInformation -Path \r\nC:\\temp\\system_health.csv\r\n\r\nExports live events to CSV. Ctrl-C may not not cancel out of it - fastest way is to stop the session.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003eGet-DbaXESession -SqlInstance sql2017 -Session system_health | Start-DbaXESession | Watch-DbaXESession | \r\nExport-Csv -NoTypeInformation -Path C:\\temp\\system_health.csv\r\n\r\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.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" }, { "CommandName": "Write-DbaDataTable", "Description": "Writes a .NET DataTable to a SQL Server table using SQL Bulk Copy.", "Tags": [ "DataTable", "Insert" ], "Syntax": "\r\nWrite-DbaDataTable [-SqlInstance] \u003cDbaInstanceParameter\u003e [[-SqlCredential] \u003cPSCredential\u003e] [[-Database] \u003cObject\u003e] \r\n-InputObject \u003cObject\u003e [-Table] \u003cString\u003e [[-Schema] \u003cString\u003e] [-BatchSize \u003cInt32\u003e] [-NotifyAfter \u003cInt32\u003e] \r\n[-AutoCreateTable] [-NoTableLock] [-CheckConstraints] [-FireTriggers] [-KeepIdentity] [-KeepNulls] [-Truncate] \r\n[-bulkCopyTimeOut \u003cInt32\u003e] [-RegularUser] [-EnableException] [-UseDynamicStringLength] [-WhatIf] [-Confirm] \r\n[\u003cCommonParameters\u003e]\r\n\r\n\r\n\r\n\r\n", "Synopsis": "Writes data to a SQL Server Table.", "Name": "Write-DbaDataTable", "Links": "https://dbatools.io/Write-DbaDataTable", "Examples": "\r\n-------------------------- EXAMPLE 1 --------------------------\r\n\r\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv | ConvertTo-DbaDataTable\r\n\r\nWrite-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Table mydb.dbo.customers\r\n\r\nPerforms a bulk insert of all the data in customers.csv into database mydb, schema dbo, table customers. A progress bar \r\nwill be shown as rows are inserted. If the destination table does not exist, the import will be halted.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 2 --------------------------\r\n\r\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv | ConvertTo-DbaDataTable\r\n\r\n$DataTable | Write-DbaDataTable -SqlInstance sql2014 -Table mydb.dbo.customers\r\n\r\nPerforms a row by row insert of the data in customers.csv. This is significantly slower than a bulk insert and will not \r\nshow a progress bar.\r\n\r\nThis method is not recommended. Use -InputObject instead.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 3 --------------------------\r\n\r\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv | ConvertTo-DbaDataTable\r\n\r\nWrite-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Table mydb.dbo.customers -AutoCreateTable\r\n\r\nPerforms a bulk insert of all the data in customers.csv. If mydb.dbo.customers does not exist, it will be created with \r\ninefficient but forgiving DataTypes.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 4 --------------------------\r\n\r\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv | ConvertTo-DbaDataTable\r\n\r\nWrite-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Table mydb.dbo.customers -Truncate\r\n\r\nPerforms a bulk insert of all the data in customers.csv. Prior to importing into mydb.dbo.customers, the user is \r\ninformed that the table will be truncated and asks for confirmation. The user is prompted again to perform the import.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 5 --------------------------\r\n\r\nPS C:\\\u003e$DataTable = Import-Csv C:\\temp\\customers.csv | ConvertTo-DbaDataTable\r\n\r\nWrite-DbaDataTable -SqlInstance sql2014 -InputObject $DataTable -Database mydb -Table customers -KeepNulls\r\n\r\nPerforms a bulk insert of all the data in customers.csv into mydb.dbo.customers. Because Schema was not specified, dbo \r\nwas used. NULL values in the destination table will be preserved.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 6 --------------------------\r\n\r\nPS C:\\\u003e$passwd = ConvertTo-SecureString \"P@ssw0rd\" -AsPlainText -Force\r\n\r\n$AzureCredential = New-Object System.Management.Automation.PSCredential(\"AzureAccount\"),$passwd)\r\n$DataTable = Import-Csv C:\\temp\\customers.csv | ConvertTo-DbaDataTable\r\nWrite-DbaDataTable -SqlInstance AzureDB.database.windows.net -InputObject $DataTable -Database mydb -Table customers \r\n-KeepNulls -Credential $AzureCredential -BulkCopyTimeOut 300\r\n\r\nThis performs the same operation as the previous example, but against a SQL Azure Database instance using the required \r\ncredentials.\r\n\r\n\r\n\r\n\r\n-------------------------- EXAMPLE 7 --------------------------\r\n\r\nPS C:\\\u003e$process = Get-Process | ConvertTo-DbaDataTable\r\n\r\nWrite-DbaDataTable -InputObject $process -SqlInstance sql2014 -Database mydb -Table myprocesses -AutoCreateTable\r\n\r\nCreates a table based on the Process object with over 60 columns, converted from PowerShell data types to SQL Server \r\ndata types. After the table is created a bulk insert is performed to add process information into the table.\r\n\r\nThis is an example of the type conversion in action. All process properties are converted, including special types like \r\nTimeSpan. Script properties are resolved before the type conversion starts thanks to ConvertTo-DbaDataTable.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" } ] |