full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaSpConfigure.ps1
Get-DbaSpConfigure.ps1
FUNCTION Get-DbaSpConfigure { <# .SYNOPSIS Returns all server level system configuration (sys.configuration/sp_configure) information .DESCRIPTION This function returns server level system configuration (sys.configuration/sp_configure) information. The information is gathered through SMO Configuration.Propertie...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Sync-SqlLoginPermissions.ps1
Sync-SqlLoginPermissions.ps1
Function Sync-SqlLoginPermissions { <# .SYNOPSIS Copies SQL login permission from one server to another. .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 not curre...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Rename-DbaLogin.ps1
Rename-DbaLogin.ps1
Function Rename-DbaLogin { <# .SYNOPSIS Rename-DbaLogin will rename login and database mapping for a specified login. .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. It can be a pain to update all of the mappings...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Remove-SqlOrphanUser.ps1
Remove-SqlOrphanUser.ps1
Function Remove-SqlOrphanUser { <# .SYNOPSIS Drop orphan users with no existing login to map .DESCRIPTION An orphan user is defined by a user that does not have their matching login. (Login property = ""). If user is the owner of the schema with the same name and if if the schema does not have any underlying o...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-SqlRegisteredServerName.ps1
Get-SqlRegisteredServerName.ps1
Function Get-SqlRegisteredServerName { <# .SYNOPSIS Gets list of SQL Server names stored in SQL Server Central Management Server. .DESCRIPTION Returns a simple array of server names. Be aware of the dynamic parameter 'Group', which can be used to limit results to one or more groups you have created on the CMS. ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/New-DbaScriptingOption.ps1
New-DbaScriptingOption.ps1
function New-DbaScriptingOption { <# .SYNOPSIS Creates a new Microsoft.SqlServer.Management.Smo.ScriptingOptions object .DESCRIPTION Creates a new Microsoft.SqlServer.Management.Smo.ScriptingOptions object. Basically saves you the time from remembering the SMO assembly name ;) See https://msdn.micro...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaDatabaseSnapshot.ps1
Get-DbaDatabaseSnapshot.ps1
Function Get-DbaDatabaseSnapshot { <# .SYNOPSIS Get database snapshots with details .DESCRIPTION Retrieves the list of database snapshot available, along with their base (the db they are the snapshot of) and creation time .PARAMETER SqlInstance The SQL Server that you're connecting to. .PARAMETER Creden...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaDatabaseOwner.ps1
Test-DbaDatabaseOwner.ps1
function Test-DbaDatabaseOwner { <# .SYNOPSIS Checks database owners against a login to validate which databases do not match that owner. .DESCRIPTION This function will check all databases on an instance against a SQL login to validate if that login owns those databases or not. By default, the function will c...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaHelpIndex.ps1
Get-DbaHelpIndex.ps1
function Get-DbaHelpIndex { <# .SYNOPSIS Returns size, row and configuration information for indexes in databases. .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. As this uses SQL Serv...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaFullRecoveryModel.ps1
Test-DbaFullRecoveryModel.ps1
Function Test-DbaFullRecoveryModel { <# .SYNOPSIS Find if database is really in the Full recovery model or not. .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. This state is also kno...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaExecutionPlan.ps1
Get-DbaExecutionPlan.ps1
Function Get-DbaExecutionPlan { <# .SYNOPSIS Gets execution plans and metadata .DESCRIPTION Gets execution plans and metadata. Can pipe to Export-DbaExecutionPlan :D Thanks to https://www.simple-talk.com/sql/t-sql-programming/dmvs-for-query-plan-metadata/ and http://www.scarydba.com/2017/02/13/expor...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaAgentJob.ps1
Get-DbaAgentJob.ps1
FUNCTION Get-DbaAgentJob { <# .SYNOPSIS Gets SQL Agent Job information for each instance(s) of SQL Server. .DESCRIPTION The Get-DbaAgentJob returns connected SMO object for SQL Agent Job information for each instance(s) of SQL Server. .PARAMETER SqlInstance SQL Server name or SMO object representing the S...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Remove-DbaSpn.ps1
Remove-DbaSpn.ps1
#ValidationTags#FlowControl,Pipeline# Function Remove-DbaSpn { <# .SYNOPSIS Removes an SPN for a given service account in active directory and also removes delegation to the same SPN, if found .DESCRIPTION This function will connect to Active Directory and search for an account. If the account is found, it will...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaAudit.ps1
Get-DbaAudit.ps1
FUNCTION Get-DbaAudit { <# .SYNOPSIS Gets SQL Security Audit information for each instance(s) of SQL Server. .DESCRIPTION The Get-DbaAudit command gets SQL Security Audit information for each instance(s) of SQL Server. .PARAMETER SqlInstance SQL Server name or SMO object representing the SQL Server to con...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Export-SqlUser.ps1
Export-SqlUser.ps1
Function Export-SqlUser { <# .SYNOPSIS Exports users creation and its permissions to a T-SQL file or host. .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. THIS CODE IS PROVID...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaDatabaseFreespace.ps1
Get-DbaDatabaseFreespace.ps1
function Get-DbaDatabaseFreespace { <# .SYNOPSIS Returns database file space information for database files on a SQL instance. .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 FIL...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlSpConfigure.ps1
Copy-SqlSpConfigure.ps1
Function Copy-SqlSpConfigure { <# .SYNOPSIS Copy-SqlSpConfigure migrates configuration values from one SQL Server to another. .DESCRIPTION By default, all configuration values are copied. The -Configs parameter is autopopulated for command-line completion and can be used to copy only specific configs. .PAR...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlAudit.ps1
Copy-SqlAudit.ps1
Function Copy-SqlAudit { <# .SYNOPSIS Copy-SqlAudit migrates server audits from one SQL Server to another. .DESCRIPTION By default, all audits are copied. The -Audits parameter is autopopulated for command-line completion and can be used to copy only specific audits. If the audit already exists on the dest...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlServerRole.ps1
Copy-SqlServerRole.ps1
Function Copy-SqlServerRole { <# .SYNOPSIS Copy-SqlServerRole migrates server roles from one SQL Server to another. .DESCRIPTION By default, all roles are copied. The -Roles parameter is autopopulated for command-line completion and can be used to copy only specific roles. If the role already exists on the...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Expand-SqlTLogResponsibly.ps1
Expand-SqlTLogResponsibly.ps1
function Expand-SqlTLogResponsibly { <# .SYNOPSIS This command will help you to automatically grow your T-Log database file in a responsible way (preventing the generation of too many VLFs). .DESCRIPTION As you may already know, having a TLog file with too many VLFs can hurt your database performance in many ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlAlert.ps1
Copy-SqlAlert.ps1
Function Copy-SqlAlert { <# .SYNOPSIS Copy-SqlAlert migrates alerts from one SQL Server to another. .DESCRIPTION By default, all alerts are copied. The -Alerts parameter is autopopulated for command-line completion and can be used to copy only specific alerts. If the alert already exists on the destination...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaMsdtc.ps1
Get-DbaMsdtc.ps1
Function Get-DbaMsdtc { <# .SYNOPSIS Displays information about the Distributed Transactioon Coordinator (MSDTC) on a server .DESCRIPTION Returns a custom object with Computer name, state of the MSDTC Service, security settings of MSDTC and CID's Requires: Windows administrator access on Servers .PARAMETE...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaTrigger.ps1
Get-DbaTrigger.ps1
Function Get-DbaTrigger { <# .SYNOPSIS Get all existing triggers on one or more SQL instances. .DESCRIPTION Get all existing triggers on one or more SQL instances. Default output includes columns ComputerName, SqlInstance, Database, TriggerName, IsEnabled and DateLastMofied. .PARAMETER SqlInstance The SQ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Find-SqlDuplicateIndex.ps1
Find-SqlDuplicateIndex.ps1
Function Find-SqlDuplicateIndex { <# .SYNOPSIS Find duplicate and overlapping indexes .DESCRIPTION This command will help you to find duplicate and overlapping indexes on a database or a list of databases When 2008+ filtered property also come to comparison Also tells how much space you can save by dropping...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaCredential.ps1
Get-DbaCredential.ps1
FUNCTION Get-DbaCredential { <# .SYNOPSIS Gets SQL Credential information for each instance(s) of SQL Server. .DESCRIPTION The Get-DbaCredential command gets SQL Credential information for each instance(s) of SQL Server. .PARAMETER SqlInstance SQL Server name or SMO object representing the SQL Server to c...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Disable-SqlLogonTrigger.ps1
Disable-SqlLogonTrigger.ps1
Function Disable-SqlLogonTrigger { <# .SYNOPSIS .DESCRIPTION .PARAMETER SqlServer The SQL Server instance. You must have sysadmin access and server version must be SQL Server version 2000 or higher. .PARAMETER SqlCredential Allows you to login to servers using SQL Logins as opposed to Windows Auth/In...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Find-DbaOrphanedFile.ps1
Find-DbaOrphanedFile.ps1
Function Find-DbaOrphanedFile { <# .SYNOPSIS Find-DbaOrphanedFile finds orphaned database files. Orphaned database files are files not associated with any attached database. .DESCRIPTION This command searches all directories associated with SQL database files for database files that are not currently in use by...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlProxyAccount.ps1
Copy-SqlProxyAccount.ps1
Function Copy-SqlProxyAccount { <# .SYNOPSIS Copy-SqlProxyAccount migrates proxy accounts from one SQL Server to another. .DESCRIPTION By default, all proxy accounts are copied. The -ProxyAccounts parameter is autopopulated for command-line completion and can be used to copy only specific proxy accounts. I...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Remove-DbaBackup.ps1
Remove-DbaBackup.ps1
Function Remove-DbaBackup { <# .SYNOPSIS Remove SQL Server backups from disk .DESCRIPTION Provides all of the same functionality for removing SQL backups from disk as a standard maintenance plan would. As an addition you have the ability to check the Archive bit on files before deletion. This will allow you ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaCmObject.ps1
Get-DbaCmObject.ps1
function Get-DbaCmObject { <# .SYNOPSIS Retrieves Wmi/Cim-Style information from computers. .DESCRIPTION This function centralizes all requests for information retrieved from Get-WmiObject or Get-CimInstance. It uses different protocols as availab...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Set-DbaCmConnection.ps1
Set-DbaCmConnection.ps1
function Set-DbaCmConnection { <# .SYNOPSIS Configures a connection object for use in remote computer management. .DESCRIPTION Configures a connection object for use in remote computer management. This function will either create new records for c...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Write-DbaDataTable.ps1
Write-DbaDataTable.ps1
Function Write-DbaDataTable { <# .SYNOPSIS Writes data to a SQL Server Table .DESCRIPTION Writes a .NET DataTable to a SQL Server table using SQL Bulk Copy .PARAMETER SqlServer The SQL Server that you're connecting to. .PARAMETER SqlCredential Credential object used to connect to the SQL Server as a dif...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlDatabaseMail.ps1
Copy-SqlDatabaseMail.ps1
function Copy-SqlDatabaseMail { <# .SYNOPSIS Migrates Mail Profiles, Accounts, Mail Servers and Mail Server Configs from one SQL Server to another. .DESCRIPTION By default, all mail configurations for Profiles, Accounts, Mail Servers and Configs are copied. The -Profiles parameter is autopopulated for com...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlServerAgent.ps1
Copy-SqlServerAgent.ps1
Function Copy-SqlServerAgent { <# .SYNOPSIS Copies *all* ProxyAccounts, JobSchedule, SharedSchedules, AlertSystem, JobCategories, OperatorCategories AlertCategories, Alerts, TargetServerGroups, TargetServers, Operators, Jobs, Mail and general SQL Agent settings from one SQL Server Agent to another. $sourceser...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Find-DbaStoredProcedure.ps1
Find-DbaStoredProcedure.ps1
Function Find-DbaStoredProcedure { <# .SYNOPSIS Returns all stored procedures that contain a specific case-insensitive string or regex pattern. .DESCRIPTION This function can either run against specific databases or all databases searching all user or user and system stored procedures. .PARAMETER SqlInstanc...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Measure-DbaBackupThroughput.ps1
Measure-DbaBackupThroughput.ps1
function Measure-DbaBackupThroughput { <# .SYNOPSIS Determines how quickly SQL Server is backing up databases to media. .DESCRIPTION Returns backup history details for some or all databases on a SQL Server. Output looks like this SqlInstance : sql2016 Database : SharePoint_Config AvgThroughput...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Repair-SqlOrphanUser.ps1
Repair-SqlOrphanUser.ps1
Function Repair-SqlOrphanUser { <# .SYNOPSIS Find orphan users with existing login and remap. .DESCRIPTION An orphan user is defined by a user that does not have their matching login. (Login property = "") If the matching login exists it must be: Enabled Not a system object Not locked Ha...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Reset-SqlAdmin.ps1
Reset-SqlAdmin.ps1
Function Reset-SqlAdmin { <# .SYNOPSIS This function will allow administrators to regain access to SQL Servers in the event that passwords or access was lost. Supports SQL Server 2005 and above. Windows administrator access is required. .DESCRIPTION This function allows administrators to regain access to l...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/New-DbaCmConnection.ps1
New-DbaCmConnection.ps1
function New-DbaCmConnection { <# .SYNOPSIS Generates a connection object for use in remote computer management. .DESCRIPTION Generates a connection object for use in remote computer management. Those objects are used for the purpose of cim/wmi qu...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlLogin.ps1
Copy-SqlLogin.ps1
Function Copy-SqlLogin { <# .SYNOPSIS Migrates logins from source to destination SQL Servers. Supports SQL Server versions 2000 and above. .DESCRIPTION SQL Server 2000: Migrates logins with SIDs, passwords, server roles and database roles. SQL Server 2005 & above: Migrates logins with SIDs, passwords, defaul...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Start-SqlMigration.ps1
Start-SqlMigration.ps1
Function Start-SqlMigration { <# .SYNOPSIS Migrates SQL Server *ALL* databases, logins, database mail profies/accounts, credentials, SQL Agent objects, linked servers, Central Management Server objects, server configuration settings (sp_configure), user objects in systems databases, system triggers and backup ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaIdentityUsage.ps1
Test-DbaIdentityUsage.ps1
Function Test-DbaIdentityUsage { <# .SYNOPSIS Displays information relating to IDENTITY seed usage. Works on SQL Server 2008 and above. .DESCRIPTION IDENTITY seeds have max values based off of their data type. This module will locate identity columns and report the seed usage. .PARAMETER SqlInstance Al...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaDatabase.ps1
Get-DbaDatabase.ps1
function Get-DbaDatabase { <# .SYNOPSIS Gets SQL Database information for each database that is present in the target instance(s) of SQL Server. .DESCRIPTION The Get-DbaDatabase command gets SQL database information for each database that is present in the target instance(s) of SQL Server. If the name of ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Set-DbaSpConfigure.ps1
Set-DbaSpConfigure.ps1
FUNCTION Set-DbaSpConfigure { <# .SYNOPSIS Changes the server level system configuration (sys.configuration/sp_configure) value for a given configuration .DESCRIPTION This function changes the configured value for sp_configure settings. If the setting is dynamic this setting will be used, otherwise the user wil...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaStartupParameter.ps1
Get-DbaStartupParameter.ps1
Function Get-DbaStartupParameter { <# .SYNOPSIS Displays values for a detailed list of SQL Server Startup Parameters. .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. This comm...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Export-DbaCertificate.ps1
Export-DbaCertificate.ps1
Function Export-DbaCertificate { <# .SYNOPSIS Exports certificates from SQL Server using smo .DESCRIPTION Exports certificates from SQL Server using smo and outputs the .cer and .pvk files along with a .sql file to create the certificate. .PARAMETER SqlServer The SQL Server that you're connecting to. .P...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaLinkedServer.ps1
Get-DbaLinkedServer.ps1
function Get-DbaLinkedServer { <# .SYNOPSIS Gets all linked servers and summary of information from the sql servers listed .DESCRIPTION Retrieves information about each linked server on the instance .PARAMETER SqlInstance SQL Server name or SMO object representing the SQL Server to connect to. This ca...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Remove-DbaAgentJobStep.ps1
Remove-DbaAgentJobStep.ps1
function Remove-DbaAgentJobStep { <# .SYNOPSIS Remove-DbaAgentJobStep removes a job step. .DESCRIPTION Remove-DbaAgentJobStep removes a a job step in the SQL Server Agent. .PARAMETER SqlInstance SQL Server instance. You must have sysadmin access and server version must be SQL Server version 2000 or grea...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaTable.ps1
Get-DbaTable.ps1
function Get-DbaTable { <# .SYNOPSIS Returns a summary of information on the tables .DESCRIPTION Shows table information around table row and data sizes and if it has any table type information. .PARAMETER SqlInstance SQLServer name or SMO object representing the SQL Server to connect to. This can be a collec...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaCmConnection.ps1
Test-DbaCmConnection.ps1
function Test-DbaCmConnection { <# .SYNOPSIS Tests over which paths a computer can be managed. .DESCRIPTION Tests over which paths a computer can be managed. This function tries out the connectivity for: - Cim over WinRM...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaClusterActiveNode.ps1
Get-DbaClusterActiveNode.ps1
Function Get-DbaClusterActiveNode { <# .SYNOPSIS Returns the active node of a SQL Cluster .DESCRIPTION Returns a string of the current owner. If -Detailed is specified, a datatable of details will be returned. .PARAMETER SqlServer The SQL Cluster .PARAMETER SqlCredential If you want to use alternative...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-SqlServerKey.ps1
Get-SqlServerKey.ps1
Function Get-SqlServerKey { <# .SYNOPSIS Gets SQL Server Product Keys from local on destination SQL Servers. Works with SQL Server 2005-2014 .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 k...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Uninstall-DbaWatchUpdate.ps1
Uninstall-DbaWatchUpdate.ps1
Function Uninstall-DbaWatchUpdate { <# .SYNOPSIS Removes the scheduled task created for Watch-DbaUpdate by Install-DbaWatchUpdate so that notifications no longer pop up. .DESCRIPTION Removes the scheduled task created for Watch-DbaUpdate by Install-DbaWatchUpdate so that notifications no longer pop up. .N...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Set-DbaConfig.ps1
Set-DbaConfig.ps1
function Set-DbaConfig { <# .SYNOPSIS Sets configuration entries. .DESCRIPTION This function creates or changes configuration values. These are used in a larger framework to provide dynamic configuration information outside the PowerShell variable system. .PARAMETER Name Name of the ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlReplication.ps1
Copy-SqlReplication.ps1
<# #$transfer.Options.ContinueScriptingOnError # replace names # Load SMO, create server object, test connection, disconnect [void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") [void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.RMO") Microsoft.SqlServer.Rmo $server = ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaRestoreHistory.ps1
Get-DbaRestoreHistory.ps1
Function Get-DbaRestoreHistory { <# .SYNOPSIS Returns restore history details for databases on a SQL Server .DESCRIPTION By default, this command will return the server name, database, username, restore type, date, from file and to files. Thanks to https://www.mssqltips.com/sqlservertip/1724/when-was-the-la...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlPolicyManagement.ps1
Copy-SqlPolicyManagement.ps1
Function Copy-SqlPolicyManagement { <# .SYNOPSIS Migrates SQL Policy Based Management Objects, including both policies and conditions. .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. The -Policies and ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlSysDbUserObjects.ps1
Copy-SqlSysDbUserObjects.ps1
Function Copy-SqlSysDbUserObjects { <# .SYNOPSIS Imports *all* user objects found in source SQL Server's master, msdb and model databases to the destination. .DESCRIPTION Imports *all* user objects found in source SQL Server's master, msdb and model databases to the destination. This is useful because many DBA'...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Export-SqlSpConfigure.ps1
Export-SqlSpConfigure.ps1
Function Export-SqlSpConfigure { <# .SYNOPSIS Exports advanced sp_configure global configuration options to sql file. .DESCRIPTION Exports advanced sp_configure global configuration options to sql file. .PARAMETER SqlCredential Allows you to login to servers using SQL Logins as opposed to Windows Auth/Inte...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaServerAuditSpecification.ps1
Get-DbaServerAuditSpecification.ps1
FUNCTION Get-DbaServerAuditSpecification { <# .SYNOPSIS Gets SQL Security Audit Specification information for each instance(s) of SQL Server. .DESCRIPTION The Get-DbaServerAuditSpecification command gets SQL Security Audit Specification information for each instance(s) of SQL Server. .PARAMETER SqlInstance...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaDiskSpace.ps1
Get-DbaDiskSpace.ps1
Function Get-DbaDiskSpace { <# .SYNOPSIS Displays Disk information for all local drives on a server .DESCRIPTION Returns a custom object with Server name, name of disk, label of disk, total size, free size, percent free, block size and filesystem. By default, this funtion only shows drives of type 2 and 3 (r...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaDatabaseAssembly.ps1
Get-DbaDatabaseAssembly.ps1
FUNCTION Get-DbaDatabaseAssembly { <# .SYNOPSIS Gets SQL Database Assembly information for each instance(s) of SQL Server. .DESCRIPTION The Get-DbaDatabaseAssembly command gets SQL Database Assembly information for each instance(s) of SQL Server. .PARAMETER SqlInstance SQL Server name or SMO object repres...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-DbaQueryStoreConfig.ps1
Copy-DbaQueryStoreConfig.ps1
Function Copy-DbaQueryStoreConfig { <# .SYNOPSIS Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases. .DESCRIPTION Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases. .PARAMETER Source ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Repair-DbaServerName.ps1
Repair-DbaServerName.ps1
Function Repair-DbaServerName { <# .SYNOPSIS Renames @@SERVERNAME to match with the Windows name. .DESCRIPTION When a SQL Server's host OS is renamed, the SQL Server should be as well. This helps with Availability Groups and Kerberos. This command renames @@SERVERNAME to match with the Windows name. The new...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaClientProtocol.ps1
Get-DbaClientProtocol.ps1
Function Get-DbaClientProtocol { <# .SYNOPSIS Gets the SQL Server related client protocols on a computer. .DESCRIPTION Gets the SQL Server related client protocols on one or more computers. Requires Local Admin rights on destination computer(s). The client protocols can be enabled a...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/New-DbaAgentJobStep.ps1
New-DbaAgentJobStep.ps1
function New-DbaAgentJobStep { <# .SYNOPSIS New-DbaAgentJobStep creates a new job step for a job .DESCRIPTION New-DbaAgentJobStep creates a new job in the SQL Server Agent for a specific job .PARAMETER SqlInstance SQL Server instance. You must have sysadmin access and server version must be SQL Server v...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Remove-DbaAgentSchedule.ps1
Remove-DbaAgentSchedule.ps1
function Remove-DbaAgentSchedule { <# .SYNOPSIS Remove-DbaAgentJobSchedule removes a job schedule. .DESCRIPTION Remove-DbaAgentJobSchedule removes a a job in the SQL Server Agent. .PARAMETER SqlInstance SQL Server instance. You must have sysadmin access and server version must be SQL Server version 20...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaLinkedServerConnection.ps1
Test-DbaLinkedServerConnection.ps1
function Test-DbaLinkedServerConnection { <# .SYNOPSIS Test all linked servers from the sql servers passed .DESCRIPTION Test each linked server on the instance .PARAMETER SqlInstance The SQL Server that you're connecting to. .PARAMETER SqlCredential Credential object used to connect to the SQL Server as...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaSqlService.ps1
Get-DbaSqlService.ps1
Function Get-DbaSqlService { <# .SYNOPSIS Gets the SQL Server related services on a computer. .DESCRIPTION Gets the SQL Server related services on one or more computers. Requires Local Admin rights on destination computer(s). .PARAMETER ComputerName The SQL Server (or server ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaTcpPort.ps1
Get-DbaTcpPort.ps1
Function Get-DbaTcpPort { <# .SYNOPSIS Returns the TCP port used by the specified SQL Server. .DESCRIPTION By default, this command returns just the TCP port used by the specified SQL Server. If -Detailed is specified, server name, IPAddress (ipv4 and ipv6), port number and if the port assignment is stati...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Export-DbaScript.ps1
Export-DbaScript.ps1
Function Export-DbaScript { <# .SYNOPSIS Exports scripts from SQL Management Objects (SMO) .DESCRIPTION Exports scripts from SQL Management Objects .PARAMETER InputObject A SQL Managment Object such as the one returned from Get-DbaLogin .PARAMETER Path The output filename and location. If n...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaLogin.ps1
Get-DbaLogin.ps1
Function Get-DbaLogin { <# .SYNOPSIS Function to get an SMO login object of the logins for a given SQL Instance. Takes a server object from the pipe .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. .PARAM...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Import-SqlSpConfigure.ps1
Import-SqlSpConfigure.ps1
Function Import-SqlSpConfigure { <# .SYNOPSIS Updates sp_configure settings on destination server. .DESCRIPTION Updates sp_configure settings on destination server. .PARAMETER Source Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2000 or greater. .PARAMETE...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaConfig.ps1
Get-DbaConfig.ps1
function Get-DbaConfig { <# .SYNOPSIS Retrieves configuration elements by name. .DESCRIPTION Retrieves configuration elements by name. Can be used to search the existing configuration list. .PARAMETER Name Default: "*" The name of the configuration element(s) to retrieve. May...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlSsisCatalog.ps1
Copy-SqlSsisCatalog.ps1
Function Copy-SqlSsisCatalog { <# .SYNOPSIS Copy-SqlSsisCatalog migrates Folders, SSIS projects, and environments from one SQL Server to another. .DESCRIPTION By default, all folders, projects, and environments are copied. The -Project parameter can be specified to copy only one project, if desired. The pa...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Set-DbaStartupParameter.ps1
Set-DbaStartupParameter.ps1
function Set-DbaStartupParameter { <# .SYNOPSIS Sets the Startup Parameters for a SQL Server instance .DESCRIPTION Modifies the startup parameters for a specified SQL Server SqlInstance For full details of what each parameter does, please refer to this MSDN article - https://msdn.microsoft.com/en-us/library/m...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaEstimatedCompletionTime.ps1
Get-DbaEstimatedCompletionTime.ps1
Function Get-DbaEstimatedCompletionTime { <# .SYNOPSIS Gets execution and estimated completion time information for queries .DESCRIPTION Gets execution and estimated completion time information for queries Percent complete will show for the following commands ALTER INDEX REORGANIZE AUTO_SHRINK option w...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlAgentCategory.ps1
Copy-SqlAgentCategory.ps1
Function Copy-SqlAgentCategory { <# .SYNOPSIS Copy-SqlAgentCategory migrates SQL Agent categories from one SQL Server to another. This is similar to sp_add_category. https://msdn.microsoft.com/en-us/library/ms181597.aspx .DESCRIPTION By default, all SQL Agent categories for Jobs, Operators and Alerts are co...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlExtendedEvent.ps1
Copy-SqlExtendedEvent.ps1
Function Copy-SqlExtendedEvent { <# .SYNOPSIS Migrates SQL Extended Event Sessions except the two default sessions, AlwaysOn_health and system_health. .DESCRIPTION By default, all non-system extended events are migrated. If the event already exists on the destination, it will be skipped unless -Force is used. ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaSqlBuildReference.ps1
Get-DbaSqlBuildReference.ps1
Function Get-DbaSqlBuildReference { <# .SYNOPSIS Returns SQL Server Build infos on a SQL instance .DESCRIPTION Returns info about the specific build of a SQL instance, including the SP, the CU and the reference KB, wherever possible. It also includes End Of Support dates as specified on Microsoft Lifecycle Pol...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Backup-DbaDatabase.ps1
Backup-DbaDatabase.ps1
Function Backup-DbaDatabase { <# .SYNOPSIS Backup one or more SQL Sever databases from a SQL Server SqlInstance .DESCRIPTION Performs a backup of a specified type of 1 or more databases on a SQL Server Instance. These backups may be Full, Differential or Transaction log backups .PARAMETER SqlInstance The S...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaAgentOperator.ps1
Get-DbaAgentOperator.ps1
FUNCTION Get-DbaAgentOperator { <# .SYNOPSIS Returns all SQL Agent operators on a SQL Server Agent. .DESCRIPTION This function returns SQL Agent operators. .PARAMETER SqlInstance SQLServer name or SMO object representing the SQL Server to connect to. This can be a collection and receive pipeline inp...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlSharedSchedule.ps1
Copy-SqlSharedSchedule.ps1
Function Copy-SqlSharedSchedule { <# .SYNOPSIS Copy-SqlSharedSchedule migrates shared job schedules from one SQL Server to another. .DESCRIPTION By default, all shared job schedules are copied. The -SharedSchedules parameter is autopopulated for command-line completion and can be used to copy only specific sh...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Restore-SqlBackupFromDirectory.ps1
Restore-SqlBackupFromDirectory.ps1
Function Restore-SqlBackupFromDirectory { <# .SYNOPSIS Restores SQL Server databases from the backup directory structure created by Ola Hallengren's database maintenance scripts. Different structures coming soon. .DESCRIPTION Many SQL Server database administrators use Ola Hallengren's SQL Server Maintenance...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-SqlPath.ps1
Test-SqlPath.ps1
Function Test-SqlPath { <# .SYNOPSIS Tests if file or directory exists from the perspective of the SQL Server service account .DESCRIPTION Uses master.dbo.xp_fileexist to determine if a file or directory exists .PARAMETER SqlServer The SQL Server you want to run the test on. .PARAMETER Path The Path to ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Restore-DbaFromDatabaseSnapshot.ps1
Restore-DbaFromDatabaseSnapshot.ps1
Function Restore-DbaFromDatabaseSnapshot { <# .SYNOPSIS Restores databases from snapshots .DESCRIPTION Restores the database from the snapshot, discarding every modification made to the database NB: Restoring to a snapshot will result in every other snapshot of the same database to be dropped It also fixes so...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaAvailabilityGroup.ps1
Get-DbaAvailabilityGroup.ps1
Function Get-DbaAvailabilityGroup { <# .SYNOPSIS Outputs information of the Availabilty Group(s) found on the server. .DESCRIPTION By default outputs a small set of information around the Availability Group found on the server. .PARAMETER SqlServer The SQL Server instance. You must have sysadmin access and...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Invoke-DbaDatabaseShrink.ps1
Invoke-DbaDatabaseShrink.ps1
Function Invoke-DbaDatabaseShrink { <# .SYNOPSIS Shrinks all files in a database. This is a command that should rarely be used. - Shrinks can cause severe index fragmentation (to the tune of 99%) - Shrinks can cause massive growth in the database's transaction log - Shrinks can require a lot of time and system...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Import-DbaCertificate.ps1
Import-DbaCertificate.ps1
Function Import-DbaCertificate { <# .SYNOPSIS Imports certificates from .cer files using smo. .DESCRIPTION Imports certificates from.cer files using smo. .PARAMETER SqlServer The SQL Server to create the certificates on. .PARAMETER Path The Path the contains the certificate and private key files. .PA...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Watch-SqlDbLogin.ps1
Watch-SqlDbLogin.ps1
Function Watch-SqlDbLogin { <# .SYNOPSIS Tracks SQL Server logins: which host they came from, what database they're using, and what program is being used to log in. .DESCRIPTION Watch-SqlDbLogin uses SQL Server process enumeration to track logins in a SQL Server table. This is helpful when you need to migr...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-SqlTempDBConfiguration.ps1
Test-SqlTempDBConfiguration.ps1
Function Test-SqlTempDbConfiguration { <# .SYNOPSIS Evaluates tempdb against several rules to match best practices. .DESCRIPTION Evaluates tempdb aganst a set of rules to match best practices. The rules are: TF 1118 enabled - Is Trace Flag 1118 enabled (See KB328551). File Count - Does the count of data files...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaVirtualLogFile.ps1
Test-DbaVirtualLogFile.ps1
function Test-DbaVirtualLogFile { <# .SYNOPSIS Returns database virtual log file information for database files on a SQL instance. .DESCRIPTION As you may already know, having a TLog file with too many VLFs can hurt database performance. Too many virtual log files can cause transaction log backups to slow do...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaSpn.ps1
Test-DbaSpn.ps1
#ValidationTags#FlowControl,Pipeline# Function Test-DbaSpn { <# .SYNOPSIS Test-DbaSpn will determine what SPNs *should* be set for a given server (and any instances of SQL running on it) and return whether the SPNs are set or not. .DESCRIPTION This function is designed to take in a server name(s) and attempt...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaAgentJobOutputFile.ps1
Get-DbaAgentJobOutputFile.ps1
Function Get-DbaAgentJobOutputFile { <# .Synopsis Returns the Output File for each step of one or many agent job with the Job Names provided dynamically if required for one or more SQL Instances .DESCRIPTION This function returns for one or more SQL Instances the output file value for each step of on...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-SqlNetworkLatency.ps1
Test-SqlNetworkLatency.ps1
Function Test-SqlNetworkLatency { <# .SYNOPSIS Tests how long a query takes to return from SQL Server .DESCRIPTION This function is intended to help measure SQL Server network latency by establishing a connection and making a simple query. This is a better alternative than ping because it actually creates ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Set-DbaMaxDop.ps1
Set-DbaMaxDop.ps1
Function Set-DbaMaxDop { <# .SYNOPSIS Sets SQL Server max dop then displays information relating to SQL Server Max DOP configuration settings. Works on SQL Server 2005-2016. .DESCRIPTION Uses the Test-DbaMaxDop command to get the recommended value if -MaxDop parameter is not specified. These are just gene...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaLastGoodCheckDb.ps1
Get-DbaLastGoodCheckDb.ps1
Function Get-DbaLastGoodCheckDb { <# .SYNOPSIS Get date/time for last known good DBCC CHECKDB .DESCRIPTION Retrieves and compares the date/time for the last known good DBCC CHECKDB, as well as the creation date/time for the database. This function supports SQL Server 2005+ Please note that this script uses...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlJob.ps1
Copy-SqlJob.ps1
function Copy-SqlJob { <# .SYNOPSIS Copy-SqlJob migrates jobs from one SQL Server to another. .DESCRIPTION By default, all jobs are copied. The -Jobs parameter is autopopulated for command-line completion and can be used to copy only specific jobs. If the job already exists on the destination, it will be ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaXEventsSession.ps1
Get-DbaXEventsSession.ps1
function Get-DbaXEventsSession { <# .SYNOPSIS Get a list of Extended Events Sessions .DESCRIPTION Retrieves a list of Extended Events Sessions .PARAMETER SqlInstance The SQL Instances that you're connecting to. .PARAMETER SqlCredential Credential object used to connect to the SQL Server as a different ...
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlCredential.ps1
Copy-SqlCredential.ps1
Function Copy-SqlCredential { <# .SYNOPSIS Copy-SqlCredential migrates SQL Server Credentials from one SQL Server to another, while maintaining Credential passwords. .DESCRIPTION By using password decryption techniques provided by Antti Rantasaari (NetSPI, 2014), this script migrates SQL Server Credentials f...