I need to pick all the nodes from below xml where application name = "secureApps" via powerShell.
I am using below script but receiving error.
$xml = [xml](Get-Content AppsConfiguration.xml)
foreach ($node in $xml.SelectNodes('/configurations/application/app')| Where
$xml.configurations.application.name -eq "SecureApps" ) {
$app_name = $node.app_name
$app_path = $node.app_path
# Create directory if not found
if(-Not (Test-Path -Path $app_path)) {
New-Item $app_path -Type Directory
}
# Convert directory to virtual directory
New-WebVirtualDirectory -Site $secure_website_name.website_name -Name
$app_name -PhysicalPath $app_path
$site_path = $secure_iis_site_location + $app_path
ConvertTo-WebApplication -PSPath $site_path
}
The problem is in the line:
foreach ($node in $xml.SelectNodes('/configurations/application/app')| Where $xml.configurations.application.name -eq "SecureApps" ) {
The XML i am using is as below:
<?xml version="1.0"?>
<configurations>
<application name="SecureApps">
<app id= "1">
<app_name>atl</app_name>
<app_path>D:\inetpub\secure\admin\atl</app_path>
</app>
<app id= "2">
<app_name>corporate</app_name>
<app_path>D:\inetpub\secure\admin\corporate</app_path>
</app>
<app id= "3">
<app_name>f2l</app_name>
<app_path>D:\inetpub\secure\admin\f2l</app_path>
</app>
<app id= "4">
<app_name>GPModality</app_name>
<app_path>D:\inetpub\secure\admin\GPModality</app_path>
</app>
</application>
<application name="webApps">
<app id= "1">
<app_name>locations</app_name>
<app_path>D:\inetpub\web\locations</app_path>
</app>
</application>
$xml.SelectNodes('/configurations/application[@name="SecureApps"]/app')