-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunction-CheckModule-example.ps1
More file actions
36 lines (31 loc) · 1.15 KB
/
function-CheckModule-example.ps1
File metadata and controls
36 lines (31 loc) · 1.15 KB
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
#-----------------------------------------------------------[Functions]------------------------------------------------------------
# -----------------------------------------------------------------------------
# Type: Function
# Name: CheckModule
# Description: Checks, if the module exists on the system and loaded
# Parameters: module name
# Return Values:
# Requirements:
# -----------------------------------------------------------------------------
Function CheckModule {
param (
[Parameter(Mandatory=$True)]
[string] $Name
)
if(-not (Get-Module -name $name) ) {
if(Get-Module -ListAvailable | Where-Object { $_.name -eq $name }) {
Import-Module -Name $name
write-host "Module $name ist bereits geladen." -ForegroundColor Green
}
else {
write-host "Module $name nicht gefunden!" -ForegroundColor Red
pause
exit
}
}
else {
write-host "Module $name ist geladen." -ForegroundColor Green
}
}
#-----------------------------------------------------------[Execution]------------------------------------------------------------
CheckModule -Name "ActiveDirectory"