forked from timmcmic/DLConversionV2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest-PowershellModule.ps1
59 lines (43 loc) · 1.68 KB
/
Test-PowershellModule.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<#
.SYNOPSIS
This function tests to see if a powershell module necessary for script execution is present.
.DESCRIPTION
This function tests to see if a powershell module necessary for script execution is present.
.EXAMPLE
Test-PowershellModule
#>
Function Test-PowershellModule
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory = $true)]
[string]$powershellModuleName
)
#Define variables that will be utilzed in the function.
[array]$commandsArray=$NULL
#Initiate the test.
Out-LogFile -string "********************************************************************************"
Out-LogFile -string "BEGIN TEST-POWERSHELLMODULE"
Out-LogFile -string "********************************************************************************"
#Write function parameter information and variables to a log file.
Out-LogFile -string ("PowerShellModuleName = "+$powershellModuleName)
try
{
$commandsArray = get-command -module $powershellModuleName -errorAction STOP
}
catch
{
Out-LogFile -string $_ -isError:$TRUE
}
if ($commandsArray.count -eq 0)
{
Out-LogFile -string "The powershell module was not found and is required for script functionality." -iserror:$TRUE
}
else
{
Out-LogFile -string "The powershell module was found."
}
Out-LogFile -string "END TEST-POWERSHELLMODULE"
Out-LogFile -string "********************************************************************************"
}