forked from proxb/PoshWSUS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test-PSWSUSDatabaseServerConnection.ps1
37 lines (35 loc) · 1.19 KB
/
Test-PSWSUSDatabaseServerConnection.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Function Test-PSWSUSDatabaseServerConnection {
<#
.SYNOPSIS
Tests the database connection from the console to the SQL database hosting the WSUS database.
.DESCRIPTION
Tests the database connection from the console to the SQL database hosting the WSUS database.
.NOTES
Name: Test-PSWSUSDatabaseServerConnection
Author: Boe Prox
DateCreated: 06DEC2010
.LINK
https://learn-powershell.net
.EXAMPLE
Test-PSWSUSDatabaseServerConnection
Description
-----------
This command will test the database connection and return a boolean value based on the connection status.
#>
[cmdletbinding()]
Param ()
Process {
If ($wsusdb) {
Try {
#Test the connection to the database
Write-Verbose "Testing the database connection to the WSUS database server."
$wsusdb.ConnectToDatabase()
Write-Output $True
} Catch {
Write-Output $False
}
} Else {
Write-Warning "Please connect to the database first using Connect-PSWSUSDatabaseServer"
}
}
}