This repository was archived by the owner on Nov 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInvoke-InstallModule.ps1
More file actions
71 lines (64 loc) · 2.07 KB
/
Invoke-InstallModule.ps1
File metadata and controls
71 lines (64 loc) · 2.07 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<#
.SYNOPSIS
Install the module in the PowerShell module folder.
.DESCRIPTION
Install the module in the PowerShell module folder by copying all the files.
#>
[CmdLetBinding()]
Param (
[ValidateNotNullOrEmpty()]
[String]$ModuleName = 'CyCLI',
[ValidateScript({Test-Path -Path $_ -Type Container})]
[String]$ModulePath = 'C:\Program Files\WindowsPowerShell\Modules'
)
Begin {
Try {
Write-Verbose "$ModuleName module installation started"
$Files = @(
'CyCLI.psd1',
'CyCLI.psm1',
'CyHelper.ps1',
'CyTDR.ps1',
'CyAPI.ps1',
'CyCrypto.ps1',
'CyDevices.ps1',
'CyThreats.ps1',
'CyZones.ps1',
'CyPolicies.ps1',
'CyInstallers.ps1',
'CyGlobalLists.ps1',
'CyUsers.ps1',
'CyOpticsDetections.ps1',
'CyOpticsRules.ps1',
'CyOpticsPackages.ps1',
'CyOpticsInstaQuery.ps1',
'CyConvenience.ps1',
'CyDATA_ApplicationDefinitions.json'
'license.txt'
)
}
Catch {
throw "Failed installing the module '$ModuleName': $_"
}
}
Process {
Try {
$TargetPath = Join-Path -Path $ModulePath -ChildPath $ModuleName
$SourcePath = $PSScriptRoot
if (-not (Test-Path $TargetPath)) {
New-Item -Path $TargetPath -ItemType Directory -EA Stop | Out-Null
Write-Verbose "$ModuleName created module folder '$TargetPath'"
}
$Files |
ForEach-Object { Get-ChildItem (Join-Path -Path $SourcePath -ChildPath $_) } |
ForEach-Object {
$Destination = Join-Path $TargetPath -ChildPath $_.Name
Copy-Item -Path $_.FullName -Destination $Destination
Write-Verbose "$ModuleName installed module file '$($_.Name)' to '$($Destination)'"
}
Write-Verbose "$ModuleName module installation successful"
}
Catch {
throw "Failed installing the module '$ModuleName': $_"
}
}