Skip to content

Commit 5597876

Browse files
2 parents e682883 + b5993ae commit 5597876

10 files changed

+326
-5
lines changed

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "PowerShell",
6+
"type": "PowerShell",
7+
"request": "launch",
8+
"program": "${file}",
9+
"args": [],
10+
"cwd": "${file}"
11+
}
12+
]
13+
}

Backup-OLADatabase.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
<#
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID e690e558-357e-43fb-9bcf-5c39b33ce527
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION This function will perform an ad-hoc backup using OLA Hallengrens solution - It doesnot expose all of the capabilities but is useful for quick backups when needed Note the Database paramter is dynamically filled once you type it
10+
11+
.COMPANYNAME
12+
13+
.COPYRIGHT
14+
15+
.TAGS SQL, Ola Hallengren, Backup
16+
17+
.LICENSEURI
18+
19+
.PROJECTURI
20+
21+
.ICONURI
22+
23+
.EXTERNALMODULEDEPENDENCIES
24+
25+
.REQUIREDSCRIPTS
26+
27+
.EXTERNALSCRIPTDEPENDENCIES
28+
29+
.RELEASENOTES
30+
31+
#>
32+
<#
233
.Synopsis
334
To perform an ad-hoc backup using OLA Hallengrens solution
435
.DESCRIPTION

Get-SQLInstancesPort.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID 5a165df0-c30a-4147-b252-975dbd2a6b2d
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION This function will show the Instances and the Port Numbers on a SQL Server using WMI and the status of the relevant SQL Service and its start mode
10+
11+
.COMPANYNAME
12+
13+
.COPYRIGHT
14+
15+
.TAGS SQL, Instance, Port Numbers, Service Accounts
16+
17+
.LICENSEURI
18+
19+
.PROJECTURI
20+
21+
.ICONURI
22+
23+
.EXTERNALMODULEDEPENDENCIES
24+
25+
.REQUIREDSCRIPTS
26+
27+
.EXTERNALSCRIPTDEPENDENCIES
28+
29+
.RELEASENOTES
30+
31+
#>
132
<#
233
.SYNOPSIS
334
Shows the Instances and the Port Numbers and SQL Service Status and Start mode on a SQL Server

Show-DatabasesOnServer.ps1

824 Bytes
Binary file not shown.

Test-OLA.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
## This script will check the status of the SQL Servers OLA set up including all agent jobs, folders and existence of backup files
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID e900b08e-5e27-47ab-b407-462b409696ae
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION This script will check the status of the SQL Servers OLA set up including all agent jobs, folders and existence of backup files
10+
11+
.COMPANYNAME
12+
13+
.COPYRIGHT
14+
15+
.TAGS SQL, Ola Hallengren, Backup, Pester, Test, OVF
16+
17+
.LICENSEURI
18+
19+
.PROJECTURI
20+
21+
.ICONURI
22+
23+
.EXTERNALMODULEDEPENDENCIES sqlserver
24+
25+
.REQUIREDSCRIPTS
26+
27+
.EXTERNALSCRIPTDEPENDENCIES
28+
29+
.RELEASENOTES
30+
31+
#>
32+
## This script will check the status of the SQL Servers OLA set up including all agent jobs, folders and existence of backup files
233
## Whilst you can call this script directly using Invoke-Pester and a script block as shown below it should be called with
334
##
435
## function Test-OLAInstance

Test-OLAInstance.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
# You will need to add the path to Test-Ola.ps1 on Line 90
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID fee80eda-3390-4396-9a2b-478c81c2267f
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION Tests an instance or a number of instances to ensure that the OLA Hallengren solution is set up correctly. That all agent jobs exist, are schedeuled and were successful That the relevant folders for each database exist and that there are backups files in the folders It uses the Test-Ola.ps1 file You will need to add the path to Test-Ola.ps1 on Line 90
10+
11+
.COMPANYNAME
12+
13+
.COPYRIGHT
14+
15+
.TAGS SQL, Ola Hallengren, Backup, Pester, Test, OVF
16+
17+
.LICENSEURI
18+
19+
.PROJECTURI
20+
21+
.ICONURI
22+
23+
.EXTERNALMODULEDEPENDENCIES sqlserver
24+
25+
.REQUIREDSCRIPTS Test-Ola
26+
27+
.EXTERNALSCRIPTDEPENDENCIES
28+
29+
.RELEASENOTES
30+
31+
#>
32+
# You will need to add the path to Test-Ola.ps1 on Line 90
233

334
function Test-OLAInstance
435
{

Test-SQLDefaults.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
<#
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID 730f1621-25a7-4503-886d-625695f1dd06
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION Function to run a series of Pester tests for SQL Defaults against a server or array of servers
10+
11+
.COMPANYNAME
12+
13+
.COPYRIGHT
14+
15+
.TAGS SQL, Pester, Defaults, SQL Server
16+
17+
.LICENSEURI
18+
19+
.PROJECTURI
20+
21+
.ICONURI
22+
23+
.EXTERNALMODULEDEPENDENCIES
24+
25+
.REQUIREDSCRIPTS
26+
27+
.EXTERNALSCRIPTDEPENDENCIES
28+
29+
.RELEASENOTES
30+
31+
#>
32+
<#
233
.Synopsis
334
Function to run a series of Pester tests for SQL Defaults against a server or array of servers
435
.DESCRIPTION

When-WillSQLComplete.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1-
<#
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID e113cd95-5822-4114-89c8-8293422b655a
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION Runs some t-sql to gather some information about requests from the sys.dm_exec_requests dmv to estimate the amount of time remaining for a statement which can be filtered by BACKUP,RESTORE,INDEX,DBCC,STATS commands
10+
11+
.COMPANYNAME
12+
13+
.COPYRIGHT
14+
15+
.TAGS SQL, Queries, Commands, Time, When Will SQL Complete
16+
17+
.LICENSEURI
18+
19+
.PROJECTURI
20+
21+
.ICONURI
22+
23+
.EXTERNALMODULEDEPENDENCIES
24+
25+
.REQUIREDSCRIPTS
26+
27+
.EXTERNALSCRIPTDEPENDENCIES
28+
29+
.RELEASENOTES
30+
31+
#>
32+
<#
233
.Synopsis
334
A quick function to estimate the completion time of a SQL Statement
435
.DESCRIPTION

set-sqllogfiles.ps1

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<#PSScriptInfo
2+
3+
.VERSION 1.0
4+
5+
.GUID edba8ac2-e4d8-471a-b4ca-7fae59ee3ac4
6+
7+
.AUTHOR Rob Sewell
8+
9+
.DESCRIPTION
10+
Uses SMO to set the number of Log files for a single or group of SQL Servers
11+
12+
.COMPANYNAME
13+
14+
.COPYRIGHT
15+
16+
.TAGS SQL Error log SQL Server
17+
18+
.LICENSEURI
19+
20+
.PROJECTURI
21+
22+
.ICONURI
23+
24+
.EXTERNALMODULEDEPENDENCIES
25+
26+
.REQUIREDSCRIPTS
27+
28+
.EXTERNALSCRIPTDEPENDENCIES
29+
30+
.RELEASENOTES
31+
32+
#>
33+
function Set-SQLLogFiles
34+
{
35+
<#
36+
.Synopsis
37+
Sets the number of Log files for a single or group of SQL Servers
38+
39+
.DESCRIPTION
40+
Uses SMO to set the number of Log files for a single or group of SQL Servers
41+
42+
.PARAMETER Instances
43+
The SQL Server Instance or an array of instances to change
44+
45+
.PARAMETER Number
46+
The number of logfiles to set
47+
48+
.EXAMPLE
49+
Set-SQLLogFiles -instances Fade2Black -Number 20
50+
51+
Sets the number of SQL Server log files to 20 on the instance Fade2Black
52+
.EXAMPLE
53+
$Servers = 'Fade2Black','JusticeForAll','MasterOfPuppets'
54+
Set-SQLLogFiles -instances $Servers -Number 20
55+
56+
Sets the number of SQL Server log files to 20 on the instances 'Fade2Black','JusticeForAll','MasterOfPuppets'
57+
.NOTES
58+
Author - Rob Sewell SQLDBAWithABeard.com
59+
#>
60+
61+
param(
62+
[object]$instances,
63+
[ValidateRange(0,99)]
64+
[int]$Number
65+
)
66+
[void][reflection.assembly]::LoadWithPartialName( 'Microsoft.SqlServer.Smo' )
67+
foreach($Server in $Instances)
68+
{
69+
try
70+
{
71+
$srv = New-Object Microsoft.SqlServer.Management.Smo.Server $server
72+
$srv.Settings.NumberOfLogFiles = $Number
73+
$srv.Alter()
74+
}
75+
catch
76+
{
77+
Write-Warning "Eailed to set Log Fiels on $Server - Run `$error[0]|fl -force to find the error"
78+
continue
79+
}
80+
}
81+
}

set-sqllogfiles1.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
<#PSScriptInfo
3+
4+
.VERSION 1.0
5+
6+
.GUID edba8ac2-e4d8-471a-b4ca-7fae59ee3ac4
7+
8+
.AUTHOR Rob Sewell
9+
10+
.COMPANYNAME
11+
12+
.COPYRIGHT
13+
14+
.TAGS SQL Error log SQL Server
15+
16+
.LICENSEURI
17+
18+
.PROJECTURI
19+
20+
.ICONURI
21+
22+
.EXTERNALMODULEDEPENDENCIES
23+
24+
.REQUIREDSCRIPTS
25+
26+
.EXTERNALSCRIPTDEPENDENCIES
27+
28+
.RELEASENOTES
29+
30+
31+
#>
32+
33+
<#
34+
35+
.DESCRIPTION
36+
Sets teh number of SQL Error log files for an instance or aray of instances
37+
38+
#>
39+
Param()
40+
41+

0 commit comments

Comments
 (0)