-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunction-CheckSnapIn-example.ps1
More file actions
34 lines (29 loc) · 1.18 KB
/
function-CheckSnapIn-example.ps1
File metadata and controls
34 lines (29 loc) · 1.18 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
#-----------------------------------------------------------[Functions]------------------------------------------------------------
# -----------------------------------------------------------------------------
# Type: Function
# Name: CheckSnapIn
# Description: Checks, if the Snapin is registered and loaded.
# Parameters: snapin name
# Return Values:
# Requirements:
# -----------------------------------------------------------------------------
function CheckSnapIn {
param (
[Parameter(Mandatory=$True)]
[string] $Name
)
if (get-pssnapin $name -ea "silentlycontinue") {
write-host "PSsnapin $name ist bereits geladen." -ForegroundColor Green
}
elseif (get-pssnapin $name -registered -ea "silentlycontinue") {
Add-PSSnapin $name
write-host "PSsnapin $name ist geladen." -ForegroundColor Green
}
else {
write-host "PSSnapin $name nicht gefunden!" -ForegroundColor Red
pause
exit
}
}
#-----------------------------------------------------------[Execution]------------------------------------------------------------
CheckSnapIn -Name "Microsoft.Exchange.Management.PowerShell.E2010"