-
Notifications
You must be signed in to change notification settings - Fork 14
/
lib.ps1
30 lines (23 loc) · 899 Bytes
/
lib.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
# i spent hours struggling trynna making this work and i forgor what i needed this for 💀
function RecursivelyPrepend ($Object, $String) {
if (($Object -Is [Array]) -or ($Object.GetType().Name -eq 'List`1')){
$Object | ForEach-Object {
$_ = RecursivelyPrepend $PSItem $String
}
} elseif ($Object -is [hashtable] ) {
[string[]]$Object.keys | ForEach-Object {
if ($Object[$_] -is [String]) {
$Object[$_] = "$String/$($Object[$_])"
}
elseif(($Object[$_] -Is [Array]) -or ($Object[$_].GetType().Name -eq 'List`1')){
$Object[$_] | ForEach-Object {
$_ = RecursivelyPrepend $PSItem $String
}
}
else {
$Object[$_] = RecursivelyPrepend $Object[$_] $String
}
}
}
$Object
}