Welcome › Forums › General PowerShell Q&A › Save xml file containing square bracket and dashes
I have xl file which i modify but when I try to save it, i get access denied error.
$file = "C:\Temp\[Name] Test [Name2] – Name3 = Name4.nfo"
[xml]$data = Get-Content -LiteralPath $file
$data.xml.title = "New name"
Exception calling "Save" with "1" argument(s): "Access to the path 'C:\Temp\[Name] Test [Name2] – Name3 = Name4.nfo' is denied."
At line:6 char:1
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
The error is Access Denied. Can you save to another file path? Is that file in use by an application?
If the file is hidden it doesnt work but if the file is not hidden it worked fine. All ok now
Must you use the square brackets in the name? Those are powershell wildcards.