-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGetPotentialUserProfiles.ps1
39 lines (36 loc) · 1.08 KB
/
GetPotentialUserProfiles.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
Function GetPotentialUserProfiles
{
[cmdletbinding()]
param
(
[parameter()]
[AllowNull()]
[string[]]$path
)
if ($null -eq $path)
{
throw('You must specify the Path parameter or run Set-OneShellUserProfilePath')
}
$JSONProfiles = @(
foreach ($p in $Path)
{
Get-ChildItem -Path "$p\*" -Include '*.json' -Exclude 'OneShellUserSettings.json'
}
)
$PotentialUserProfiles = @(
foreach ($file in $JSONProfiles)
{
Import-JSON -Path $file.fullname |
Where-Object -FilterScript {$_.Profiletype -eq 'OneShellUserProfile'} |
Add-Member -MemberType NoteProperty -Name DirectoryPath -Value $File.DirectoryName -PassThru
}
)
if ($PotentialUserProfiles.Count -lt 1)
{
throw('You must specify a folder path which contains OneShell User Profiles with the Path parameter and/or you must create at least one User Profile using New-OneShellUserProfile.')
}
else
{
$PotentialUserProfiles
}
}