1384 lines
18 KiB
PowerShell
1384 lines
18 KiB
PowerShell
<#
|
|
---------------------------------------------------------------------------
|
|
Module......: SQL.psm1
|
|
Projekt.....: Veeam Enterprise Installer
|
|
Version.....: 2.0.0
|
|
|
|
Beschreibung
|
|
|
|
SQL Verwaltung für Veeam Installation.
|
|
|
|
Unterstützt:
|
|
|
|
• SQL Instanzprüfung
|
|
• SQL Verbindung
|
|
• Serviceprüfung
|
|
• Datenbankprüfung
|
|
• Benutzerprüfung
|
|
• Datenbankbereitstellung
|
|
|
|
Zielumgebung:
|
|
|
|
SQL Server 2022 Standard
|
|
Instanz VEEAMSQLSERVER
|
|
|
|
---------------------------------------------------------------------------#>
|
|
|
|
Set-StrictMode -Version Latest
|
|
|
|
|
|
#region Variablen
|
|
|
|
$Script:SQLVersion = "2.0.0"
|
|
|
|
$Script:DefaultInstance = "VEEAMSQLSERVER"
|
|
|
|
#endregion
|
|
|
|
|
|
############################################################
|
|
# Get-SQLServiceName
|
|
############################################################
|
|
|
|
function Get-SQLServiceName {
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Ermittelt SQL Dienstnamen.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
if($Instance -eq "MSSQLSERVER")
|
|
{
|
|
|
|
return "MSSQLSERVER"
|
|
|
|
}
|
|
|
|
|
|
return "MSSQL`$$Instance"
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLService
|
|
|
|
############################################################
|
|
|
|
function Get-SQLService {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Liefert SQL Dienst.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$ServiceName =
|
|
|
|
Get-SQLServiceName `
|
|
-Instance $Instance
|
|
|
|
|
|
|
|
try
|
|
{
|
|
|
|
Get-Service `
|
|
-Name $ServiceName `
|
|
-ErrorAction Stop
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
return $null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-SQLService
|
|
|
|
############################################################
|
|
|
|
function Test-SQLService {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft SQL Dienst.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$Service =
|
|
|
|
Get-SQLService `
|
|
-Instance $Instance
|
|
|
|
|
|
|
|
if($null -eq $Service)
|
|
{
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
|
$Service.Status -eq "Running"
|
|
|
|
)
|
|
|
|
}
|
|
#Beginn PART 2
|
|
############################################################
|
|
# Get-SQLInstances
|
|
############################################################
|
|
|
|
function Get-SQLInstances {
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Listet SQL Instanzen auf dem Server.
|
|
#>
|
|
|
|
|
|
$RegistryPaths = @(
|
|
|
|
"HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL",
|
|
|
|
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL"
|
|
|
|
)
|
|
|
|
|
|
$Instances = @()
|
|
|
|
|
|
|
|
foreach($Path in $RegistryPaths)
|
|
{
|
|
|
|
if(Test-Path $Path)
|
|
{
|
|
|
|
$Data =
|
|
|
|
Get-ItemProperty `
|
|
-Path $Path
|
|
|
|
|
|
|
|
foreach($Property in $Data.PSObject.Properties)
|
|
{
|
|
|
|
if(
|
|
$Property.Name `
|
|
-notmatch "^PS"
|
|
)
|
|
{
|
|
|
|
$Instances += [PSCustomObject]@{
|
|
|
|
Name =
|
|
$Property.Name
|
|
|
|
|
|
InstanceID =
|
|
$Property.Value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return $Instances
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-SQLInstanceExists
|
|
############################################################
|
|
|
|
function Test-SQLInstanceExists {
|
|
|
|
|
|
param(
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$Instances =
|
|
|
|
Get-SQLInstances
|
|
|
|
|
|
|
|
foreach($Item in $Instances)
|
|
{
|
|
|
|
if(
|
|
$Item.Name `
|
|
-eq $Instance
|
|
)
|
|
{
|
|
|
|
return $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLVersion
|
|
############################################################
|
|
|
|
function Get-SQLVersion {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Liest SQL Server Version.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$Path =
|
|
|
|
"HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server"
|
|
|
|
|
|
if(!(Test-Path $Path))
|
|
{
|
|
|
|
return $null
|
|
|
|
}
|
|
|
|
|
|
Get-ChildItem `
|
|
$Path |
|
|
|
|
Where-Object {
|
|
|
|
$_.PSChildName `
|
|
-like "MSSQL*"
|
|
|
|
} |
|
|
|
|
Select-Object `
|
|
PSChildName
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLPort
|
|
|
|
############################################################
|
|
|
|
function Get-SQLPort {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Liest TCP Port der Instanz.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$Instances =
|
|
|
|
Get-SQLInstances
|
|
|
|
|
|
|
|
$Target =
|
|
|
|
$Instances |
|
|
|
|
Where-Object {
|
|
|
|
$_.Name -eq $Instance
|
|
|
|
}
|
|
|
|
|
|
|
|
if($null -eq $Target)
|
|
{
|
|
|
|
return $null
|
|
|
|
}
|
|
|
|
|
|
$PortPath =
|
|
|
|
"HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$($Target.InstanceID)\MSSQLServer\SuperSocketNetLib\Tcp\IPAll"
|
|
|
|
|
|
|
|
if(Test-Path $PortPath)
|
|
{
|
|
|
|
Get-ItemProperty `
|
|
$PortPath |
|
|
|
|
Select-Object `
|
|
TcpPort,
|
|
TcpDynamicPorts
|
|
|
|
}
|
|
|
|
}
|
|
#Beginn PART 3
|
|
############################################################
|
|
# New-SQLConnectionString
|
|
############################################################
|
|
|
|
function New-SQLConnectionString {
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Erstellt SQL Connection String.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Server =
|
|
$env:COMPUTERNAME,
|
|
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance,
|
|
|
|
|
|
[string]$Database =
|
|
"master"
|
|
|
|
)
|
|
|
|
|
|
return (
|
|
|
|
"Server=$Server\$Instance;" +
|
|
"Database=$Database;" +
|
|
"Integrated Security=True;" +
|
|
"TrustServerCertificate=True;"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-SQLConnection
|
|
|
|
############################################################
|
|
|
|
function Test-SQLConnection {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft SQL Verbindung.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$Server =
|
|
$env:COMPUTERNAME,
|
|
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$ConnectionString =
|
|
|
|
New-SQLConnectionString `
|
|
-Server $Server `
|
|
-Instance $Instance
|
|
|
|
|
|
|
|
try
|
|
{
|
|
|
|
$Connection =
|
|
|
|
New-Object `
|
|
System.Data.SqlClient.SqlConnection(
|
|
$ConnectionString
|
|
)
|
|
|
|
|
|
$Connection.Open()
|
|
|
|
|
|
$Connection.Close()
|
|
|
|
|
|
return $true
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Invoke-SQLQuery
|
|
############################################################
|
|
|
|
function Invoke-SQLQuery {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Führt SQL Query aus.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$Query,
|
|
|
|
|
|
[string]$Database =
|
|
"master",
|
|
|
|
|
|
[string]$Server =
|
|
$env:COMPUTERNAME,
|
|
|
|
|
|
[string]$Instance =
|
|
$Script:DefaultInstance
|
|
|
|
)
|
|
|
|
|
|
$ConnectionString =
|
|
|
|
New-SQLConnectionString `
|
|
-Server $Server `
|
|
-Instance $Instance `
|
|
-Database $Database
|
|
|
|
|
|
|
|
$Connection =
|
|
|
|
New-Object `
|
|
System.Data.SqlClient.SqlConnection(
|
|
$ConnectionString
|
|
)
|
|
|
|
|
|
$Command =
|
|
|
|
$Connection.CreateCommand()
|
|
|
|
|
|
$Command.CommandText =
|
|
$Query
|
|
|
|
|
|
|
|
try
|
|
{
|
|
|
|
$Connection.Open()
|
|
|
|
|
|
$Adapter =
|
|
|
|
New-Object `
|
|
System.Data.SqlClient.SqlDataAdapter(
|
|
$Command
|
|
)
|
|
|
|
|
|
$Table =
|
|
|
|
New-Object `
|
|
System.Data.DataTable
|
|
|
|
|
|
$Adapter.Fill($Table) |
|
|
|
|
Out-Null
|
|
|
|
|
|
return $Table
|
|
|
|
}
|
|
finally
|
|
{
|
|
|
|
$Connection.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLDatabases
|
|
|
|
############################################################
|
|
|
|
function Get-SQLDatabases {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Listet Datenbanken.
|
|
#>
|
|
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
SELECT
|
|
name,
|
|
database_id,
|
|
state_desc
|
|
FROM sys.databases
|
|
ORDER BY name
|
|
"
|
|
|
|
}
|
|
#Beginn PART 4
|
|
############################################################
|
|
# Test-DatabaseExists
|
|
############################################################
|
|
|
|
function Test-DatabaseExists {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft ob Datenbank existiert.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$DatabaseName
|
|
|
|
)
|
|
|
|
|
|
$Result =
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
|
|
SELECT name
|
|
|
|
FROM sys.databases
|
|
|
|
WHERE name = '$DatabaseName'
|
|
|
|
"
|
|
|
|
|
|
|
|
return (
|
|
|
|
$null -ne $Result -and
|
|
$Result.Count -gt 0
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# New-SQLDatabase
|
|
############################################################
|
|
|
|
function New-SQLDatabase {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Erstellt SQL Datenbank.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$DatabaseName
|
|
|
|
)
|
|
|
|
|
|
if(Test-DatabaseExists $DatabaseName)
|
|
{
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
|
|
CREATE DATABASE [$DatabaseName]
|
|
|
|
" | Out-Null
|
|
|
|
|
|
|
|
return (
|
|
|
|
Test-DatabaseExists `
|
|
-DatabaseName $DatabaseName
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Remove-SQLDatabase
|
|
|
|
############################################################
|
|
|
|
function Remove-SQLDatabase {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Löscht SQL Datenbank.
|
|
|
|
Nur für Wartung/Test.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$DatabaseName
|
|
|
|
)
|
|
|
|
|
|
if(!(Test-DatabaseExists $DatabaseName))
|
|
{
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
|
|
ALTER DATABASE [$DatabaseName]
|
|
|
|
SET SINGLE_USER
|
|
|
|
WITH ROLLBACK IMMEDIATE;
|
|
|
|
|
|
DROP DATABASE [$DatabaseName];
|
|
|
|
" | Out-Null
|
|
|
|
|
|
|
|
return $true
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-DatabaseCollation
|
|
|
|
############################################################
|
|
|
|
function Get-DatabaseCollation {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Liest Datenbank Collation.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$DatabaseName
|
|
|
|
)
|
|
|
|
|
|
$Result =
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Database $DatabaseName `
|
|
|
|
-Query "
|
|
|
|
SELECT
|
|
|
|
DATABASEPROPERTYEX(
|
|
DB_NAME(),
|
|
'Collation'
|
|
)
|
|
AS Collation
|
|
|
|
"
|
|
|
|
|
|
return $Result.Collation
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-VeeamDatabase
|
|
|
|
############################################################
|
|
|
|
function Test-VeeamDatabase {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft Veeam Datenbank.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[string]$DatabaseName =
|
|
"VeeamBackup"
|
|
|
|
)
|
|
|
|
|
|
[PSCustomObject]@{
|
|
|
|
Name =
|
|
$DatabaseName
|
|
|
|
|
|
Exists =
|
|
Test-DatabaseExists `
|
|
-DatabaseName $DatabaseName
|
|
|
|
|
|
Collation =
|
|
if(
|
|
Test-DatabaseExists `
|
|
-DatabaseName $DatabaseName
|
|
)
|
|
{
|
|
|
|
Get-DatabaseCollation `
|
|
-DatabaseName $DatabaseName
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
#Beginn PART 5
|
|
############################################################
|
|
# Test-SQLLoginExists
|
|
############################################################
|
|
|
|
function Test-SQLLoginExists {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft SQL Login.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$LoginName
|
|
|
|
)
|
|
|
|
|
|
$Result =
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
|
|
SELECT name
|
|
|
|
FROM sys.server_principals
|
|
|
|
WHERE name = '$LoginName'
|
|
|
|
"
|
|
|
|
|
|
|
|
return (
|
|
|
|
$null -ne $Result -and
|
|
$Result.Count -gt 0
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLLogin
|
|
|
|
############################################################
|
|
|
|
function Get-SQLLogin {
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$LoginName
|
|
|
|
)
|
|
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
|
|
SELECT
|
|
|
|
name,
|
|
|
|
type_desc,
|
|
|
|
create_date
|
|
|
|
FROM sys.server_principals
|
|
|
|
WHERE name = '$LoginName'
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-DatabasePermission
|
|
|
|
############################################################
|
|
|
|
function Test-DatabasePermission {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft Datenbankrechte.
|
|
#>
|
|
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$DatabaseName,
|
|
|
|
|
|
[Parameter(Mandatory)]
|
|
|
|
[string]$UserName
|
|
|
|
)
|
|
|
|
|
|
$Result =
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Database $DatabaseName `
|
|
|
|
-Query "
|
|
|
|
SELECT
|
|
|
|
dp.name,
|
|
|
|
dp.type_desc
|
|
|
|
FROM
|
|
|
|
sys.database_principals dp
|
|
|
|
WHERE
|
|
|
|
dp.name = '$UserName'
|
|
|
|
"
|
|
|
|
|
|
|
|
return $Result
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLConfigurationReport
|
|
############################################################
|
|
|
|
function Get-SQLConfigurationReport {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Erstellt SQL Bericht.
|
|
#>
|
|
|
|
|
|
[PSCustomObject]@{
|
|
|
|
|
|
Computer =
|
|
|
|
$env:COMPUTERNAME
|
|
|
|
|
|
|
|
Instance =
|
|
|
|
$Script:DefaultInstance
|
|
|
|
|
|
|
|
ServiceRunning =
|
|
|
|
Test-SQLService
|
|
|
|
|
|
|
|
Connection =
|
|
|
|
Test-SQLConnection
|
|
|
|
|
|
|
|
Databases =
|
|
|
|
Get-SQLDatabases
|
|
|
|
|
|
|
|
Timestamp =
|
|
|
|
Get-Date
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-VeeamSQLPreparation
|
|
|
|
############################################################
|
|
|
|
function Test-VeeamSQLPreparation {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Komplette SQL Vorbereitung.
|
|
#>
|
|
|
|
|
|
$Report = [ordered]@{}
|
|
|
|
|
|
|
|
$Report.Instance =
|
|
|
|
Test-SQLInstanceExists
|
|
|
|
|
|
|
|
$Report.Service =
|
|
|
|
Test-SQLService
|
|
|
|
|
|
|
|
$Report.Connection =
|
|
|
|
Test-SQLConnection
|
|
|
|
|
|
|
|
$Report.Database =
|
|
|
|
Test-VeeamDatabase
|
|
|
|
|
|
|
|
return (
|
|
|
|
[PSCustomObject]$Report
|
|
|
|
)
|
|
|
|
}
|
|
#Beginn PART 6
|
|
############################################################
|
|
# Get-SQLServerInformation
|
|
############################################################
|
|
|
|
function Get-SQLServerInformation {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Liefert SQL Server Informationen.
|
|
#>
|
|
|
|
|
|
$Result =
|
|
|
|
Invoke-SQLQuery `
|
|
|
|
-Query "
|
|
|
|
SELECT
|
|
|
|
SERVERPROPERTY(
|
|
'ServerName'
|
|
) AS ServerName,
|
|
|
|
|
|
SERVERPROPERTY(
|
|
'ProductVersion'
|
|
) AS ProductVersion,
|
|
|
|
|
|
SERVERPROPERTY(
|
|
'ProductLevel'
|
|
) AS ProductLevel,
|
|
|
|
|
|
SERVERPROPERTY(
|
|
'Edition'
|
|
) AS Edition
|
|
|
|
"
|
|
|
|
|
|
return $Result
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-SQLVersionSupported
|
|
############################################################
|
|
|
|
function Test-SQLVersionSupported {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prüft SQL Version.
|
|
|
|
Ziel:
|
|
SQL Server 2022
|
|
#>
|
|
|
|
|
|
$Info =
|
|
|
|
Get-SQLServerInformation
|
|
|
|
|
|
|
|
if($null -eq $Info)
|
|
{
|
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
$Info.ProductVersion `
|
|
-like "16.*"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLEdition
|
|
|
|
############################################################
|
|
|
|
function Get-SQLEdition {
|
|
|
|
|
|
$Info =
|
|
|
|
Get-SQLServerInformation
|
|
|
|
|
|
|
|
if($null -eq $Info)
|
|
{
|
|
|
|
return $null
|
|
|
|
}
|
|
|
|
|
|
return $Info.Edition
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Test-SQLConfiguration
|
|
|
|
|
|
############################################################
|
|
|
|
function Test-SQLConfiguration {
|
|
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Gesamte SQL Prüfung.
|
|
#>
|
|
|
|
|
|
[PSCustomObject]@{
|
|
|
|
|
|
Instance =
|
|
|
|
$Script:DefaultInstance
|
|
|
|
|
|
|
|
Service =
|
|
|
|
Test-SQLService
|
|
|
|
|
|
|
|
Connection =
|
|
|
|
Test-SQLConnection
|
|
|
|
|
|
|
|
VersionSupported =
|
|
|
|
Test-SQLVersionSupported
|
|
|
|
|
|
|
|
Edition =
|
|
|
|
Get-SQLEdition
|
|
|
|
|
|
|
|
Database =
|
|
|
|
Test-VeeamDatabase
|
|
|
|
|
|
|
|
Time =
|
|
|
|
Get-Date
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
############################################################
|
|
# Get-SQLModuleInformation
|
|
|
|
############################################################
|
|
|
|
function Get-SQLModuleInformation {
|
|
|
|
|
|
[PSCustomObject]@{
|
|
|
|
|
|
Module =
|
|
|
|
"SQL.psm1"
|
|
|
|
|
|
|
|
Version =
|
|
|
|
$Script:SQLVersion
|
|
|
|
|
|
|
|
DefaultInstance =
|
|
|
|
$Script:DefaultInstance
|
|
|
|
|
|
|
|
Loaded =
|
|
|
|
$true
|
|
|
|
}
|
|
|
|
}
|
|
#Beginn PART 7
|
|
############################################################
|
|
# Export Module Functions
|
|
############################################################
|
|
|
|
Export-ModuleMember `
|
|
-Function `
|
|
Get-SQLServiceName,
|
|
Get-SQLService,
|
|
Test-SQLService,
|
|
Get-SQLInstances,
|
|
Test-SQLInstanceExists,
|
|
Get-SQLVersion,
|
|
Get-SQLPort,
|
|
New-SQLConnectionString,
|
|
Test-SQLConnection,
|
|
Invoke-SQLQuery,
|
|
Get-SQLDatabases,
|
|
Test-DatabaseExists,
|
|
New-SQLDatabase,
|
|
Remove-SQLDatabase,
|
|
Get-DatabaseCollation,
|
|
Test-VeeamDatabase,
|
|
Test-SQLLoginExists,
|
|
Get-SQLLogin,
|
|
Test-DatabasePermission,
|
|
Get-SQLConfigurationReport,
|
|
Test-VeeamSQLPreparation,
|
|
Get-SQLServerInformation,
|
|
Test-SQLVersionSupported,
|
|
Get-SQLEdition,
|
|
Test-SQLConfiguration,
|
|
Get-SQLModuleInformation
|
|
|
|
|
|
############################################################
|
|
# Ende SQL.psm1
|
|
############################################################
|