-
Notifications
You must be signed in to change notification settings - Fork 26
/
setup.ps1
48 lines (40 loc) · 1.31 KB
/
setup.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
[cmdletBinding()]
Param(
# What name would you prefer the drive to be mapped under.
[string]$Store = "ps"
, # If you don't have an existing profile, Copy our template in that maps the drive as your profile.
[switch]$copyProfile
)
$v = measure-command {
try
{
Get-PSDrive $Store -ErrorAction stop
}
catch [System.Exception]
{
Write-verbose "adding the store: $Store"
# Add the network path to the shared powershell scripts as a drive for the current user
New-PSDrive -Name $Store `
-PSProvider "FileSystem" `
-Root "\\uhhs\psStore" `
-Description "Powershell script and module store"
}
catch
{
Write-warning 'No Fault'
}
}
Write-verbose "$($v.TotalSeconds) seconds - Detecting store drive"
$v = measure-command {
write-verbose "path Before:"
$env:PSModulePath.split(';') | % {write-host $PSItem}
# Check to see if the above added drive is in the module path. If not, add it.
if($env:PSModulePath -notmatch "$Store`:")
{
Write-verbose "no store found"
$env:PSModulePath = $env:PSModulePath.Insert(0, "$Store`:\;")
}
write-verbose "path after:"
$env:PSModulePath.split(';') | % {write-host $PSItem}
}
Write-verbose "$($v.TotalSeconds) seconds - add store to path"