Q: Powershell Xml file >> Creating a folder I want to create a folder with the name of the xml file in PowerShell from a part of an xml file.
I found something like that, but instead of a folder it's a txt file:
$xml = [xml](Get-Content c:\temp\config.xml)
$xml.config.compare.source
$xml.config.compare.parameters.parameter[0]
$xml.config.compare.source >> c:\temp\output.txt

Can not I use that to create a folder?

A: [xml]$xml = @"
<config>
    <compare>
        <original name="Test123" />
    </compare>
</config>
"@

# Get value from the XML
Write-Host $xml.config.compare.original.name

$newDirectory = Join-Path -Path "C:\Users" -ChildPath $env:USERNAME
Write-Host $newDirectory
$newDirectory = Join-Path -Path $newDirectory -ChildPath $xml.config.compare.original.name
Write-Host $newDirectory

# Create a folder using one of the values
New-Item -Path $newDirectory -ItemType Directory


A: Shorter answer
$NewDir = Join-Path -Path "C:\Users" -ChildPath $env:USERNAME | 

New-Item -Path $NewDir -Name $xml.config.compare.original.name -ItemType Directory

Alternatively Since the variable for C:\Users\CurrentUser alreay exists as $HOME :
New-Item -Path $NewDir -Name $xml.config.compare.original.name -ItemType Directory

