-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSession Manager XML update.ps1
60 lines (49 loc) · 3.18 KB
/
Session Manager XML update.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
#####################################################################################
#Script Created by Phillip Marshall #
#Creation Date 1/27/15 #
#Revision 1 #
#Revisions Changes - N/A #
# #
#Revision 2 #
#Revisions Changes - Changes the XML document paths to variables for easier updating#
#in the future. #
# #
#Description - This Script will Pull information from the Users.xml file and update #
#the SessionGroup.xml with the values pulled. #
# #
# #
#####################################################################################
$Userspath = 'C:\Users\pmarshall\documents\User.xml'
$SessionPath = 'C:\Users\pmarshall\documents\SessionGroup.xml'
#Pulls the User.xml file into a variable
[XML]$Users = Get-Content $Userspath
#Gets the max row count from the document and establishes $i for the while loop.
$max = $Users.Users.user.count
$i = 0
#Creates the arrays to hold the data
$Serviceplus= @()
$StandardSupport= @()
$Consulting= @()
$Onboarding= @()
#Pulls all the needed user values and adds them to corresponding arrays.
While ($i -lt $max)
{
If ( $users.users.user[$i].roles.InnerText -match 'ServicePlus'){$Serviceplus+= $users.users.user[$i].Name}
If ( $users.users.user[$i].roles.InnerText -match 'Standard Support'){$StandardSupport+= $users.users.user[$i].Name}
If ( $users.users.user[$i].roles.InnerText -match 'Consulting'){$Consulting+= $users.users.user[$i].Name}
If ( $users.users.user[$i].roles.InnerText -match 'Onboarding'){$Onboarding+= $users.users.user[$i].Name}
$i++
}
#Opens each Xpath from the SessionGroup.xml file and updates the values with the Strings from the corresponding array.
$XMLSelection = Select-Xml -Path $SessionPath -XPath '/SessionGroups/SessionGroup[16]/@SessionFilter'
$XMLSelection.node.'#text' = $StandardSupport -join ','
$XMLSelection.node.OwnerDocument.save($XMLSelection.path)
$XMLSelection = Select-Xml -Path $SessionPath -XPath '/SessionGroups/SessionGroup[17]/@SessionFilter'
$XMLSelection.node.'#text' = $Serviceplus -join ','
$XMLSelection.node.OwnerDocument.save($XMLSelection.path)
$XMLSelection = Select-Xml -Path $SessionPath -XPath '/SessionGroups/SessionGroup[18]/@SessionFilter'
$XMLSelection.node.'#text' = $Consulting -join ','
$XMLSelection.node.OwnerDocument.save($XMLSelection.path)
$XMLSelection = Select-Xml -Path $SessionPath -XPath '/SessionGroups/SessionGroup[19]/@SessionFilter'
$XMLSelection.node.'#text' = $Onboarding -join ','
$XMLSelection.node.OwnerDocument.save($XMLSelection.path)