-
Notifications
You must be signed in to change notification settings - Fork 0
/
XPath_Example.ps1
35 lines (28 loc) · 1.08 KB
/
XPath_Example.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
$xpath = @'
//*[
contains(
name(),
'Password'
)
]
'@
$param = @{
Namespace = @{
u = "urn:schemas-microsoft-com:unattend"
}
#xpath = "//*[contains(name(),'Password')]"
#xpath = "//*[contains(translate(name(),'PAS','pas'),'pass')]"
xpath = "//*[text() = '#PASSWORD#']"
}
#//*[contains(translate(name(),'PAS','pas'),'pass')]
$config = [xml](Get-Content -Path C:\dev\TestLab\unattend\unattend_IP_Copy.xml)
$config | Select-XML @param | Format-Table -AutoSize Node, @{
Name = 'Value'
Expression = { $_.Node.InnerXml }
}
$config | Select-XML @param | ForEach-Object -Process {$_.Node.Value = "Test";$Node = $_} -End {$Node.Node.OwnerDocument.Save("c:\dev\TestLab\unattend\Updated.xml")}
$config | Select-XML @param | ForEach-Object -Process {$_.Node."#text" = "Test";$Node = $_} -End {$Node.Node.OwnerDocument.Save("c:\dev\TestLab\unattend\Updated.xml")}
$NodePassword = $config | Select-XML @param | ForEach-Object -Process {$_.Node."#text" = "Test"}
ComputerName
$_.Node."#text"
//*[text() = 'qwerty']