-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpers.ps1
101 lines (89 loc) · 2.37 KB
/
Helpers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
function Install-NugetProvider
{
param
(
[String] $Version = '2.8.201'
)
Write-Verbose 'Installing NuGet package management.'
Install-PackageProvider -Name NuGet -MinimumVersion $Version -Force
Import-PackageProvider -Name NuGet -MinimumVersion $Version -Force
}
function Remove-OldNugetProvider
{
<# First cut of function -- not tested #>
param
(
[Parameter(Mandatory)]
[String] $Version
)
$dir1 = ""
$dir2 = ""
Get-ChildItem -Path $dir1 -Recurse | ? {
$_.Name -lt $Version
} | Remove-Item
Get-ChildItem -Path $dir2 -Recurse | ? {
$_.Name -lt $Version
} | Remove-Item
}
function Is-NugetProviderInstalled
{
if ((-not (Test-Path "$env:ProgramFiles\PackageManagement\ProviderAssemblies\nuget")) `
-and `
(-not (Test-Path "$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies\nuget")))
{
Write-Verbose 'NuGet package management not found.'
Install-NugetProvider
}
}
function Install-DSCModules
{
param
(
[String[]] $desired = @('xSQLServer', 'cChoco')
)
$installed = @()
Get-DscResource | ForEach-Object {
$installed += $_.Name
}
foreach ($item in $desired) {
if (-not $installed.Contains($item)) {
Find-Module -Name $item | Install-Module -Name $item -Force
}
}
}
function Install-Chocolatey
{
Write-Verbose 'Installing chocolatey'
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
}
function Is-ChocolateyInstalled
{
if (-not (Test-Path $env:ChocolateyInstall)) {
Write-Verbose 'Chocolatey not found.'
Install-Chocolatey
}
}
function Install-Wmf
{
Write-Verbose 'Installing PowerShell 5.0'
$CMD = "$env:ChocolateyInstall\bin\cinst.exe"
& $CMD 'powershell' '-y'
}
function Is-WmfInstalled
{
if (-not (Test-Path "$env:ChocolateyInstall\lib\PowerShell")) {
Write-Verbose 'PowerShell 5.0 required but not found.'
Install-Wmf
Restart-Computer
}
}
function Get-OctopusDSC
{
$psmodulepath = $env:PSModulePath.Split(';')
$psmodulepath = $psmodulepath -like "*\Program Files\*"
if (-not (Test-Path "$psmodulepath\OctopusDSC")) {
#Remove-Item "$psmodulepath\OctopusDSC" -Recurse -Force
& 'git' 'clone' 'https://github.com/OctopusDeploy/OctopusDSC.git' "$psmodulepath\OctopusDSC"
}
}
$packageManagementUrl = '/en-us/download/confirmation.aspx?id=51451&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1'