-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
40 lines (29 loc) · 1.46 KB
/
install.ps1
File metadata and controls
40 lines (29 loc) · 1.46 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
function Install-Module($ModuleName)
{
$SourcePath = $SourcePath = "Modules\" + $ModuleName
if(!(Test-Path $SourcePath)) {
Write-Error ("{0} is missing, run create.ps1 first" -f $SourcePath)
return;
}
$TargetPath = ("{0}\Documents\WindowsPowerShell\Modules\{1}" -f $env:USERPROFILE, $ModuleName)
# Remove items if exits
if(Test-Path $TargetPath) {
$message = ('Module already exists, if you proceed, this script will replace the module at ' + $TargetPath)
$question = 'Are you sure you want to proceed?'
$OptYes = (New-Object Management.Automation.Host.ChoiceDescription '&Yes', ('Removes the existing module, and replaces it with the one located at ' + $SourcePath))
$OptNo = (New-Object Management.Automation.Host.ChoiceDescription '&No','Abort, do NOT remove existing module')
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($OptYes, $OptNo)
$decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
if ($decision -eq 0) {
Write-Output "Removing existing module..."
Remove-Item $TargetPath -Recurse -Force
} else {
Write-Output "Aborting... module is NOT installed"
return
}
}
Copy-Item $SourcePath $TargetPath -Container -Recurse -Force
Write-Output ("Installed at location: " + $TargetPath)
Get-DscResource -Module $ModuleName
}
Install-Module "cRemoteFile"