full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Get-DbaAgentOperator.Tests.ps1 | Get-DbaAgentOperator.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Verbos... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/InModule.Help.Exceptions.ps1 | InModule.Help.Exceptions.ps1 | $global:FunctionHelpTestExceptions = @(
"TabExpansion2"
)
|
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Test-DbaDatabaseOwner.Tests.ps1 | Test-DbaDatabaseOwner.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Verbos... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Stop-Function.Tests.ps1 | Stop-Function.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if (-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{ }
if ($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Ver... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Repair-SqlOrphanUser.Tests.ps1 | Repair-SqlOrphanUser.Tests.ps1 | ## This is a template file for the ScriptAnalyser tests for each command.
## It Should be named $CommandName.Tests.ps1 the capital T is important as is the . !!
## The help will be analysed via the inModuleHelp.Tests.ps1 file so you dont need to worry about that.
## Add you own functional tests to the end of this fi... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Get-DbaSqlBuildReference.Tests.ps1 | Get-DbaSqlBuildReference.Tests.ps1 | ## Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot) {
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master") {
$Verbose.add("Verbose"... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Get-DbaAgentAlert.Tests.ps1 | Get-DbaAgentAlert.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Verbos... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Get-DirectoryRestoreFile.Tests.ps1 | Get-DirectoryRestoreFile.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Verbos... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Test-DbaMaxMemory.Tests.ps1 | Test-DbaMaxMemory.Tests.ps1 | ## Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot) {
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master") {
$Verbose.add("Verbose", ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Out-DbaDataTable.Tests.ps1 | Out-DbaDataTable.Tests.ps1 |
Describe "Testing data table output when using a complex object" {
$obj = New-Object -TypeName psobject -Property @{
guid = [system.guid]'32ccd4c4-282a-4c0d-997c-7b5deb97f9e0'
timespan = New-TimeSpan -Start 2016-10-30 -End 2017-04-30
datetime = Get-Date -Year 2016 -Month 10 -Day 30 -Ho... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Set-DbaAgentJobOutputFile.Tests.ps1 | Set-DbaAgentJobOutputFile.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Verbos... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/Get-XpDirTreeRestoreFile.Tests.ps1 | Get-XpDirTreeRestoreFile.Tests.ps1 | #Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/
if(-not $PSScriptRoot)
{
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$Verbose = @{}
if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master")
{
$Verbose.add("Verbos... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/InModule.Help.Tests.ps1 | InModule.Help.Tests.ps1 | <#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119
Created on: 4/12/2016 1:11 PM
Created by: June Blender
Organization: SAPIEN Technologies, Inc
Filename: *.Help.Tests.ps1
=======... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/tests/appveyor.pester.ps1 | appveyor.pester.ps1 | # This script will invoke pester tests
# It should invoke on PowerShell v2 and later
# We serialize XML results and pull them in appveyor.yml
#If Finalize is specified, we collect XML output, upload tests, and indicate build errors
param([switch]$Finalize)
#Initialize some variables, move to the project root
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-FilteredRestoreFile.ps1 | Get-FilteredRestoreFile.ps1 | function Get-FilteredRestoreFile
{
<#
.SYNOPSIS
Internal Function to Filter a set of SQL Server backup files
.DESCRIPTION
Takes an array of FileSystem Objects and then filters them down by date to get a potential Restore set
First step is to pass them to a SQLInstance to be parsed with Read-DBABackupHeader
Th... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-OfflineSqlFileStructure.ps1 | Get-OfflineSqlFileStructure.ps1 | Function Get-OfflineSqlFileStructure
{
<#
.SYNOPSIS
Internal function. Returns dictionary object that contains file structures for SQL databases.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[ValidateNotNullOrEmpty()]
[object]$SqlServer,
[Parameter(Mandatory = $true, ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Restore-DBFromFilteredArray.ps1 | Restore-DBFromFilteredArray.ps1 | Function Restore-DBFromFilteredArray
{
<#
.SYNOPSIS
Internal function. Restores .bak file to SQL database. Creates db if it doesn't exist. $filestructure is
a custom object that contains logical and physical file locations.
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param (
[parameter(Mand... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Select-DefaultView.ps1 | Select-DefaultView.ps1 | Function Select-DefaultView
{
<#
This command enables us to send full on objects to the pipeline without the user seeing it
See it in action in Get-DbaSnapshot and Remove-DbaDatabaseSnapshot
a lot of this is from boe, thanks boe!
https://learn-powershell.net/2013/08/03/quick-hits-set-the-default-p... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-OlaHRestoreFile.ps1 | Get-OlaHRestoreFile.ps1 | function Get-OlaHRestoreFile
{
<#
.SYNOPSIS
Internal Function to get SQL Server backfiles from a specified folder that's formatted according to Ola Hallengreen's scripts.
.DESCRIPTION
Takes path, checks for validity. Scans for usual backup file
#>
[CmdletBinding()]
Param (
[parameter(Mandatory = $true,... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Connect-AsServer.ps1 | Connect-AsServer.ps1 | Function Connect-AsServer
{
<#
.SYNOPSIS
Internal function that creates SMO server object. Input can be text or SMO.Server.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[object]$AsServer,
[switch]$ParameterConnection
)
if ($AsServer.GetType() -eq [Microsoft.AnalysisServices.Se... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Rename-LogicalFile.ps1 | Rename-LogicalFile.ps1 | Function Rename-LogicalFile
{
<#
.SYNOPSIS
Internal function. Renames logical files.
Can either use prefix with -Prefix, ALL files log and data will be prefixed
Or pass in a mapping hash like:
$mapping = @{
'File1'='NewNamefile1'
'File3'='somethingelse'
}
Can select ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Show-Notification.ps1 | Show-Notification.ps1 | function Show-Notification (
$title = "dbatools update",
$text = "Version $galleryversion is now available"
)
{
# ensure the dbatools 'app' exists in registry so that it doesn't immediately disappear from Action Center
$regpath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings'
$appi... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Update-SqlDbOwner.ps1 | Update-SqlDbOwner.ps1 | Function Update-SqlDbOwner
{
<#
.SYNOPSIS
Internal function. Updates specified database dbowner.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[object]$source,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[object]$destination,
[string]$... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-SqlSaLogin.ps1 | Get-SqlSaLogin.ps1 | Function Get-SqlSaLogin
{
<#
.SYNOPSIS
Internal function. Gets the name of the sa login in case someone changed it.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.PSCredential]$SqlCredential
)
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Invoke-SmoCheck.ps1 | Invoke-SmoCheck.ps1 | Function Invoke-SmoCheck
{
<#
.SYNOPSIS
Checks for PowerShell SMO version vs SQL Server's SMO version.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[object]$SqlServer
)
if ($script:smocheck -ne $true)
{
$script:smocheck = $true
$smo = (([AppDomain]::CurrentDomain.GetAss... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Tag-Command.ps1 | Tag-Command.ps1 | function Invoke-TagCommand ([string]$Tag, [string]$Keyword)
{
<#
.SYNOPSIS
An internal command, feel free to ignore.
.EXAMPLE
Tag-Command -Tag Restore -Keyword Restore
Tag-Command -Tag Backup -Keyword Backup
Tag-Command -Tag Orphan -Keyword Orphan
Tag-Command -Tag DisasterRecovery -Keyword Attach
Ta... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Write-Exception.ps1 | Write-Exception.ps1 | Function Write-Exception
{
<#
.SYNOPSIS
Internal function. Writes exception to disk (my docs\dbatools-exceptions.txt) for later analysis.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[object]$e
)
$docs = [Environment]::GetFolderPath("mydocuments")
$errorlog = "$docs\dbatools-excep... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Resolve-NetBiosName.ps1 | Resolve-NetBiosName.ps1 | Function Resolve-NetBiosName
{
<#
.SYNOPSIS
Internal function. Takes a best guess at the NetBIOS name of a server.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.PSCredential]$SqlCredential
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Update-SqlDbReadOnly.ps1 | Update-SqlDbReadOnly.ps1 | Function Update-SqlDbReadOnly
{
<#
.SYNOPSIS
Internal function. Updates specified database to read-only or read-write. Necessary because SMO doesn't appear to support NO_WAIT.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Alias("ServerInstance", "SqlInstance")... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Invoke-ManagedComputerCommand.ps1 | Invoke-ManagedComputerCommand.ps1 | Function Invoke-ManagedComputerCommand
{
<#
.SYNOPSIS
Internal command
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ComputerName")]
[object]$Server,
[System.Management.Automation.PSCredential]$Credential,
[Parameter(Mandatory = $true)]
[scriptblock]$ScriptBlock,
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Resolve-IpAddress.ps1 | Resolve-IpAddress.ps1 | Function Resolve-IpAddress
{
# Uses the Beard's method to resolve IPs
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ServerInstance", "SqlInstance","ComputerName","SqlServer")]
[object]$Server
)
if ($Server.GetType() -eq [Microsoft.SqlServer.Management.Smo.Server])
{
return... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Convert-DbVersionToSqlVersion.ps1 | Convert-DbVersionToSqlVersion.ps1 | Function Convert-DbVersionToSqlVersion
{
param (
[string]$dbversion
)
$dbversion = switch ($dbversion)
{
856 { "SQL Server vNext CTP1" }
852 { "SQL Server 2016" }
829 { "SQL Server 2016 Prerelease" }
782 { "SQL Server 2014" }
706 { "SQL Server 2012" }
684 { "SQL Server 2012 CTP1" }
6... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Start-DbccCheck.ps1 | Start-DbccCheck.ps1 | Function Start-DbccCheck
{
[CmdletBinding(SupportsShouldProcess = $true)]
param (
[object]$server,
[string]$dbname,
[switch]$table
)
$servername = $server.name
if ($Pscmdlet.ShouldProcess($sourceserver, "Running dbcc check on $dbname on $servername"))
{
try
{
if ($table)
{
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-DbaRestoreVersion.ps1 | Test-DbaRestoreVersion.ps1 | function Test-DbaRestoreVersion
{
<#
.SYNOPSIS
Checks that the restore files are from a version of SQL Server that can be restored on the target version
.DESCRIPTION
Finds the anchoring Full backup (or multiple if it's a striped set).
Then filters to ensure that all the backups are from that anchor point (Las... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Restore-Database.ps1 | Restore-Database.ps1 | Function Restore-Database
{
<#
.SYNOPSIS
Internal function. Restores .bak file to SQL database. Creates db if it doesn't exist. $filestructure is
a custom object that contains logical and physical file locations.
#>
[CmdletBinding()]
param (
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServe... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-FunctionInterrupt.ps1 | Test-FunctionInterrupt.ps1 | function Test-FunctionInterrupt
{
<#
.SYNOPSIS
Internal tool, used to gracefully interrupt a function.
.DESCRIPTION
This helper function is designed to work in tandem with Stop-Function.
When gracefully terminating a function, there is a major iss... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-HostOSLinux.ps1 | Test-HostOSLinux.ps1 | Function Test-HostOSLinux
{
param (
[object]$sqlserver,
[object]$sqlcredential
)
$server = Connect-SqlServer -SqlServer $sqlserver -SqlCredential $sqlcredential
$server.ConnectionContext.ExecuteScalar("SELECT @@VERSION") -match "Linux"
}
|
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-SqlLoginAccess.ps1 | Test-SqlLoginAccess.ps1 | Function Test-SqlLoginAccess
{
<#
.SYNOPSIS
Internal function. Ensures login has access on SQL Server.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.PSCredential]$S... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-SqlAgent.ps1 | Test-SqlAgent.ps1 | Function Test-SqlAgent
{
<#
.SYNOPSIS
Internal function. Checks to see if SQL Server Agent is running on a server.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.P... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-DirectoryRestoreFile.ps1 | Get-DirectoryRestoreFile.ps1 | function Get-DirectoryRestoreFile
{
<#
.SYNOPSIS
Internal Function to get SQL Server backfiles from a specified folder
.DESCRIPTION
Takes path, checks for validity. Scans for usual backup file
#>
[CmdletBinding()]
Param (
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string]$Path
)
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-SqlDefaultSpConfigure.ps1 | Get-SqlDefaultSpConfigure.ps1 | Function Get-SqlDefaultSpConfigure
{
<#
.SYNOPSIS
Internal function. Returns the default sp_configure options for a given version of SQL Server.
.NOTES
Server Configuration Options BOL (links subject to change):
SQL Server 2016 - https://technet.microsoft.com/en-us/library/ms189631(v=sql.130).aspx
SQL Server ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-SqlQueryComplete.ps1 | Test-SqlQueryComplete.ps1 | Function Test-SqlQueryComplete
{
param (
[Alias("SqlServer")]
[object]$server,
[string]$sql,
[switch]$checkpid
)
if ($checkpid)
{
$sqlpid = " and session_id = $sqlpid"
}
$sqlpid = $server.ConnectionContext.ProcessID
$sqlpid = " and session_id = $sqlpid"
$sql = $sql.Replace("'", "''... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/DynamicParams.ps1 | DynamicParams.ps1 | <#
These are all the functions for tab completion (auto-population of params)
To use, place this after params in a function
DynamicParam { if ($source) { return (Get-ParamSqlXyz -SqlServer $Source -SqlCredential $SourceSqlCredential) } }
#>
Function Get-ParamSqlServerConfigs
{
<#
.SYNOPSIS
Internal ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-SqlSa.ps1 | Test-SqlSa.ps1 | Function Test-SqlSa
{
<#
.SYNOPSIS
Internal function. Ensures sysadmin account access on SQL Server.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.PSCredential]$Sql... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Stop-Function.ps1 | Stop-Function.ps1 | function Stop-Function
{
<#
.SYNOPSIS
Function that interrupts a function.
.DESCRIPTION
Function that interrupts a function.
This function is a utility function used by other functions to reduce error catching overhead.
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-PSRemoting.ps1 | Test-PSRemoting.ps1 | #requires -version 3.0
Function Test-PSRemoting {
<#
Jeff Hicks
https://www.petri.com/test-network-connectivity-powershell-test-connection-cmdlet
#>
[cmdletbinding()]
Param(
[Parameter(Position=0,Mandatory,HelpMessage = "Enter a computername",ValueFromPipeline)]
[ValidateNotNullorEmpty()]
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-SaLoginName.ps1 | Get-SaLoginName.ps1 | Function Get-SaLoginName
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.PSCredential]$SqlCredential
)
$server = Connect-SqlServer -SqlServer $SqlServer -SqlCredential $SqlCredential
$sanam... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-DbaLsnChain.ps1 | Test-DbaLsnChain.ps1 | function Test-DbaLsnChain
{
<#
.SYNOPSIS
Checks that a filtered array from Get-FilteredRestore contains a restorabel chain of LSNs
.DESCRIPTION
Finds the anchoring Full backup (or multiple if it's a striped set).
Then filters to ensure that all the backups are from that anchor point (LastLSN) and that they're... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-ComputerTarget.ps1 | Test-ComputerTarget.ps1 | function Test-ComputerTarget
{
<#
.SYNOPSIS
Validates whether the input string can be legally used to target a computer.
.DESCRIPTION
Validates whether the input string can be legally used to target a computer.
It will consider:
- Nam... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Write-Message.ps1 | Write-Message.ps1 | function Write-Message
{
<#
.SYNOPSIS
This function acts as central information node for dbatools.
.DESCRIPTION
This function acts as central information node for dbatools.
Other functions hand off all their information output for processing to th... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Update-SqlPermissions.ps1 | Update-SqlPermissions.ps1 | Function Update-SqlPermissions
{
<#
.SYNOPSIS
Internal function. Updates permission sets, roles, database mappings on server and databases
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[object]$sourceserver,
[Parameter(Mandatory = $true)]
[Validat... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Register-DbaConfigHandler.ps1 | Register-DbaConfigHandler.ps1 | function Register-DbaConfigHandler
{
<#
.SYNOPSIS
Registers a configuration handler.
.DESCRIPTION
Registers a configuration handler.
Configuration handlers are used to validate and process new configuration settings before they are committed to th... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-DbaADObject.ps1 | Get-DbaADObject.ps1 | #ValidationTags#FlowControl,Pipeline#
Function Get-DbaADObject
{
<#
.SYNOPSIS
Get-DbaADObject tries to facilitate searching AD with dbatools, which ATM can't require AD cmdlets.
.DESCRIPTION
As working with multiple domains, forests, ldap filters, partitions, etc is quite hard to grasp, let's try to do "the ri... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-XpDirTreeRestoreFile.ps1 | Get-XpDirTreeRestoreFile.ps1 | function Get-XpDirTreeRestoreFile
{
<#
.SYNOPSIS
Internal Function to get SQL Server backfiles from a specified folder using xp_dirtree
.DESCRIPTION
Takes path, checks for validity. Scans for usual backup file
.PARAMETER Path
.PARAMETER
#>
[CmdletBinding()]
Param (
[parameter(Mandatory = $... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-SmoServerForDynamicParams.ps1 | Get-SmoServerForDynamicParams.ps1 | Function Get-SmoServerForDynamicParams
{
if ($fakeBoundParameter.length -eq 0) { return }
$sqlserver = $fakeBoundParameter['SqlServer']
$sqlcredential = $fakeBoundParameter['SqlCredential']
if ($sqlserver -eq $null)
{
$sqlserver = $fakeBoundParameter['sqlinstance']
}
if ($sqlserver -eq $null)
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-SqlDefaultPaths.ps1 | Get-SqlDefaultPaths.ps1 | Function Get-SqlDefaultPaths
{
<#
.SYNOPSIS
Internal function. Returns the default data and log paths for SQL Server. Needed because SMO's server.defaultpath is sometimes null.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Alias("ServerInstance", "SqlInstance"... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Connect-SqlServer.ps1 | Connect-SqlServer.ps1 | Function Connect-SqlServer {
<#
.SYNOPSIS
Internal function that creates SMO server object. Input can be text or SMO.Server.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[object[]]$SqlServer,
[System.Management.Automation.PSCredential]$SqlCredential,
[switch]$ParameterConnection,
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Remove-SqlDatabase.ps1 | Remove-SqlDatabase.ps1 | Function Remove-SqlDatabase
{
<#
.SYNOPSIS
Internal function. Uses SMO's KillDatabase to drop all user connections then drop a database. $server is
an SMO server object.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[Parame... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Invoke-DbaDiagnosticQueryScriptParser.ps1 | Invoke-DbaDiagnosticQueryScriptParser.ps1 | function Invoke-DbaDiagnosticQueryScriptParser
{
[CmdletBinding(DefaultParameterSetName="Default")]
Param(
[parameter(Mandatory = $true)]
[ValidateScript({Test-Path $_})]
[System.IO.FileInfo]$filename
)
$out = "Parsing file {0}"-f $filename
write-verbose -Message $out
$Parse... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Was-Bound.ps1 | Was-Bound.ps1 |
function Was-Bound
{
<#
.SYNOPSIS
Helperfunction that tests, whether a parameter was bound.
.DESCRIPTION
Helperfunction that tests, whether a parameter was bound.
.PARAMETER ParameterName
The name of the parameter that is test... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Test-DbaDeprecation.ps1 | Test-DbaDeprecation.ps1 | function Test-DbaDeprecation
{
<#
.SYNOPSIS
Tests whether a function or one of its parameters was called by a bad name.
.DESCRIPTION
Tests whether a function or one of its parameters was called by a bad name.
This allows giving deprecation warning... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Resolve-SqlIpAddress.ps1 | Resolve-SqlIpAddress.ps1 | Function Resolve-SqlIpAddress
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Alias("ServerInstance", "SqlInstance")]
[object]$SqlServer,
[System.Management.Automation.PSCredential]$SqlCredential
)
$server = Connect-SqlServer -SqlServer $SqlServer -SqlCredential $SqlCredential
$ser... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Get-SqlFileStructure.ps1 | Get-SqlFileStructure.ps1 | Function Get-SqlFileStructure
{
<#
.SYNOPSIS
Internal function. Returns custom object that contains file structures on destination paths (\\sqlserver\m$\mssql\etc\etc\file.mdf) for
source and destination servers.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[ValidateNotNullO... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/Join-AdminUnc.ps1 | Join-AdminUnc.ps1 | Function Join-AdminUnc
{
<#
.SYNOPSIS
Internal function. Parses a path to make it an admin UNC.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$servername,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$filepath
)
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/dynamicparams/tag.ps1 | tag.ps1 | $ScriptBlock = {
param (
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameter
)
# Hack till we get this working
function New-CompletionResult
{
param ([Parameter(Position = 0, ValueFromPipelineByPr... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/onetimenotifications.ps1 | onetimenotifications.ps1 | <#
This configuration script is for all notifications that shown once only.
Basically, if you want to show a message only once per session, make that dependent on a configuration flag.
Example:
Set-DbaConfig -Name 'MessageShown.DeprecatedAlias.FooBar' -Value $false -Default -Hidden
In your function, only displ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/userinteraction.ps1 | userinteraction.ps1 | <#
This configuration file is for all settings of how dbatools interacts with users
#>
# Configure the message levels at which the function will write either an info, a verbose message or debug message
# Used by the internal "Write-Message" function
Set-DbaConfig -Name 'message.maximuminfo' -Value 3 -Default -Di... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/computermanagement.handler.ps1 | computermanagement.handler.ps1 | #region ComputerManagement.Cache.Disable.All
$ScriptBlock = {
Param (
$Value
)
$Result = New-Object PSOBject -Property @{
Success = $True
Message = ""
}
if ($Value.GetType().FullName -ne "System.Boolean")
{
$Result.Message = "Not a Boolean: ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/computermanagement.ps1 | computermanagement.ps1 | <#
This is designed for all things that control how anything that caches acts
#>
# Sets the default timeout on bad connections
Set-DbaConfig -Name 'ComputerManagement.BadConnectionTimeout' -Value (New-TimeSpan -Minutes 15) -Default -DisableHandler -Description 'The timeout used on bad computer management connecti... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/paths.ps1 | paths.ps1 | <#
This is designed for all paths you need configurations for.
#>
# The default path where dbatools stores persistent data
Set-DbaConfig -Name 'Path.DbatoolsData' -Value "$env:AppData\PowerShell\dbatools" -Default -DisableHandler -Description "The path where dbatools stores persistent data on a per user basis."
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/paths.handler.ps1 | paths.handler.ps1 | #region Path.DbatoolsLogPath
$ScriptBlock = {
Param (
$Value
)
$Result = New-Object PSOBject -Property @{
Success = $True
Message = ""
}
try { [System.IO.Path]::GetFullPath($Value) }
catch
{
$Result.Message = "Illegal path: $Value"
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/logging.handler.ps1 | logging.handler.ps1 | #region Logging.MaxErrorCount
$ScriptBlock = {
Param (
$Value
)
$Result = New-Object PSOBject -Property @{
Success = $True
Message = ""
}
try { [int]$number = $Value }
catch
{
$Result.Message = "Not an integer: $Value"
$Result.... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/logging.ps1 | logging.ps1 | <#
This is for all configuration values regarding the logging system
NOTES:
- All these configurations should have a handler, as the logging system relies entirely on static fields for performance reasons
- If you want to change the default values, change them both here AND in the C# library
#>
Set-DbaConfig ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/formatting.handler.ps1 | formatting.handler.ps1 | #region Formatting.Date
$ScriptBlock = {
Param (
[string]
$Value
)
$Result = New-Object PSOBject -Property @{
Success = $True
Message = ""
}
if ([string]::IsNullOrEmpty($Value))
{
$Result.Message = "Is an empty format st... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/userinteraction.handler.ps1 | userinteraction.handler.ps1 | #region message.maximuminfo
$ScriptBlock = {
Param (
$Value
)
$Result = New-Object PSOBject -Property @{
Success = $True
Message = ""
}
try { [int]$number = $Value }
catch
{
$Result.Message = "Not an integer: $Value"
$Result.Su... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/formatting.ps1 | formatting.ps1 | # The default formatting style for dates
Set-DbaConfig -Name 'Formatting.Date' -Value "dd MMM yyyy" -Default -DisableHandler -Description "The default formatting of Dates"
# The default formatting style for full datetime objects
Set-DbaConfig -Name 'Formatting.DateTime' -Value "yyyy-MM-dd HH:mm:ss.fff" -Default -D... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/configurations/configuration.ps1 | configuration.ps1 | <#
#-------------------------#
# Warning Warning Warning #
#-------------------------#
This is the global configuration management file.
DO NOT EDIT THIS FILE!!!!!
Disobedience shall be answered by the wrath of Fred.
You've been warned.
;)
The purpose of this file is to manage the configuration system... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/internal/scripts/logfilescript.ps1 | logfilescript.ps1 | $scriptBlock = {
#region Helper Functions
function Clean-ErrorXml
{
[CmdletBinding()]
Param (
$Path
)
$totalLength = $Null
$files = Get-ChildItem -Path $Path.FullName -Filter "dbatools_$($pid)_error_*.xml" | Sort-Object LastWriteTime
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaPrivilege.ps1 | Get-DbaPrivilege.ps1 | function Get-DbaPrivilege
{
<#
.SYNOPSIS
Gets the users with local privileges on one or more computersr.
.DESCRIPTION
Gets the users with local privileges 'Lock Pages in Memory', 'Instant File Initialization', 'Logon as Batch' on one or more computers.
Requires Local Admin ri... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Stop-DbaProcess.ps1 | Stop-DbaProcess.ps1 | Function Stop-DbaProcess
{
<#
.SYNOPSIS
This command finds and kills SQL Server processes.
.DESCRIPTION
This command kills all spids associated with a spid, login, host, program or database.
If you are attempting to kill your own login sessions, the process performing the kills will be skipped.
.PARAMETE... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-DbaOptimizeForAdHoc.ps1 | Test-DbaOptimizeForAdHoc.ps1 | Function Test-DbaOptimizeForAdHoc
{
<#
.SYNOPSIS
Displays information relating to SQL Server Optimize for AdHoc Workloads setting. Works on SQL Server 2008-2016.
.DESCRIPTION
When this option is set, plan cache size is further reduced for single-use adhoc OLTP workload.
More info: https://msdn.microsoft.... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Read-DbaTransactionLog.ps1 | Read-DbaTransactionLog.ps1 | function Read-DbaTransactionLog
{
<#
.SYNOPSIS
Reads the live Transaction log from specied SQL Server Database
.DESCRIPTION
Using the fn_dblog function, the live transaction log is read and returned as a PowerShell object
This function returns the whole of the log. The information is presented in the form... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Remove-DbaAgentJob.ps1 | Remove-DbaAgentJob.ps1 | function Remove-DbaAgentJob {
<#
.SYNOPSIS
Remove-DbaAgentJob removes a job.
.DESCRIPTION
Remove-DbaAgentJob 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 2000 or greater.
.PARAMETER Sql... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Resolve-DbaNetworkName.ps1 | Resolve-DbaNetworkName.ps1 | Function Resolve-DbaNetworkName
{
<#
.SYNOPSIS
Returns information about the network connection of the target computer including NetBIOS name, IP Address, domain name and fully qualified domain name (FQDN).
.DESCRIPTION
Retrieves the IPAddress, ComputerName from one computer.
Th... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Test-SqlMigrationConstraint.ps1 | Test-SqlMigrationConstraint.ps1 | Function Test-SqlMigrationConstraint
{
<#
.SYNOPSIS
Show if you can migrate the database(s) between the servers.
.DESCRIPTION
When you want to migrate from a higher edition to a lower one there are some features that can't be used.
This function will validate if you have any of this features in use and will re... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Set-DbaPowerPlan.ps1 | Set-DbaPowerPlan.ps1 | Function Set-DbaPowerPlan
{
<#
.SYNOPSIS
Sets the SQL Server OS's Power Plan.
.DESCRIPTION
Sets the SQL Server OS's Power Plan. It defaults to High Performance which is Best Practice.
If your organization uses a custom power plan that is considered best practice, specify -CustomPowerPlan.
References:
... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaSpn.ps1 | Get-DbaSpn.ps1 | #ValidationTags#FlowControl,Pipeline#
function Get-DbaSpn
{
<#
.SYNOPSIS
Returns a list of set service principal names for a given computer/AD account
.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
a given active ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Export-DbaExecutionPlan.ps1 | Export-DbaExecutionPlan.ps1 | Function Export-DbaExecutionPlan
{
<#
.SYNOPSIS
Exports execution plans to disk.
.DESCRIPTION
Exports execution plans to disk. Can pipe from 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/ex... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlAuditSpecification.ps1 | Copy-SqlAuditSpecification.ps1 | Function Copy-SqlAuditSpecification
{
<#
.SYNOPSIS
Copy-SqlAuditSpecification migrates server audit specifications from one SQL Server to another.
.DESCRIPTION
By default, all audits are copied. The -ServerAuditSpecifications parameter is autopopulated for command-line completion and can be used to copy only ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Clear-DbaSqlConnectionPool.ps1 | Clear-DbaSqlConnectionPool.ps1 | Function Clear-DbaSqlConnectionPool
{
<#
.SYNOPSIS
Resets (or empties) the connection pool.
.DESCRIPTION
This command resets (or empties) the connection pool.
If 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 poo... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Copy-SqlDatabase.ps1 | Copy-SqlDatabase.ps1 | Function Copy-SqlDatabase
{
<#
.SYNOPSIS
Migrates Sql Server databases from one Sql Server to another.
.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 Express.
By default, databases will ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Find-DbaCommand.ps1 | Find-DbaCommand.ps1 | Function Find-DbaCommand
{
<#
.SYNOPSIS
Finds dbatools commands searching through the inline help text
.DESCRIPTION
Finds dbatools commands searching through the inline help text, building a consolidated json index and querying it because Get-Help is too slow
.PARAMETER Tag
Finds all commands tagged with th... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaDependency.ps1 | Get-DbaDependency.ps1 | function Get-DbaDependency
{
<#
.SYNOPSIS
Finds object dependencies and their relevant creation scripts.
.DESCRIPTION
This function recursively finds all objects that depends on the input.
It will then retrieve rich information from them, includin... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Export-DbaDiagnosticQuery.ps1 | Export-DbaDiagnosticQuery.ps1 | function Export-DbaDiagnosticQuery {
<#
.SYNOPSIS
Export-DbaDiagnosticQuery can convert ouput generated by Invoke-DbaDiagnosticQuery to CSV or Excel
.DESCRIPTION
The default output format of Invoke-DbaDiagnosticQuery is a custom object. It can also output to CSV and Excel.
However, CSV output can generate a l... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/New-DbaDatabaseSnapshot.ps1 | New-DbaDatabaseSnapshot.ps1 | Function New-DbaDatabaseSnapshot
{
<#
.SYNOPSIS
Creates database snapshots
.DESCRIPTION
Creates database snapshots without hassles
.PARAMETER SqlInstance
The SQL Server that you're connecting to.
.PARAMETER Credential
Credential object used to connect to the SQL Server as a different user
.PARAMETER ... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaMaxMemory.ps1 | Get-DbaMaxMemory.ps1 | Function Get-DbaMaxMemory
{
<#
.SYNOPSIS
Gets the 'Max Server Memory' configuration setting and the memory of the server. Works on SQL Server 2000-2014.
.DESCRIPTION
This command retrieves the SQL Server 'Max Server Memory' configuration setting as well as the total physical installed on the server.
.PA... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Get-DbaLocaleSetting.ps1 | Get-DbaLocaleSetting.ps1 | Function Get-DbaLocaleSetting
{
<#
.SYNOPSIS
Gets the Locale settings on a computer.
.DESCRIPTION
Gets the Locale settings on one or more computers.
Requires Local Admin rights on destination computer(s).
.PARAMETER ComputerName
The SQL Server (or server in ge... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Show-SqlDatabaseList.ps1 | Show-SqlDatabaseList.ps1 | Function Show-SqlDatabaseList
{
<#
.SYNOPSIS
Shows a list of databases in a GUI
.DESCRIPTION
Shows a list of databases in a GUI. Returns a simple string. Hitting cancel returns null.
.PARAMETER SqlServer
The SQL Server instance.
.PARAMETER SqlCredential
Allows you to login to servers using SQL Logins... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/Install-DbaWhoIsActive.ps1 | Install-DbaWhoIsActive.ps1 | Function Install-DbaWhoIsActive {
<#
.SYNOPSIS
Automatically installs or updates sp_WhoisActive by Adam Machanic.
.DESCRIPTION
This command downloads, extracts and installs sp_WhoisActive with Adam's permission. To read more about sp_WhoisActive, please visit:
Updates: http://sqlblog.com/blogs/adam_machanic/a... |
PowerShellCorpus/PowerShellGallery/dbatools/0.8.957/functions/New-DbaSqlDirectory.ps1 | New-DbaSqlDirectory.ps1 | Function New-DbaSqlDirectory
{
<#
.SYNOPSIS
Creates new path as specified by the path variable
.DESCRIPTION
Uses master.dbo.xp_create_subdir to create the path
Returns $true if the path can be created, $false otherwise
.PARAMETER SqlServer
The SQL Server you want to run the test on.
.PARAMETER Path
The... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.